From c34bc7def0e02e02d7d25242cb4bdb7c5c3741ea Mon Sep 17 00:00:00 2001 From: S2D2 Date: Tue, 10 Nov 2026 20:29:44 +0000 Subject: [PATCH 1/3] refactor: drop an unused attribute and redundant exception checks - StackOneToolSet._execute_config was assigned in __init__ and never read; account_ids and timeout are taken from the execute argument directly. - ToolsetError subclasses StackOneError, so catching or isinstance-checking both is the same as StackOneError alone. The ToolsetError imports in tools.py and toolset.py then go unused. No behaviour change. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- stackone_ai/tools.py | 3 +-- stackone_ai/toolset.py | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/stackone_ai/tools.py b/stackone_ai/tools.py index 486b6aa..26cb869 100644 --- a/stackone_ai/tools.py +++ b/stackone_ai/tools.py @@ -42,7 +42,6 @@ ToolArgumentsError, ToolParameters, ToolsetConfigError, - ToolsetError, ToolsetLoadError, ) @@ -755,7 +754,7 @@ def _describe_mcp_failure(exc: BaseException, endpoint: str, timeout: float) -> seen.add(id(current)) # Our own errors are already descriptive. They reach here wrapped in an # ExceptionGroup because they are raised inside the session's TaskGroup. - if isinstance(current, StackOneError | ToolsetError): + if isinstance(current, StackOneError): return current if isinstance(current, httpx.HTTPStatusError): body = _response_body(current.response) diff --git a/stackone_ai/toolset.py b/stackone_ai/toolset.py index 0780659..f8d5561 100644 --- a/stackone_ai/toolset.py +++ b/stackone_ai/toolset.py @@ -52,7 +52,6 @@ ToolMode, ToolParameters, ToolsetConfigError, - ToolsetError, ToolsetLoadError, ) @@ -231,7 +230,6 @@ def __init__( self._account_ids: list[str] = self._validate_account_ids( execute.get("account_ids") if execute else None ) - self._execute_config: ExecuteToolsConfig | None = execute execute_timeout = execute.get("timeout") if execute else None self._timeout: float = ( timeout if timeout is not None else (execute_timeout if execute_timeout is not None else 60.0) @@ -398,7 +396,7 @@ def fetch_tools( return Tools(all_tools) - except (ToolsetError, StackOneError): + except StackOneError: # StackOneAPIError carries the HTTP status. Re-wrapping it below would throw # that away, so a caller could not tell a 401 from a 429. raise From ef8dd6d0cc1c0811ccbf582856308ff5c6d6931c Mon Sep 17 00:00:00 2001 From: S2D2 Date: Tue, 10 Nov 2026 20:41:52 +0000 Subject: [PATCH 2/3] test: stop setting the removed StackOneToolSet._execute_config Two pydantic_ai tests assigned the attribute on a toolset built with __new__. Nothing reads it, so the assignments set state no code uses. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- tests/test_integrations_pydantic_ai.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_integrations_pydantic_ai.py b/tests/test_integrations_pydantic_ai.py index 3bdc1cd..b605582 100644 --- a/tests/test_integrations_pydantic_ai.py +++ b/tests/test_integrations_pydantic_ai.py @@ -122,7 +122,6 @@ def test_tools_to_pydantic_ai_with_agent(sample_tool: StackOneTool, monkeypatch: def test_toolset_pydantic_ai_default_uses_fetch_tools(sample_tool: StackOneTool): toolset = StackOneToolSet.__new__(StackOneToolSet) toolset.fetch_tools = MagicMock(return_value=Tools([sample_tool])) # type: ignore[method-assign] - toolset._execute_config = None # type: ignore[attr-defined] tools = toolset.pydantic_ai() @@ -134,7 +133,6 @@ def test_toolset_pydantic_ai_default_uses_fetch_tools(sample_tool: StackOneTool) def test_toolset_pydantic_ai_account_ids_override(sample_tool: StackOneTool): toolset = StackOneToolSet.__new__(StackOneToolSet) toolset.fetch_tools = MagicMock(return_value=Tools([sample_tool])) # type: ignore[method-assign] - toolset._execute_config = {"account_ids": ["from-config"]} # type: ignore[attr-defined] toolset.pydantic_ai(account_ids=["override"]) From 5f84c6030a019a8f46a7572239ee6ce952e0d1d0 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Wed, 11 Nov 2026 00:52:49 +0000 Subject: [PATCH 3/3] test: name the pydantic_ai account_ids test for what it checks With the dead _execute_config setup gone, nothing configured is overridden; the test checks that pydantic_ai() passes account_ids to fetch_tools. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- tests/test_integrations_pydantic_ai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_integrations_pydantic_ai.py b/tests/test_integrations_pydantic_ai.py index b605582..730757d 100644 --- a/tests/test_integrations_pydantic_ai.py +++ b/tests/test_integrations_pydantic_ai.py @@ -130,7 +130,7 @@ def test_toolset_pydantic_ai_default_uses_fetch_tools(sample_tool: StackOneTool) assert tools[0].name == "bamboohr_list_employees" -def test_toolset_pydantic_ai_account_ids_override(sample_tool: StackOneTool): +def test_toolset_pydantic_ai_passes_account_ids_through(sample_tool: StackOneTool): toolset = StackOneToolSet.__new__(StackOneToolSet) toolset.fetch_tools = MagicMock(return_value=Tools([sample_tool])) # type: ignore[method-assign]