6,570 matches across 25 files for error lang:Python lang:Python lang:Python lang:Python
snippet_mode: grep · sorted by relevance
236 dirs = [d for d in VCR_PACKAGES if d in all_affected]
237 else:
238▶ raise ValueError(f"Unknown job: {job}")
239
240 return [
· · ·
254
255 Raises:
256▶ ValueError: If a single argument looks like JSON but is not a string array.
257 """
258 if len(args) != 1:
· · ·
265 try:
266 parsed = json.loads(value)
267▶ except json.JSONDecodeError as e:
268 msg = "Expected changed files JSON to be a list of strings."
269 raise ValueError(msg) from e
· · ·
269▶ raise ValueError(msg) from e
270
271 if not isinstance(parsed, list) or not all(
· · ·
273 ):
274 msg = "Expected changed files JSON to be a list of strings."
275▶ raise ValueError(msg)
276 return parsed
277
+ 1 more matches in this file
42
43 Raises:
44▶ ValueError: If the dependency string cannot be parsed.
45 """
46 match = _NAME_RE.match(dep)
· · ·
47 if not match:
48 msg = f"Cannot parse dependency: {dep!r}"
49▶ raise ValueError(msg)
50 name = match.group(1)
51 rest = dep[match.end() :].strip()
· · ·
55 if close == -1:
56 msg = f"Unclosed extras bracket in dependency: {dep!r}"
57▶ raise ValueError(msg)
58 rest = rest[close + 1 :].strip()
59
· · ·
70
71def main(pyproject_path: Path) -> int:
72▶ """Check extras sync and return `0` on pass, `1` on mismatch or parse error."""
73 with pyproject_path.open("rb") as f:
74 data = tomllib.load(f)
· · ·
78 try:
79 name, spec = _parse_dep(dep)
80▶ except ValueError as e:
81 print(f"::error file={pyproject_path}::{e}")
82 return 1
+ 3 more matches in this file
25
26 if "rc" in dep_version_string:
27▶ raise ValueError(
28 f"Dependency {dep_version} has a prerelease version. Please remove this."
29 )
· · ·
32 "allow-prereleases", False
33 ):
34▶ raise ValueError(
35 f"Dependency {dep_version} has allow-prereleases set to true. Please remove this."
36 )
46 Raises:
47 requests.exceptions.RequestException: If PyPI API request fails
48▶ KeyError: If package not found or response format unexpected
49 """
50 pypi_url = f"https://pypi.org/pypi/{package_name}/json"
· · ·
86 if spec_set.contains(version):
87 valid_versions.append(version)
88▶ except ValueError:
89 continue
90
· · ·
183 return version in constraints
184 except Exception as e:
185▶ print(f"Error: {e}")
186 return False
187
27 # PyYAML (YAML 1.1) parses the bare key `on` as boolean True
28 return data[True]["workflow_dispatch"]["inputs"]["working-directory"]["options"]
29▶ except (KeyError, TypeError) as e:
30 msg = f"Could not find workflow_dispatch options in {workflow}: {e}"
31 raise AssertionError(msg) from e
· · ·
31▶ raise AssertionError(msg) from e
32
33
71
72 Raises:
73▶ AttributeError: If the attribute is not a valid dynamic import.
74 """
75 module_name = _dynamic_imports.get(attr_name)
124 """Finalize the annotation of a class."""
125 # Can't set new_doc on some extension objects.
126▶ with contextlib.suppress(AttributeError):
127 obj.__doc__ = new_doc
128
105 if pending and removal:
106 msg = "A pending deprecation cannot have a scheduled removal"
107▶ raise ValueError(msg)
108 if alternative and alternative_import:
109 msg = "Cannot specify both alternative and alternative_import"
· · ·
110▶ raise ValueError(msg)
111
112 if alternative_import and "." not in alternative_import:
· · ·
115 f" {alternative_import}"
116 )
117▶ raise ValueError(msg)
118
119
· · ·
259 """Finalize the deprecation of a class."""
260 # Can't set new_doc on some extension objects.
261▶ with contextlib.suppress(AttributeError):
262 obj.__doc__ = new_doc
263
· · ·
290 if not _name:
291 msg = f"Field {obj} must have a name to be deprecated."
292▶ raise ValueError(msg)
293 old_doc = obj.description
294
+ 2 more matches in this file
7 try:
8 frame = inspect.currentframe()
9▶ except AttributeError:
10 return False
11 if frame is None:
20
21 Raises:
22▶ ImportError: If the module cannot be found.
23 AttributeError: If the attribute does not exist in the module or package.
24
· · ·
23▶ AttributeError: If the attribute does not exist in the module or package.
24
25 Returns:
· · ·
29 try:
30 result = import_module(f".{attr_name}", package=package)
31▶ except ModuleNotFoundError:
32 msg = f"module '{package!r}' has no attribute {attr_name!r}"
33 raise AttributeError(msg) from None
· · ·
33▶ raise AttributeError(msg) from None
34 else:
35 try:
· · ·
36 module = import_module(f".{module_name}", package=package)
37▶ except ModuleNotFoundError as err:
38 msg = f"module '{package!r}.{module_name!r}' not found ({err})"
39 raise ImportError(msg) from None
+ 1 more matches in this file
8"""
9
10▶from langchain_core._security._exceptions import SSRFBlockedError
11from langchain_core._security._policy import (
12 SSRFPolicy,
· · ·
24
25__all__ = [
26▶ "SSRFBlockedError",
27 "SSRFPolicy",
28 "SSRFSafeSyncTransport",
2
3
4▶class SSRFBlockedError(Exception):
5 """Raised when a request is blocked by SSRF protection policy."""
6
8import urllib.parse
9
10▶from langchain_core._security._exceptions import SSRFBlockedError
11
12# ---------------------------------------------------------------------------
· · ·
192 """Validate a resolved IP address against the SSRF policy.
193
194▶ Raises SSRFBlockedError if the IP is blocked.
195 """
196 try:
· · ·
197 addr = ipaddress.ip_address(ip_str)
198▶ except ValueError as exc:
199 raise SSRFBlockedError("invalid IP address") from exc
200
· · ·
199▶ raise SSRFBlockedError("invalid IP address") from exc
200
201 if isinstance(addr, ipaddress.IPv6Address):
· · ·
206 reason = _ip_in_blocked_networks(addr, policy)
207 if reason is not None:
208▶ raise SSRFBlockedError(reason)
209
210
+ 12 more matches in this file
1▶"""SSRF Protection - thin wrapper raising ValueError for internal callers.
2
3Delegates all validation to `langchain_core._security._policy`.
· · ·
15)
16
17▶from langchain_core._security._exceptions import SSRFBlockedError
18from langchain_core._security._policy import (
19 SSRFPolicy,
· · ·
60
61 Raises:
62▶ ValueError: If URL is invalid or potentially dangerous.
63 """
64 url_str = str(url)
· · ·
79 try:
80 _validate_url_sync(url_str, policy)
81▶ except SSRFBlockedError as exc:
82 raise ValueError(str(exc)) from exc
83
· · ·
82▶ raise ValueError(str(exc)) from exc
83
84 # DNS resolution and IP validation
+ 8 more matches in this file
6import httpx
7
8▶from langchain_core._security._exceptions import SSRFBlockedError
9from langchain_core._security._policy import (
10 SSRFPolicy,
· · ·
65 try:
66 validate_url_sync(str(request.url), self._policy)
67▶ except SSRFBlockedError:
68 raise
69
· · ·
82 type=socket.SOCK_STREAM,
83 )
84▶ except socket.gaierror as exc:
85 raise SSRFBlockedError("DNS resolution failed") from exc
86
· · ·
85▶ raise SSRFBlockedError("DNS resolution failed") from exc
86
87 if not addrinfo:
· · ·
88▶ raise SSRFBlockedError("DNS resolution returned no results")
89
90 # 5. Validate ALL resolved IPs - any blocked means reject.
+ 3 more matches in this file
191
192 Raises:
193▶ ValueError: If `maxsize` is less than or equal to `0`.
194 """
195 self._cache: dict[tuple[str, str], RETURN_VAL_TYPE] = {}
· · ·
196 if maxsize is not None and maxsize <= 0:
197 msg = "maxsize must be greater than 0"
198▶ raise ValueError(msg)
199 self._maxsize = maxsize
200
25 """Mixin for `Retriever` callbacks."""
26
27▶ def on_retriever_error(
28 self,
29 error: BaseException,
· · ·
29▶ error: BaseException,
30 *,
31 run_id: UUID,
· · ·
33 **kwargs: Any,
34 ) -> Any:
35▶ """Run when `Retriever` errors.
36
37 Args:
· · ·
38▶ error: The error that occurred.
39 run_id: The ID of the current run.
40 parent_run_id: The ID of the parent run.
· · ·
107 """
108
109▶ def on_llm_error(
110 self,
111 error: BaseException,
+ 40 more matches in this file
139
140 Raises:
141▶ RuntimeError: If the file is closed or not available.
142
143 """
· · ·
157 if not hasattr(self, "file") or self.file is None or self.file.closed:
158 msg = "File is not open. Use FileCallbackHandler as a context manager."
159▶ raise RuntimeError(msg)
160
161 print_text(text, file=self.file, color=color, end=end)
125 except Exception as e:
126 if not group_cm.ended:
127▶ run_manager.on_chain_error(e)
128 raise
129 else:
· · ·
208 except Exception as e:
209 if not group_cm.ended:
210▶ await run_manager.on_chain_error(e)
211 raise
212 else:
· · ·
244 # `call-arg` used to not fail 3.9 or 3.10 tests
245 return await asyncio.shield(task)
246▶ except TypeError:
247 # Python < 3.11 fallback - create task normally then shield
248 # This won't preserve context perfectly but is better than nothing
· · ·
283 if asyncio.iscoroutine(event):
284 coros.append(event)
285▶ except NotImplementedError as e:
286 if event_name == "on_chat_model_start":
287 if message_strings is None:
· · ·
299 handler_name = handler.__class__.__name__
300 logger.warning(
301▶ "NotImplementedError in %s.%s callback: %s",
302 handler_name,
303 event_name,
+ 83 more matches in this file
68 """
69
70▶ def on_llm_error(self, error: BaseException, **kwargs: Any) -> None:
71 """Run when LLM errors.
72
· · ·
71▶ """Run when LLM errors.
72
73 Args:
· · ·
74▶ error: The error that occurred.
75 **kwargs: Additional keyword arguments.
76 """
· · ·
95 """
96
97▶ def on_chain_error(self, error: BaseException, **kwargs: Any) -> None:
98 """Run when chain errors.
99
· · ·
98▶ """Run when chain errors.
99
100 Args:
+ 4 more matches in this file
53 try:
54 generation = response.generations[0][0]
55▶ except IndexError:
56 generation = None
57
· · ·
64 usage_metadata = message.usage_metadata
65 model_name = message.response_metadata.get("model_name")
66▶ except AttributeError:
67 pass
68
69 messages_data = json.load(f)
70 return messages_from_dict(messages_data)
71▶ except FileNotFoundError:
72 return []
73
· · ·
153
154 Raises:
155▶ NotImplementedError: If the sub-class has not implemented an efficient
156 `add_messages` method.
157 """
· · ·
165 "Please implement add_message or add_messages."
166 )
167▶ raise NotImplementedError(msg)
168
169 def add_messages(self, messages: Sequence[BaseMessage]) -> None:
20
21 _HAS_TEXT_SPLITTERS = True
22▶except ImportError:
23 _HAS_TEXT_SPLITTERS = False
24
· · ·
66
67 Raises:
68▶ ImportError: If `langchain-text-splitters` is not installed and no
69 `text_splitter` is provided.
70
· · ·
79 "`pip install -U langchain-text-splitters`."
80 )
81▶ raise ImportError(msg)
82
83 text_splitter_: TextSplitter = RecursiveCharacterTextSplitter()
· · ·
98 return iter(self.load())
99 msg = f"{self.__class__.__name__} does not implement lazy_load()"
100▶ raise NotImplementedError(msg)
101
102 async def alazy_load(self) -> AsyncIterator[Document]:
92
93 Raises:
94▶ ValueError: If both `client` and `client_kwargs` are provided.
95 """ # noqa: E501
96 if client and client_kwargs:
· · ·
97▶ raise ValueError
98 self._client = client or LangSmithClient(**client_kwargs)
99 self.content_key = list(content_key.split(".")) if content_key else []
153 if "data" not in values and "path" not in values:
154 msg = "Either data or path must be provided"
155▶ raise ValueError(msg)
156 return values
157
· · ·
160
161 Raises:
162▶ ValueError: If the blob cannot be represented as a string.
163
164 Returns:
· · ·
172 return self.data
173 msg = f"Unable to get string for blob {self}"
174▶ raise ValueError(msg)
175
176 def as_bytes(self) -> bytes:
· · ·
178
179 Raises:
180▶ ValueError: If the blob cannot be represented as bytes.
181
182 Returns:
· · ·
190 return Path(self.path).read_bytes()
191 msg = f"Unable to get bytes for blob {self}"
192▶ raise ValueError(msg)
193
194 @contextlib.contextmanager
+ 2 more matches in this file
Search syntax
auth login | both terms (AND is implicit) |
auth OR login | either term |
NOT path:vendor | exclude matches |
"exact phrase" | quoted exact match |
/func\s+Test/ | regex |
handler~1 | fuzzy (Levenshtein 1) |
file:*_test.go | filename glob |
path:pkg/auth/** | full path glob |
lang:go | language filter |
Search any public repo from your terminal
This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.