Skip to content

Commit 57bbbcd

Browse files
committed
style: Run black across all packages
1 parent 587e0ba commit 57bbbcd

16 files changed

Lines changed: 141 additions & 70 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
from typing import Any, Awaitable, Callable, Dict, Mapping, Optional
1818

1919
import toolbox_core
20-
from fastapi.openapi.models import (OAuth2, OAuthFlowAuthorizationCode,
21-
OAuthFlows)
22-
from google.adk.auth.auth_credential import (AuthCredential,
23-
AuthCredentialTypes, OAuth2Auth)
20+
from fastapi.openapi.models import OAuth2, OAuthFlowAuthorizationCode, OAuthFlows
21+
from google.adk.auth.auth_credential import (
22+
AuthCredential,
23+
AuthCredentialTypes,
24+
OAuth2Auth,
25+
)
2426
from google.adk.auth.auth_tool import AuthConfig
2527
from google.adk.tools.base_tool import BaseTool
2628
from google.adk.tools.tool_context import ToolContext

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import (Any, Awaitable, Callable, Dict, List, Mapping, Optional,
16-
Union)
15+
from typing import Any, Awaitable, Callable, Dict, List, Mapping, Optional, Union
1716

1817
from google.adk.agents.readonly_context import ReadonlyContext
1918
from google.adk.tools.base_tool import BaseTool

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import pytest
2020
from google import genai
2121
from google.adk import Agent
22-
from google.adk.auth.auth_credential import (AuthCredential,
23-
AuthCredentialTypes, OAuth2Auth)
22+
from google.adk.auth.auth_credential import (
23+
AuthCredential,
24+
AuthCredentialTypes,
25+
OAuth2Auth,
26+
)
2427
from google.adk.runners import Runner
25-
from google.adk.sessions.in_memory_session_service import \
26-
InMemorySessionService
28+
from google.adk.sessions.in_memory_session_service import InMemorySessionService
2729
from google.adk.tools.base_tool import BaseTool
2830
from google.genai import types
2931
from pydantic import ValidationError
@@ -315,9 +317,12 @@ async def test_api_key_integration(self):
315317

316318
async def test_adk_integration_optional_params(self):
317319
"""test that we can create credentials from ADK objects without auth_scheme."""
318-
from google.adk.auth.auth_credential import (AuthCredential,
319-
AuthCredentialTypes,
320-
HttpAuth, HttpCredentials)
320+
from google.adk.auth.auth_credential import (
321+
AuthCredential,
322+
AuthCredentialTypes,
323+
HttpAuth,
324+
HttpCredentials,
325+
)
321326

322327
# 1. Create ADK credential (HTTP Bearer)
323328
adk_creds = AuthCredential(
@@ -636,7 +641,9 @@ async def test_run_tool_wrong_auth(self, auth_token2: str):
636641
pytest.fail("Expected tool to fail with auth error")
637642
except Exception as e:
638643
err_str = str(e)
639-
assert "401" in err_str or "-32600" in err_str, f"Unexpected error message: {err_str}"
644+
assert (
645+
"401" in err_str or "-32600" in err_str
646+
), f"Unexpected error message: {err_str}"
640647
finally:
641648
await toolset.close()
642649

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

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ def test_api_key(self):
6565

6666
def test_from_adk_credentials_oauth2(self):
6767
from fastapi.openapi.models import OAuth2, OAuthFlows
68-
from google.adk.auth.auth_credential import (AuthCredential,
69-
AuthCredentialTypes,
70-
OAuth2Auth)
68+
from google.adk.auth.auth_credential import (
69+
AuthCredential,
70+
AuthCredentialTypes,
71+
OAuth2Auth,
72+
)
7173

7274
auth_credential = AuthCredential(
7375
auth_type=AuthCredentialTypes.OAUTH2,
@@ -84,9 +86,12 @@ def test_from_adk_credentials_oauth2(self):
8486

8587
def test_from_adk_credentials_http_bearer(self):
8688
from fastapi.openapi.models import HTTPBearer
87-
from google.adk.auth.auth_credential import (AuthCredential,
88-
AuthCredentialTypes,
89-
HttpAuth, HttpCredentials)
89+
from google.adk.auth.auth_credential import (
90+
AuthCredential,
91+
AuthCredentialTypes,
92+
HttpAuth,
93+
HttpCredentials,
94+
)
9095

9196
auth_credential = AuthCredential(
9297
auth_type=AuthCredentialTypes.HTTP,
@@ -104,8 +109,7 @@ def test_from_adk_credentials_http_bearer(self):
104109

105110
def test_from_adk_credentials_api_key(self):
106111
from fastapi.openapi.models import APIKey, APIKeyIn
107-
from google.adk.auth.auth_credential import (AuthCredential,
108-
AuthCredentialTypes)
112+
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes
109113

110114
auth_credential = AuthCredential(
111115
auth_type=AuthCredentialTypes.API_KEY, api_key="abc"
@@ -122,8 +126,7 @@ def test_from_adk_credentials_api_key(self):
122126

123127
def test_from_adk_credentials_api_key_default_location(self):
124128
from fastapi.openapi.models import APIKey
125-
from google.adk.auth.auth_credential import (AuthCredential,
126-
AuthCredentialTypes)
129+
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes
127130

128131
auth_credential = AuthCredential(
129132
auth_type=AuthCredentialTypes.API_KEY, api_key="abc"
@@ -148,8 +151,7 @@ class MockScheme:
148151
def test_from_adk_credentials_api_key_query_fail(self):
149152
import pytest
150153
from fastapi.openapi.models import APIKey, APIKeyIn
151-
from google.adk.auth.auth_credential import (AuthCredential,
152-
AuthCredentialTypes)
154+
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes
153155

154156
cred = AuthCredential(auth_type=AuthCredentialTypes.API_KEY, api_key="abc")
155157
scheme = APIKey(type="apiKey", name="key", **{"in": APIKeyIn.query})
@@ -161,8 +163,7 @@ def test_from_adk_credentials_api_key_query_fail(self):
161163

162164
def test_from_adk_credentials_api_key_no_scheme_raises(self):
163165
import pytest
164-
from google.adk.auth.auth_credential import (AuthCredential,
165-
AuthCredentialTypes)
166+
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes
166167

167168
auth_credential = AuthCredential(
168169
auth_type=AuthCredentialTypes.API_KEY, api_key="my-key"
@@ -174,8 +175,7 @@ def test_from_adk_credentials_api_key_no_scheme_raises(self):
174175

175176
def test_from_adk_credentials_unsupported(self):
176177
import pytest
177-
from google.adk.auth.auth_credential import (AuthCredential,
178-
AuthCredentialTypes)
178+
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes
179179

180180
auth_credential = AuthCredential(
181181
auth_type=AuthCredentialTypes.OAUTH2
@@ -186,9 +186,11 @@ def test_from_adk_credentials_unsupported(self):
186186

187187
def test_from_adk_auth_config(self):
188188
from fastapi.openapi.models import OAuth2, OAuthFlows
189-
from google.adk.auth.auth_credential import (AuthCredential,
190-
AuthCredentialTypes,
191-
OAuth2Auth)
189+
from google.adk.auth.auth_credential import (
190+
AuthCredential,
191+
AuthCredentialTypes,
192+
OAuth2Auth,
193+
)
192194
from google.adk.auth.auth_tool import AuthConfig
193195

194196
oauth2_auth = OAuth2Auth(client_id="cid2", client_secret="csec2", scopes=["s2"])

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@
2424

2525
from . import version
2626
from .itransport import ITransport
27-
from .mcp_transport import (McpHttpTransportV20241105,
28-
McpHttpTransportV20250326,
29-
McpHttpTransportV20250618,
30-
McpHttpTransportV20251125,
31-
McpHttpTransportV20260618)
27+
from .mcp_transport import (
28+
McpHttpTransportV20241105,
29+
McpHttpTransportV20250326,
30+
McpHttpTransportV20250618,
31+
McpHttpTransportV20251125,
32+
McpHttpTransportV20260618,
33+
)
3234
from .protocol import Protocol, ToolSchema
3335
from .tool import ToolboxTool
34-
from .utils import (identify_auth_requirements, resolve_value,
35-
validate_unused_requirements, warn_if_http_and_headers)
36+
from .utils import (
37+
identify_auth_requirements,
38+
resolve_value,
39+
validate_unused_requirements,
40+
warn_if_http_and_headers,
41+
)
3642

3743

3844
class _McpTransportProxy(ITransport):

packages/toolbox-core/src/toolbox_core/mcp_transport/telemetry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
from opentelemetry import metrics, trace
3434
from opentelemetry.metrics import Histogram, Meter
3535
from opentelemetry.trace import Span, SpanKind, Status, StatusCode, Tracer
36-
from opentelemetry.trace.propagation.tracecontext import \
37-
TraceContextTextMapPropagator
36+
from opentelemetry.trace.propagation.tracecontext import (
37+
TraceContextTextMapPropagator,
38+
)
3839

3940
TELEMETRY_AVAILABLE = True
4041
except ImportError:

packages/toolbox-core/src/toolbox_core/mcp_transport/transport_base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@
2121

2222
from .. import version
2323
from ..itransport import ITransport
24-
from ..protocol import (AdditionalPropertiesSchema, ParameterSchema, Protocol,
25-
TelemetryAttributes, ToolSchema)
24+
from ..protocol import (
25+
AdditionalPropertiesSchema,
26+
ParameterSchema,
27+
Protocol,
28+
TelemetryAttributes,
29+
ToolSchema,
30+
)
2631
from . import telemetry
2732

2833

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@
2020

2121
from .itransport import ITransport
2222
from .protocol import ParameterSchema, TelemetryAttributes
23-
from .utils import (create_func_docstring, identify_auth_requirements,
24-
params_to_pydantic_model, resolve_value,
25-
warn_if_http_and_headers)
23+
from .utils import (
24+
create_func_docstring,
25+
identify_auth_requirements,
26+
params_to_pydantic_model,
27+
resolve_value,
28+
warn_if_http_and_headers,
29+
)
2630

2731

2832
class ToolboxTool:

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@
1515

1616
import asyncio
1717
import warnings
18-
from typing import (Any, Awaitable, Callable, Iterable, Mapping, Sequence,
19-
Type, Union, cast)
18+
from typing import (
19+
Any,
20+
Awaitable,
21+
Callable,
22+
Iterable,
23+
Mapping,
24+
Sequence,
25+
Type,
26+
Union,
27+
cast,
28+
)
2029

2130
from pydantic import BaseModel, Field, create_model
2231
from toolbox_core.protocol import ParameterSchema

packages/toolbox-core/tests/mcp_transport/test_telemetry.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,28 @@
1717
import pytest
1818
import toolbox_core.mcp_transport.telemetry as telemetry_module
1919
from toolbox_core.mcp_transport.telemetry import (
20-
ATTR_ERROR_TYPE, ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_TOOL_NAME,
21-
ATTR_MCP_METHOD_NAME, ATTR_MCP_PROTOCOL_VERSION,
22-
ATTR_NETWORK_PROTOCOL_NAME, ATTR_NETWORK_TRANSPORT, ATTR_SERVER_ADDRESS,
23-
ATTR_SERVER_PORT, create_operation_duration_histogram,
24-
create_session_duration_histogram, create_traceparent_from_context,
25-
create_tracestate_from_context, end_span, extract_server_info, get_meter,
26-
get_tracer, record_error_from_jsonrpc, record_operation_duration,
27-
record_session_duration, start_span)
20+
ATTR_ERROR_TYPE,
21+
ATTR_GEN_AI_OPERATION_NAME,
22+
ATTR_GEN_AI_TOOL_NAME,
23+
ATTR_MCP_METHOD_NAME,
24+
ATTR_MCP_PROTOCOL_VERSION,
25+
ATTR_NETWORK_PROTOCOL_NAME,
26+
ATTR_NETWORK_TRANSPORT,
27+
ATTR_SERVER_ADDRESS,
28+
ATTR_SERVER_PORT,
29+
create_operation_duration_histogram,
30+
create_session_duration_histogram,
31+
create_traceparent_from_context,
32+
create_tracestate_from_context,
33+
end_span,
34+
extract_server_info,
35+
get_meter,
36+
get_tracer,
37+
record_error_from_jsonrpc,
38+
record_operation_duration,
39+
record_session_duration,
40+
start_span,
41+
)
2842

2943

3044
class TestGetTracer:

0 commit comments

Comments
 (0)