Cleanup after ai

This commit is contained in:
Michael Panchenko
2025-04-22 17:32:45 +02:00
parent 5ad8158391
commit e51cb768db
3 changed files with 6 additions and 23 deletions
+4 -5
View File
@@ -1372,11 +1372,10 @@ class InitialInstructionsTool(Tool):
def iter_tool_classes(same_module_only: bool = True) -> Generator[type[Tool], None, None]:
"""
Iterate over all Tool subclasses.
Args:
same_module_only: If True, only iterate over tools defined in the same module as the Tool class.
If False, iterate over all Tool subclasses.
Iterate over Tool subclasses.
:param same_module_only: Whether to only iterate over tools defined in the same module as the Tool class
or over all subclasses of Tool.
"""
for tool_class in iter_subclasses(Tool):
if same_module_only and tool_class.__module__ != Tool.__module__:
+2 -18
View File
@@ -3,7 +3,7 @@
import pytest
from mcp.server.fastmcp.tools.base import Tool as MCPTool
from serena.agent import Tool
from serena.agent import Tool, iter_tool_classes
from serena.mcp import make_tool
@@ -269,23 +269,7 @@ def is_test_mock_class(tool_class: type) -> bool:
)
def get_real_tool_classes():
"""Get all non-test, non-abstract tool classes."""
from serena.agent import iter_tool_classes
for tool_class in iter_tool_classes(same_module_only=False):
# Skip abstract base classes that can't be instantiated
if tool_class.__name__ == "Tool" or getattr(tool_class, "__abstractmethods__", set()):
continue
# Skip test mock classes
if is_test_mock_class(tool_class):
continue
yield tool_class
@pytest.mark.parametrize("tool_class", list(get_real_tool_classes()))
@pytest.mark.parametrize("tool_class", list(iter_tool_classes()))
def test_make_tool_all_tools(tool_class) -> None:
"""Test that make_tool works for all tools in the codebase."""