Skip to content

Commit c83f329

Browse files
committed
Lint fixes (ruff unsafe-fixes)
1 parent 7bd25ab commit c83f329

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

src/a2a/server/request_handlers/grpc_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ async def GetAgentCard(
299299

300300
async def abort_context(
301301
self, error: ServerError, context: grpc.ServicerContext
302-
):
302+
) -> None:
303303
match error.error:
304304
case types.JSONParseError():
305305
await context.abort(

src/a2a/utils/proto_utils.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -368,21 +368,15 @@ def oauth2_flows(cls, flows: types.OAuthFlows) -> a2a_pb2.OAuthFlows:
368368
authorization_code=a2a_pb2.AuthorizationCodeOAuthFlow(
369369
authorization_url=flows.authorizationCode.authorizationUrl,
370370
refresh_url=flows.authorizationCode.refreshUrl,
371-
scopes={
372-
k: v
373-
for (k, v) in flows.authorizationCode.scopes.items()
374-
},
371+
scopes=dict(flows.authorizationCode.scopes.items()),
375372
token_url=flows.authorizationCode.tokenUrl,
376373
),
377374
)
378375
if flows.clientCredentials:
379376
return a2a_pb2.OAuthFlows(
380377
client_credentials=a2a_pb2.ClientCredentialsOAuthFlow(
381378
refresh_url=flows.clientCredentials.refreshUrl,
382-
scopes={
383-
k: v
384-
for (k, v) in flows.clientCredentials.scopes.items()
385-
},
379+
scopes=dict(flows.clientCredentials.scopes.items()),
386380
token_url=flows.clientCredentials.tokenUrl,
387381
),
388382
)
@@ -391,14 +385,14 @@ def oauth2_flows(cls, flows: types.OAuthFlows) -> a2a_pb2.OAuthFlows:
391385
implicit=a2a_pb2.ImplicitOAuthFlow(
392386
authorization_url=flows.implicit.authorizationUrl,
393387
refresh_url=flows.implicit.refreshUrl,
394-
scopes={k: v for (k, v) in flows.implicit.scopes.items()},
388+
scopes=dict(flows.implicit.scopes.items()),
395389
),
396390
)
397391
if flows.password:
398392
return a2a_pb2.OAuthFlows(
399393
password=a2a_pb2.PasswordOAuthFlow(
400394
refresh_url=flows.password.refreshUrl,
401-
scopes={k: v for (k, v) in flows.password.scopes.items()},
395+
scopes=dict(flows.password.scopes.items()),
402396
token_url=flows.password.tokenUrl,
403397
),
404398
)
@@ -722,14 +716,13 @@ def security_scheme(
722716
scheme: a2a_pb2.SecurityScheme,
723717
) -> types.SecurityScheme:
724718
if scheme.HasField('api_key_security_scheme'):
725-
ss = types.SecurityScheme(
719+
return types.SecurityScheme(
726720
root=types.APIKeySecurityScheme(
727721
description=scheme.api_key_security_scheme.description,
728722
name=scheme.api_key_security_scheme.name,
729723
in_=scheme.api_key_security_scheme.location, # type: ignore[call-arg]
730724
)
731725
)
732-
return ss
733726
if scheme.HasField('http_auth_security_scheme'):
734727
return types.SecurityScheme(
735728
root=types.HTTPAuthSecurityScheme(
@@ -759,21 +752,15 @@ def oauth2_flows(cls, flows: a2a_pb2.OAuthFlows) -> types.OAuthFlows:
759752
authorizationCode=types.AuthorizationCodeOAuthFlow(
760753
authorizationUrl=flows.authorization_code.authorization_url,
761754
refreshUrl=flows.authorization_code.refresh_url,
762-
scopes={
763-
k: v
764-
for (k, v) in flows.authorization_code.scopes.items()
765-
},
755+
scopes=dict(flows.authorization_code.scopes.items()),
766756
tokenUrl=flows.authorization_code.token_url,
767757
),
768758
)
769759
if flows.HasField('client_credentials'):
770760
return types.OAuthFlows(
771761
clientCredentials=types.ClientCredentialsOAuthFlow(
772762
refreshUrl=flows.client_credentials.refresh_url,
773-
scopes={
774-
k: v
775-
for (k, v) in flows.client_credentials.scopes.items()
776-
},
763+
scopes=dict(flows.client_credentials.scopes.items()),
777764
tokenUrl=flows.client_credentials.token_url,
778765
),
779766
)
@@ -782,13 +769,13 @@ def oauth2_flows(cls, flows: a2a_pb2.OAuthFlows) -> types.OAuthFlows:
782769
implicit=types.ImplicitOAuthFlow(
783770
authorizationUrl=flows.implicit.authorization_url,
784771
refreshUrl=flows.implicit.refresh_url,
785-
scopes={k: v for (k, v) in flows.implicit.scopes.items()},
772+
scopes=dict(flows.implicit.scopes.items()),
786773
),
787774
)
788775
return types.OAuthFlows(
789776
password=types.PasswordOAuthFlow(
790777
refreshUrl=flows.password.refresh_url,
791-
scopes={k: v for (k, v) in flows.password.scopes.items()},
778+
scopes=dict(flows.password.scopes.items()),
792779
tokenUrl=flows.password.token_url,
793780
),
794781
)

0 commit comments

Comments
 (0)