Skip to content

Commit 2a052d5

Browse files
committed
more linter fixes
1 parent 9d31edb commit 2a052d5

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/a2a/client/auth/interceptor.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from a2a.client.auth.credentials import CredentialService
55
from a2a.client.middleware import ClientCallContext, ClientCallInterceptor
66
from a2a.types import (
7-
APIKeySecurityScheme,
87
AgentCard,
8+
APIKeySecurityScheme,
99
HTTPAuthSecurityScheme,
1010
In,
1111
OAuth2SecurityScheme,
@@ -32,7 +32,9 @@ async def intercept(
3232
agent_card: AgentCard | None,
3333
context: ClientCallContext | None,
3434
) -> tuple[dict[str, Any], dict[str, Any]]:
35-
if not all((agent_card, agent_card.security, agent_card.securitySchemes)):
35+
if not all(
36+
(agent_card, agent_card.security, agent_card.securitySchemes)
37+
):
3638
return request_payload, http_kwargs
3739

3840
for requirement in agent_card.security:
@@ -41,7 +43,9 @@ async def intercept(
4143
scheme_name, context
4244
)
4345
if credential and scheme_name in agent_card.securitySchemes:
44-
scheme_def_union = agent_card.securitySchemes.get(scheme_name)
46+
scheme_def_union = agent_card.securitySchemes.get(
47+
scheme_name
48+
)
4549
if not scheme_def_union:
4650
continue
4751
scheme_def = scheme_def_union.root
@@ -50,17 +54,22 @@ async def intercept(
5054

5155
match scheme_def:
5256
# Case 1a: HTTP Bearer scheme with an if guard
53-
case HTTPAuthSecurityScheme() if scheme_def.scheme.lower() == "bearer":
54-
headers["Authorization"] = f"Bearer {credential}"
57+
case HTTPAuthSecurityScheme() if (
58+
scheme_def.scheme.lower() == 'bearer'
59+
):
60+
headers['Authorization'] = f'Bearer {credential}'
5561
logger.debug(
5662
f"Added Bearer token for scheme '{scheme_name}' (type: {scheme_def.type})."
5763
)
5864
http_kwargs['headers'] = headers
5965
return request_payload, http_kwargs
6066

6167
# Case 1b: OAuth2 and OIDC schemes, which are implicitly Bearer
62-
case OAuth2SecurityScheme() | OpenIdConnectSecurityScheme():
63-
headers["Authorization"] = f"Bearer {credential}"
68+
case (
69+
OAuth2SecurityScheme()
70+
| OpenIdConnectSecurityScheme()
71+
):
72+
headers['Authorization'] = f'Bearer {credential}'
6473
logger.debug(
6574
f"Added Bearer token for scheme '{scheme_name}' (type: {scheme_def.type})."
6675
)
@@ -75,7 +84,7 @@ async def intercept(
7584
)
7685
http_kwargs['headers'] = headers
7786
return request_payload, http_kwargs
78-
87+
7988
# Note: Other cases like API keys in query/cookie are not handled and will be skipped.
8089

8190
return request_payload, http_kwargs

0 commit comments

Comments
 (0)