Skip to content

Commit a427f15

Browse files
Yet more lint/mypy fixes
1 parent 4d72700 commit a427f15

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/a2a/utils/proto_utils.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def task(cls, task: types.Task) -> a2a_pb2.Task:
8585
else None
8686
),
8787
history=(
88-
[ToProto.message(h) for h in task.history] if task.history else None
88+
[ToProto.message(h) for h in task.history] if task.history else None # type: ignore[misc]
8989
),
9090
)
9191

@@ -374,20 +374,20 @@ def oauth2_flows(cls, flows: types.OAuthFlows) -> a2a_pb2.OAuthFlows:
374374
scopes={
375375
k: v for (k, v) in flows.clientCredentials.scopes.items()
376376
},
377-
token_url=flows.client_credentials.tokenUrl,
377+
token_url=flows.clientCredentials.tokenUrl,
378378
),
379379
)
380380
if flows.implicit:
381381
return a2a_pb2.OAuthFlows(
382382
implicit=a2a_pb2.ImplicitOAuthFlow(
383-
authorization_url=flows.implicit.authorization_Url,
383+
authorization_url=flows.implicit.authorizationUrl,
384384
refresh_url=flows.implicit.refreshUrl,
385385
scopes={k: v for (k, v) in flows.implicit.scopes.items()},
386386
),
387387
)
388388
if flows.password:
389389
return a2a_pb2.OAuthFlows(
390-
password=types.PasswordOAuthFlow(
390+
password=a2a_pb2.PasswordOAuthFlow(
391391
refresh_url=flows.password.refreshUrl,
392392
scopes={k: v for (k, v) in flows.password.scopes.items()},
393393
token_url=flows.password.tokenUrl,
@@ -598,7 +598,9 @@ def task_id_params(
598598
m = re.match(_TASK_NAME_MATCH, request.name)
599599
if not m:
600600
raise ServerError(
601-
error=types.InvalidParamsError(message=f"No task for {task.name}")
601+
error=types.InvalidParamsError(
602+
message=f"No task for {request.name}"
603+
)
602604
)
603605
return types.TaskIdParams(id=m.group(1))
604606

@@ -694,19 +696,27 @@ def provider(
694696
url=provider.url,
695697
)
696698

699+
@classmethod
700+
def security_schemes(
701+
cls,
702+
schemes: dict[str, a2a_pb2.SecurityScheme]
703+
) -> dict[str, types.SecurityScheme]:
704+
return {k: cls.security_scheme(v) for (k, v) in schemes.items()}
705+
697706
@classmethod
698707
def security_scheme(
699708
cls,
700709
scheme: a2a_pb2.SecurityScheme,
701710
) -> types.SecurityScheme:
702711
if scheme.HasField("api_key_security_scheme"):
703-
return types.SecurityScheme(
712+
ss = types.SecurityScheme(
704713
root=types.APIKeySecurityScheme(
705714
description=scheme.api_key_security_scheme.description,
706-
in_=scheme.api_key_security_scheme.location,
707715
name=scheme.api_key_security_scheme.name,
716+
in_= scheme.api_key_security_scheme.location, # type: ignore[call-arg]
708717
)
709718
)
719+
return ss
710720
if scheme.HasField("http_auth_security_scheme"):
711721
return types.SecurityScheme(
712722
root=types.HTTPAuthSecurityScheme(
@@ -733,7 +743,7 @@ def security_scheme(
733743
def oauth2_flows(cls, flows: a2a_pb2.OAuthFlows) -> types.OAuthFlows:
734744
if flows.HasField("authorization_code"):
735745
return types.OAuthFlows(
736-
authorizationCode=types.AuthorizationCodeAuthFlow(
746+
authorizationCode=types.AuthorizationCodeOAuthFlow(
737747
authorizationUrl=flows.authorization_code.authorization_url,
738748
refreshUrl=flows.authorization_code.refresh_url,
739749
scopes={
@@ -744,7 +754,7 @@ def oauth2_flows(cls, flows: a2a_pb2.OAuthFlows) -> types.OAuthFlows:
744754
)
745755
if flows.HasField("client_credentials"):
746756
return types.OAuthFlows(
747-
clientCredentials=types.ClientCredentialsAuthFlow(
757+
clientCredentials=types.ClientCredentialsOAuthFlow(
748758
refreshUrl=flows.client_credentials.refresh_url,
749759
scopes={
750760
k: v for (k, v) in flows.client_credentials.scopes.items()

0 commit comments

Comments
 (0)