mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
style(langchain): add ruff rule RUF012 (#34497)
Co-authored-by: Mason Daugherty <mason@langchain.dev> Co-authored-by: Mason Daugherty <github@mdrxy.com>
This commit is contained in:
committed by
GitHub
parent
85f1ba2351
commit
0bd862b814
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from collections.abc import Awaitable, Callable, Sequence
|
||||
from dataclasses import dataclass, field, replace
|
||||
from inspect import iscoroutinefunction
|
||||
from typing import (
|
||||
@@ -338,7 +338,7 @@ class AgentMiddleware(Generic[StateT, ContextT]):
|
||||
state_schema: type[StateT] = cast("type[StateT]", AgentState)
|
||||
"""The schema for state passed to the middleware nodes."""
|
||||
|
||||
tools: list[BaseTool]
|
||||
tools: Sequence[BaseTool]
|
||||
"""Additional tools registered by the middleware."""
|
||||
|
||||
@property
|
||||
|
||||
@@ -112,7 +112,6 @@ ignore = [
|
||||
"FIX002", # Line contains TODO
|
||||
"PERF203", # Rarely useful
|
||||
"PLR09", # Too many something (arg, statements, etc)
|
||||
"RUF012", # Doesn't play well with Pydantic
|
||||
"TD002", # Missing author in TODO
|
||||
"TD003", # Missing issue link in TODO
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ def test_middleware_with_additional_tools() -> None:
|
||||
return "middleware"
|
||||
|
||||
class ToolProvidingMiddleware(AgentMiddleware):
|
||||
tools = [middleware_tool]
|
||||
tools = (middleware_tool,)
|
||||
|
||||
# Model calls the middleware-provided tool
|
||||
model = FakeToolCallingModel(
|
||||
|
||||
@@ -31,7 +31,7 @@ class ProfileChatModel(BaseChatModel):
|
||||
def _generate(self, messages, **kwargs): # type: ignore[no-untyped-def]
|
||||
return ChatResult(generations=[ChatGeneration(message=AIMessage(content="Summary"))])
|
||||
|
||||
profile: ModelProfile | None = {"max_input_tokens": 1000}
|
||||
profile: ModelProfile | None = ModelProfile(max_input_tokens=1000)
|
||||
|
||||
@property
|
||||
def _llm_type(self) -> str:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Unit tests for tool emulator middleware."""
|
||||
|
||||
import typing
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Sequence
|
||||
from itertools import cycle
|
||||
from typing import Any, Literal
|
||||
|
||||
@@ -86,7 +86,7 @@ class FakeModel(GenericFakeChatModel):
|
||||
class FakeEmulatorModel(BaseChatModel):
|
||||
"""Fake model for emulating tool responses."""
|
||||
|
||||
responses: list[str] = ["Emulated response"]
|
||||
responses: Sequence[str] = ("Emulated response",)
|
||||
response_index: int = 0
|
||||
|
||||
def _generate(
|
||||
|
||||
@@ -776,7 +776,7 @@ class TestDynamicModelWithResponseFormat:
|
||||
# Custom model that we'll use to test whether the tool strategy is applied
|
||||
# correctly at runtime.
|
||||
class CustomModel(GenericFakeChatModel):
|
||||
tool_bindings: list[Any] = []
|
||||
tool_bindings: list[Any] = Field(default_factory=list)
|
||||
|
||||
def bind_tools(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user