Skip to content

Commit 2753513

Browse files
committed
refactor: complete migration to native Python typing
- Replace Union[A, B] with A | B (using string literals for forward refs) - Replace Optional[T] with T | None - Replace List[T] with list[T] - Replace Any with any - Use collections.abc.Callable instead of typing.Callable - Maintain TYPE_CHECKING for circular import resolution - All tests pass with native typing syntax 🤖 Assisted by Amazon Q Developer
1 parent 226f351 commit 2753513

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/strands/experimental/agent_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def tool_pool(self) -> "ToolPool":
4545
"""
4646
return self._tool_pool
4747

48-
def toAgent(self, tools: "ToolPool" | None = None, **kwargs: any) -> "Agent":
48+
def toAgent(self, tools: "ToolPool | None" = None, **kwargs: any) -> "Agent":
4949
"""Create an Agent instance from this configuration.
5050
5151
Args:

src/strands/experimental/tool_pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ABOUTME: Integrates with existing tool infrastructure and @tool decorator pattern
33
"""Experimental tool pool system for structured tool management."""
44

5-
from typing import Any, Optional, Union, Callable
5+
from collections.abc import Callable
66

77
from ..types.tools import AgentTool
88
from ..tools.tools import PythonAgentTool
@@ -12,7 +12,7 @@
1212
class ToolPool:
1313
"""Pool of available tools for agent selection using existing tool infrastructure."""
1414

15-
def __init__(self, tools: Optional[list[Union[AgentTool, Callable]]] = None):
15+
def __init__(self, tools: "list[AgentTool | Callable] | None" = None):
1616
"""Initialize tool pool.
1717
1818
Args:
@@ -56,7 +56,7 @@ def add_tool_function(self, tool_func: Callable) -> None:
5656
else:
5757
raise ValueError(f"Function {tool_func.__name__} is not decorated with @tool")
5858

59-
def add_tools_from_module(self, module: Any) -> None:
59+
def add_tools_from_module(self, module: any) -> None:
6060
"""Add all @tool decorated functions from a Python module.
6161
6262
Args:
@@ -69,7 +69,7 @@ def add_tools_from_module(self, module: Any) -> None:
6969
self.add_tool_function(obj)
7070

7171
@classmethod
72-
def from_module(cls, module: Any) -> "ToolPool":
72+
def from_module(cls, module: any) -> "ToolPool":
7373
"""Create ToolPool from all @tool functions in a module.
7474
7575
Args:
@@ -82,7 +82,7 @@ def from_module(cls, module: Any) -> "ToolPool":
8282
pool.add_tools_from_module(module)
8383
return pool
8484

85-
def get_tool(self, name: str) -> Optional[AgentTool]:
85+
def get_tool(self, name: str) -> AgentTool | None:
8686
"""Get tool by name.
8787
8888
Args:

0 commit comments

Comments
 (0)