core: Add ruff rules S110 and S112 (#30599)

This commit is contained in:
Christophe Bornet 2025-04-01 19:17:22 +02:00 committed by GitHub
parent 88b4233fa1
commit 768e4f695a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View File

@ -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,

View File

@ -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"):

View File

@ -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)

View File

@ -107,8 +107,6 @@ ignore = [
"PYI",
"RET",
"RUF",
"S110",
"S112",
"SLF",
"TD",
]