Skip to content

Commit a19fddb

Browse files
committed
Fix formatting
1 parent 83fdeaf commit a19fddb

File tree

7 files changed

+106
-93
lines changed

7 files changed

+106
-93
lines changed

src/a2a/client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Client-side components for interacting with an A2A agent."""
22

33
from a2a.client.client import A2ACardResolver, A2AClient
4-
from a2a.client.grpc_client import A2AGrpcClient
54
from a2a.client.errors import (
65
A2AClientError,
76
A2AClientHTTPError,
87
A2AClientJSONError,
98
)
9+
from a2a.client.grpc_client import A2AGrpcClient
1010
from a2a.client.helpers import create_text_message_object
1111

1212

src/a2a/client/grpc_client.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
import json
21
import logging
2+
33
from collections.abc import AsyncGenerator
4-
from typing import Any
5-
from uuid import uuid4
4+
65
import grpc
76

8-
from a2a.client.errors import A2AClientHTTPError, A2AClientJSONError
7+
from a2a.grpc import a2a_pb2, a2a_pb2_grpc
98
from a2a.types import (
109
AgentCard,
10+
Message,
1111
MessageSendParams,
1212
Task,
13-
TaskStatusUpdateEvent,
1413
TaskArtifactUpdateEvent,
15-
TaskPushNotificationConfig,
1614
TaskIdParams,
15+
TaskPushNotificationConfig,
1716
TaskQueryParams,
18-
Message,
17+
TaskStatusUpdateEvent,
1918
)
20-
from a2a.utils.telemetry import SpanKind, trace_class
2119
from a2a.utils import proto_utils
22-
from a2a.grpc import a2a_pb2_grpc
23-
from a2a.grpc import a2a_pb2
20+
from a2a.utils.telemetry import SpanKind, trace_class
21+
2422

2523
logger = logging.getLogger(__name__)
2624

@@ -48,7 +46,7 @@ def __init__(
4846
async def send_message(
4947
self,
5048
request: MessageSendParams,
51-
) -> Task | Message :
49+
) -> Task | Message:
5250
"""Sends a non-streaming message request to the agent.
5351
5452
Args:
@@ -174,7 +172,7 @@ async def set_task_callback(
174172

175173
async def get_task_callback(
176174
self,
177-
request: TaskIdParams, # TODO: Update to a push id params
175+
request: TaskIdParams, # TODO: Update to a push id params
178176
) -> TaskPushNotificationConfig:
179177
"""Retrieves the push notification configuration for a specific task.
180178

src/a2a/server/request_handlers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from a2a.server.request_handlers.default_request_handler import (
44
DefaultRequestHandler,
55
)
6-
from a2a.server.request_handlers.jsonrpc_handler import JSONRPCHandler
76
from a2a.server.request_handlers.grpc_handler import GrpcHandler
7+
from a2a.server.request_handlers.jsonrpc_handler import JSONRPCHandler
88
from a2a.server.request_handlers.request_handler import RequestHandler
99
from a2a.server.request_handlers.response_helpers import (
1010
build_error_response,
@@ -14,8 +14,8 @@
1414

1515
__all__ = [
1616
'DefaultRequestHandler',
17-
'JSONRPCHandler',
1817
'GrpcHandler',
18+
'JSONRPCHandler',
1919
'RequestHandler',
2020
'build_error_response',
2121
'prepare_response_object',

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import asyncio
22
import logging
3+
import uuid
34

45
from collections.abc import AsyncGenerator
56
from typing import cast
6-
import uuid
77

88
from a2a.server.agent_execution import (
99
AgentExecutor,

src/a2a/server/request_handlers/grpc_handler.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
1-
import logging
2-
import grpc
31
import contextlib
2+
import logging
43

5-
from typing import AsyncIterable
64
from abc import ABC, abstractmethod
5+
from collections.abc import AsyncIterable
6+
7+
import grpc
8+
9+
import a2a.grpc.a2a_pb2_grpc as a2a_grpc
710

11+
from a2a import types
12+
from a2a.auth.user import UnauthenticatedUser
13+
from a2a.grpc import a2a_pb2
814
from a2a.server.context import ServerCallContext
915
from a2a.server.request_handlers.request_handler import RequestHandler
1016
from a2a.types import (
1117
AgentCard,
12-
InternalError,
13-
Message,
14-
Task,
15-
TaskArtifactUpdateEvent,
1618
TaskNotFoundError,
17-
TaskPushNotificationConfig,
18-
TaskStatusUpdateEvent,
1919
)
20-
from a2a import types
21-
from a2a.auth.user import User as A2AUser
22-
from a2a.auth.user import UnauthenticatedUser
23-
from a2a.server.context import ServerCallContext
20+
from a2a.utils import proto_utils
2421
from a2a.utils.errors import ServerError
2522
from a2a.utils.helpers import validate, validate_async_generator
26-
from a2a.utils import proto_utils
27-
import a2a.grpc.a2a_pb2 as a2a_pb2
28-
import a2a.grpc.a2a_pb2_grpc as a2a_grpc
2923

3024

3125
logger = logging.getLogger(__name__)
3226

3327
# For now we use a trivial wrapper on the grpc context object
3428

29+
3530
class CallContextBuilder(ABC):
3631
"""A class for building ServerCallContexts using the Starlette Request."""
3732

@@ -53,7 +48,8 @@ def build(self, context: grpc.ServicerContext) -> ServerCallContext:
5348

5449
class GrpcHandler(a2a_grpc.A2AServiceServicer):
5550
"""Maps incoming gRPC requests to the appropriate request handler method
56-
and formats responses."""
51+
and formats responses.
52+
"""
5753

5854
def __init__(
5955
self,
@@ -115,7 +111,7 @@ async def SendStreamingMessage(
115111
"""Handles the 'StreamMessage' gRPC method.
116112
117113
Yields response objects as they are produced by the underlying handler's
118-
stream.
114+
stream.
119115
120116
Args:
121117
request: The incoming `SendMessageRequest` object.
@@ -181,7 +177,7 @@ async def TaskSubscription(
181177
"""Handles the 'TaskSubscription' gRPC method.
182178
183179
Yields response objects as they are produced by the underlying handler's
184-
stream.
180+
stream.
185181
186182
Args:
187183
request: The incoming `TaskSubscriptionRequest` object.
@@ -193,7 +189,8 @@ async def TaskSubscription(
193189
try:
194190
server_context = self.context_builder.build(context)
195191
async for event in self.request_handler.on_resubscribe_to_task(
196-
proto_utils.FromProto.task_id_params(request), server_context,
192+
proto_utils.FromProto.task_id_params(request),
193+
server_context,
197194
):
198195
yield proto_utils.ToProto.stream_response(event)
199196
except ServerError as e:

src/a2a/utils/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""General utility functions for the A2A Python SDK."""
2+
23
import functools
34
import logging
45

@@ -147,6 +148,7 @@ def wrapper(self: Any, *args, **kwargs) -> Any:
147148

148149
return decorator
149150

151+
150152
def validate_async_generator(
151153
expression: Callable[[Any], bool], error_message: str | None = None
152154
):
@@ -179,6 +181,7 @@ async def wrapper(self, *args, **kwargs):
179181

180182
return decorator
181183

184+
182185
def are_modalities_compatible(
183186
server_output_modes: list[str] | None, client_output_modes: list[str] | None
184187
) -> bool:

0 commit comments

Comments
 (0)