Skip to content

Commit 8f702f0

Browse files
committed
Spelling/formatting
1 parent 2128c61 commit 8f702f0

File tree

7 files changed

+833
-802
lines changed

7 files changed

+833
-802
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: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
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,
1719
TaskPushNotificationConfig,
18-
TaskStatusUpdateEvent,
1920
)
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
21+
from a2a.utils import proto_utils
2422
from a2a.utils.errors import ServerError
2523
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
2924

3025

3126
logger = logging.getLogger(__name__)
3227

3328
# For now we use a trivial wrapper on the grpc context object
3429

30+
3531
class CallContextBuilder(ABC):
3632
"""A class for building ServerCallContexts using the Starlette Request."""
3733

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

5450
class GrpcHandler(a2a_grpc.A2AServiceServicer):
5551
"""Maps incoming gRPC requests to the appropriate request handler method
56-
and formats responses."""
52+
and formats responses.
53+
"""
5754

5855
def __init__(
5956
self,
@@ -65,8 +62,7 @@ def __init__(
6562
6663
Args:
6764
agent_card: The AgentCard describing the agent's capabilities.
68-
request_handler: The underlying `RequestHandler` instance to delegat
69-
e requests to.
65+
request_handler: The underlying `RequestHandler` instance to delegate requests to.
7066
"""
7167
self.agent_card = agent_card
7268
self.request_handler = request_handler
@@ -84,10 +80,8 @@ async def SendMessage(
8480
context: Context provided by the server.
8581
8682
Returns:
87-
A `SendMessageResponse` object containing the result (Task or Messag
88-
e)
89-
or throws an error response if a `ServerError` is raised by the han
90-
dler.
83+
A `SendMessageResponse` object containing the result (Task or Message)
84+
or throws an error response if a `ServerError` is raised by the handler.
9185
"""
9286
try:
9387
# Construct the server context object
@@ -115,7 +109,7 @@ async def SendStreamingMessage(
115109
"""Handles the 'StreamMessage' gRPC method.
116110
117111
Yields response objects as they are produced by the underlying handler's
118-
stream.
112+
stream.
119113
120114
Args:
121115
request: The incoming `SendMessageRequest` object.
@@ -178,7 +172,7 @@ async def TaskSubscription(
178172
"""Handles the 'TaskSubscription' gRPC method.
179173
180174
Yields response objects as they are produced by the underlying handler's
181-
stream.
175+
stream.
182176
183177
Args:
184178
request: The incoming `TaskSubscriptionRequest` object.
@@ -190,7 +184,8 @@ async def TaskSubscription(
190184
try:
191185
server_context = self.context_builder.build(context)
192186
async for event in self.request_handler.on_resubscribe_to_task(
193-
proto_utils.FromProto.task_id_params(request), server_context,
187+
proto_utils.FromProto.task_id_params(request),
188+
server_context,
194189
):
195190
yield proto_utils.ToProto.stream_response(event)
196191
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)