mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 20:57:52 +02:00
chore: drop Python 3.9 (and syntax) (#6289)
* `strict=False` is the default, pyupgrade to min version 3.10 adds this to be explicit w/ behavior
This commit is contained in:
@@ -4,12 +4,8 @@ import json
|
||||
from functools import partial
|
||||
from typing import (
|
||||
Annotated,
|
||||
List,
|
||||
Literal,
|
||||
Optional,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
import pytest
|
||||
@@ -419,7 +415,7 @@ def test__infer_handled_types() -> None:
|
||||
def handle2(e: Exception) -> str:
|
||||
return ""
|
||||
|
||||
def handle3(e: Union[ValueError, ToolException]) -> str:
|
||||
def handle3(e: ValueError | ToolException) -> str:
|
||||
return ""
|
||||
|
||||
class Handler:
|
||||
@@ -428,7 +424,7 @@ def test__infer_handled_types() -> None:
|
||||
|
||||
handle4 = Handler().handle
|
||||
|
||||
def handle5(e: Union[Union[TypeError, ValueError], ToolException]):
|
||||
def handle5(e: TypeError | ValueError | ToolException):
|
||||
return ""
|
||||
|
||||
expected: tuple = (Exception,)
|
||||
@@ -467,7 +463,7 @@ def test__infer_handled_types() -> None:
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
|
||||
def handler(e: Union[str, int]):
|
||||
def handler(e: str | int):
|
||||
return ""
|
||||
|
||||
_infer_handled_types(handler)
|
||||
@@ -506,7 +502,7 @@ class CustomState(AgentState):
|
||||
|
||||
|
||||
class CustomStatePydantic(AgentStatePydantic):
|
||||
user_name: Optional[str] = None
|
||||
user_name: str | None = None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version", REACT_TOOL_CALL_VERSIONS)
|
||||
@@ -687,7 +683,7 @@ T = TypeVar("T")
|
||||
_InjectedStateDataclassSchema,
|
||||
],
|
||||
)
|
||||
def test_tool_node_inject_state(schema_: Type[T]) -> None:
|
||||
def test_tool_node_inject_state(schema_: type[T]) -> None:
|
||||
def tool1(some_val: int, state: Annotated[T, InjectedState]) -> str:
|
||||
"""Tool 1 docstring."""
|
||||
if isinstance(state, dict):
|
||||
@@ -705,13 +701,13 @@ def test_tool_node_inject_state(schema_: Type[T]) -> None:
|
||||
def tool3(
|
||||
some_val: int,
|
||||
foo: Annotated[str, InjectedState("foo")],
|
||||
msgs: Annotated[List[AnyMessage], InjectedState("messages")],
|
||||
msgs: Annotated[list[AnyMessage], InjectedState("messages")],
|
||||
) -> str:
|
||||
"""Tool 1 docstring."""
|
||||
return foo
|
||||
|
||||
def tool4(
|
||||
some_val: int, msgs: Annotated[List[AnyMessage], InjectedState("messages")]
|
||||
some_val: int, msgs: Annotated[list[AnyMessage], InjectedState("messages")]
|
||||
) -> str:
|
||||
"""Tool 1 docstring."""
|
||||
return msgs[0].content
|
||||
@@ -2012,7 +2008,7 @@ def test_post_model_hook_with_structured_output() -> None:
|
||||
flag: bool
|
||||
structured_response: WeatherResponse
|
||||
|
||||
def post_model_hook(state: State) -> Union[dict[str, bool], Command]:
|
||||
def post_model_hook(state: State) -> dict[str, bool] | Command:
|
||||
return {"flag": True}
|
||||
|
||||
agent = create_react_agent(
|
||||
|
||||
Reference in New Issue
Block a user