mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-17 16:39:52 +00:00
core: Add ruff rules S110 and S112 (#30599)
This commit is contained in:
parent
88b4233fa1
commit
768e4f695a
@ -1,6 +1,7 @@
|
||||
"""Serializable base class."""
|
||||
|
||||
import contextlib
|
||||
import logging
|
||||
from abc import ABC
|
||||
from typing import (
|
||||
Any,
|
||||
@ -15,6 +16,8 @@ from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import NotRequired, override
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BaseSerialized(TypedDict):
|
||||
"""Base class for serialized objects.
|
||||
@ -359,7 +362,7 @@ def to_json_not_implemented(obj: object) -> SerializedNotImplemented:
|
||||
elif hasattr(obj, "__class__"):
|
||||
_id = [*obj.__class__.__module__.split("."), obj.__class__.__name__]
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("Failed to serialize object", exc_info=True)
|
||||
|
||||
result: SerializedNotImplemented = {
|
||||
"lc": 1,
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""AI message."""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import operator
|
||||
from typing import Any, Literal, Optional, Union, cast
|
||||
|
||||
@ -32,6 +33,8 @@ from langchain_core.utils._merge import merge_dicts, merge_lists
|
||||
from langchain_core.utils.json import parse_partial_json
|
||||
from langchain_core.utils.usage import _dict_int_op
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InputTokenDetails(TypedDict, total=False):
|
||||
"""Breakdown of input token counts.
|
||||
@ -210,7 +213,7 @@ class AIMessage(BaseMessage):
|
||||
values["tool_calls"] = parsed_tool_calls
|
||||
values["invalid_tool_calls"] = parsed_invalid_tool_calls
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("Failed to parse tool calls", exc_info=True)
|
||||
|
||||
# Ensure "type" is properly set on all tool call-like dicts.
|
||||
if tool_calls := values.get("tool_calls"):
|
||||
|
@ -20,11 +20,7 @@ def _get_sub_deps(packages: Sequence[str]) -> list[str]:
|
||||
continue
|
||||
|
||||
for req in required:
|
||||
try:
|
||||
cleaned_req = req.split(" ")[0]
|
||||
except Exception: # In case parsing of requirement spec fails
|
||||
continue
|
||||
|
||||
if cleaned_req.replace("-", "_") not in _underscored_packages:
|
||||
sub_deps.add(cleaned_req)
|
||||
|
||||
|
@ -107,8 +107,6 @@ ignore = [
|
||||
"PYI",
|
||||
"RET",
|
||||
"RUF",
|
||||
"S110",
|
||||
"S112",
|
||||
"SLF",
|
||||
"TD",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user