mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 18:50:33 +00:00
chore(langchain): check agents integration tests with mypy (#34308)
This commit is contained in:
committed by
GitHub
parent
d6b5f05f33
commit
bbc1d46efe
@@ -94,7 +94,7 @@ line-length = 100
|
|||||||
strict = true
|
strict = true
|
||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
enable_error_code = "deprecated"
|
enable_error_code = "deprecated"
|
||||||
exclude = ["tests/unit_tests/agents/*", "tests/integration_tests/agents/*"]
|
exclude = ["tests/unit_tests/agents/*"]
|
||||||
|
|
||||||
# TODO: activate for 'strict' checking
|
# TODO: activate for 'strict' checking
|
||||||
disallow_any_generics = false
|
disallow_any_generics = false
|
||||||
|
|||||||
@@ -7,9 +7,13 @@ from typing import Any
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from langchain_core.messages import HumanMessage
|
from langchain_core.messages import HumanMessage
|
||||||
|
from langgraph._internal._typing import StateLike
|
||||||
|
from langgraph.graph.state import CompiledStateGraph
|
||||||
|
from typing_extensions import TypedDict
|
||||||
|
|
||||||
from langchain.agents import create_agent
|
from langchain.agents import create_agent
|
||||||
from langchain.agents.middleware.shell_tool import ShellToolMiddleware
|
from langchain.agents.middleware.shell_tool import ShellToolMiddleware
|
||||||
|
from langchain.agents.middleware.types import _InputAgentState
|
||||||
|
|
||||||
|
|
||||||
def _get_model(provider: str) -> Any:
|
def _get_model(provider: str) -> Any:
|
||||||
@@ -33,7 +37,7 @@ def test_shell_tool_basic_execution(tmp_path: Path, provider: str) -> None:
|
|||||||
pytest.importorskip(f"langchain_{provider}")
|
pytest.importorskip(f"langchain_{provider}")
|
||||||
|
|
||||||
workspace = tmp_path / "workspace"
|
workspace = tmp_path / "workspace"
|
||||||
agent = create_agent(
|
agent: CompiledStateGraph[Any, Any, _InputAgentState, Any] = create_agent(
|
||||||
model=_get_model(provider),
|
model=_get_model(provider),
|
||||||
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
||||||
)
|
)
|
||||||
@@ -55,7 +59,7 @@ def test_shell_tool_basic_execution(tmp_path: Path, provider: str) -> None:
|
|||||||
def test_shell_session_persistence(tmp_path: Path) -> None:
|
def test_shell_session_persistence(tmp_path: Path) -> None:
|
||||||
"""Test shell session state persists across multiple tool calls."""
|
"""Test shell session state persists across multiple tool calls."""
|
||||||
workspace = tmp_path / "workspace"
|
workspace = tmp_path / "workspace"
|
||||||
agent = create_agent(
|
agent: CompiledStateGraph[Any, Any, _InputAgentState, Any] = create_agent(
|
||||||
model=_get_model("anthropic"),
|
model=_get_model("anthropic"),
|
||||||
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
||||||
)
|
)
|
||||||
@@ -82,7 +86,7 @@ def test_shell_session_persistence(tmp_path: Path) -> None:
|
|||||||
def test_shell_tool_error_handling(tmp_path: Path) -> None:
|
def test_shell_tool_error_handling(tmp_path: Path) -> None:
|
||||||
"""Test shell tool captures command errors."""
|
"""Test shell tool captures command errors."""
|
||||||
workspace = tmp_path / "workspace"
|
workspace = tmp_path / "workspace"
|
||||||
agent = create_agent(
|
agent: CompiledStateGraph[Any, Any, _InputAgentState, Any] = create_agent(
|
||||||
model=_get_model("anthropic"),
|
model=_get_model("anthropic"),
|
||||||
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
||||||
)
|
)
|
||||||
@@ -121,7 +125,7 @@ def test_shell_tool_with_custom_tools(tmp_path: Path) -> None:
|
|||||||
"""Greet someone by name."""
|
"""Greet someone by name."""
|
||||||
return f"Hello, {name}!"
|
return f"Hello, {name}!"
|
||||||
|
|
||||||
agent = create_agent(
|
agent: CompiledStateGraph[Any, Any, _InputAgentState, Any] = create_agent(
|
||||||
model=_get_model("anthropic"),
|
model=_get_model("anthropic"),
|
||||||
tools=[custom_greeting],
|
tools=[custom_greeting],
|
||||||
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
middleware=[ShellToolMiddleware(workspace_root=workspace)],
|
||||||
|
|||||||
Reference in New Issue
Block a user