Skip to content

Commit 9233619

Browse files
committed
chore: delint
1 parent cb0492b commit 9233619

4 files changed

Lines changed: 30 additions & 10 deletions

File tree

packages/toolbox-adk/src/toolbox_adk/toolset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
from google.adk.tools.base_tool import BaseTool
1919
from google.adk.tools.base_toolset import BaseToolset
2020
from google.adk.tools.tool_context import ToolContext
21+
from toolbox_core.utils import validate_unused_requirements
2122
from typing_extensions import override
2223

2324
from .client import ToolboxClient
2425
from .credentials import CredentialConfig
2526
from .tool import ToolboxTool
26-
from toolbox_core.utils import validate_unused_requirements
2727

2828

2929
class ToolboxToolset(BaseToolset):
@@ -131,7 +131,9 @@ async def get_tools(
131131
# Generate intuitive name for the error string if a specific toolset wasn't used
132132
validation_name = self.__toolset_name
133133
if not validation_name:
134-
validation_name = ", ".join(self.__tool_names) if self.__tool_names else "default"
134+
validation_name = (
135+
", ".join(self.__tool_names) if self.__tool_names else "default"
136+
)
135137

136138
validate_unused_requirements(
137139
provided_auth_keys=set(self.__auth_token_getters.keys()),

packages/toolbox-adk/tests/integration/test_integration.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,13 @@ async def test_run_multiple_tools_partial_auth_usage(self, auth_token2: str):
572572
"""Tests that when some tokens are used and some aren't across diverse tools, only the truly unused tokens appear in the error."""
573573
toolset = ToolboxToolset(
574574
server_url="http://localhost:5000",
575-
tool_names=["get-row-by-id-auth", "search-rows"], # first requires 'my-test-auth', second requires nothing
575+
tool_names=[
576+
"get-row-by-id-auth",
577+
"search-rows",
578+
], # first requires 'my-test-auth', second requires nothing
576579
auth_token_getters={
577-
"my-test-auth": lambda: auth_token2,
578-
"extra-token": lambda: "fake"
580+
"my-test-auth": lambda: auth_token2,
581+
"extra-token": lambda: "fake",
579582
},
580583
credentials=CredentialStrategy.toolbox_identity(),
581584
)

packages/toolbox-adk/tests/unit/test_toolset.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,21 @@ async def test_get_tools_with_auth_token_getters(self, mock_client_cls):
8484
({}, [], True), # No requirements, token is completely unused
8585
({"param1": ["service"]}, [], False), # authn natively consumes it
8686
({}, ["service"], False), # authz natively consumes it
87-
({"param1": ["other"]}, ["service"], False), # unused by authn, but authz consumes it
88-
({"param1": ["service"]}, ["other"], False), # authn consumes it, authz doesn't
89-
({"param1": ["other"]}, ["other"], True), # Requirements exist, but token is unused by both
87+
(
88+
{"param1": ["other"]},
89+
["service"],
90+
False,
91+
), # unused by authn, but authz consumes it
92+
(
93+
{"param1": ["service"]},
94+
["other"],
95+
False,
96+
), # authn consumes it, authz doesn't
97+
(
98+
{"param1": ["other"]},
99+
["other"],
100+
True,
101+
), # Requirements exist, but token is unused by both
90102
],
91103
)
92104
async def test_get_tools_auth_validation(
@@ -107,7 +119,8 @@ async def test_get_tools_auth_validation(
107119

108120
if should_raise:
109121
with pytest.raises(
110-
ValueError, match="unused auth tokens could not be applied to any tool: service"
122+
ValueError,
123+
match="unused auth tokens could not be applied to any tool: service",
111124
):
112125
await toolset.get_tools()
113126
else:

packages/toolbox-core/src/toolbox_core/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def validate_unused_requirements(
201201
f"unused bound parameters: {', '.join(unused_bound)}"
202202
)
203203

204-
final_target_type = target_type if target_type else ("toolset" if is_toolset else "tool")
204+
final_target_type = (
205+
target_type if target_type else ("toolset" if is_toolset else "tool")
206+
)
205207
raise ValueError(
206208
f"Validation failed for {final_target_type} '{name}': {'; '.join(error_messages)}."
207209
)

0 commit comments

Comments
 (0)