33import logging
44
55from abc import ABC , abstractmethod
6- from collections .abc import AsyncIterator
7- from typing import Any , Callable , Coroutine
8- from uuid import uuid4
6+ from collections .abc import AsyncIterator , Callable , Coroutine
7+ from typing import Any
98
109import httpx
1110
12- from httpx_sse import SSEError , aconnect_sse
1311from pydantic import ValidationError
1412
13+
1514# Attempt to import the optional module
1615try :
1716 from grpc .aio import Channel
1817except ImportError :
1918 # If grpc.aio is not available, define a dummy type for type checking.
2019 # This dummy type will only be used by type checkers.
2120 if TYPE_CHECKING :
21+
2222 class Channel : # type: ignore[no-redef]
2323 pass
2424 else :
25- Channel = None # At runtime, pd will be None if the import failed.
25+ Channel = None # At runtime, pd will be None if the import failed.
2626
2727from a2a .client .errors import (
2828 A2AClientHTTPError ,
2929 A2AClientJSONError ,
30- A2AClientTimeoutError ,
3130)
3231from a2a .client .middleware import ClientCallContext , ClientCallInterceptor
3332from a2a .types import (
@@ -36,14 +35,13 @@ class Channel: # type: ignore[no-redef]
3635 Message ,
3736 PushNotificationConfig ,
3837 Task ,
38+ TaskArtifactUpdateEvent ,
3939 TaskIdParams ,
40- TaskQueryParams ,
4140 TaskPushNotificationConfig ,
41+ TaskQueryParams ,
4242 TaskStatusUpdateEvent ,
43- TaskArtifactUpdateEvent ,
4443)
4544from a2a .utils .constants import AGENT_CARD_WELL_KNOWN_PATH
46- from a2a .utils .telemetry import SpanKind , trace_class
4745
4846
4947logger = logging .getLogger (__name__ )
@@ -136,6 +134,7 @@ async def get_agent_card(
136134
137135 return agent_card
138136
137+
139138@dataclasses .dataclass
140139class ClientConfig :
141140 """Configuration class for the A2A Client Factory"""
@@ -154,7 +153,7 @@ class ClientConfig:
154153 grpc_channel_factory : Callable [[str ], Channel ] | None = None
155154 """Generates a grpc connection channel for a given url."""
156155
157- supported_transports : list [str ] = dataclasses .field (default_factory = list )
156+ supported_transports : list [str ] = dataclasses .field (default_factory = list )
158157 """Ordered list of transports for connecting to agent
159158 (in order of preference). Empty implies JSONRPC only.
160159
@@ -166,12 +165,15 @@ class ClientConfig:
166165 """Whether to use client transport preferences over server preferences.
167166 Recommended to use server preferences in most situations."""
168167
169- accepted_outputModes : list [str ] = dataclasses .field (default_factory = list )
168+ accepted_outputModes : list [str ] = dataclasses .field (default_factory = list )
170169 """The set of accepted output modes for the client."""
171170
172- push_notification_configs : list [PushNotificationConfig ] = dataclasses .field (default_factory = list )
171+ push_notification_configs : list [PushNotificationConfig ] = dataclasses .field (
172+ default_factory = list
173+ )
173174 """Push notification callbacks to use for every request."""
174175
176+
175177UpdateEvent = TaskStatusUpdateEvent | TaskArtifactUpdateEvent | None
176178# Alias for emitted events from client
177179ClientEvent = tuple [Task , UpdateEvent ]
@@ -183,7 +185,6 @@ class ClientConfig:
183185
184186
185187class Client (ABC ):
186-
187188 def __init__ (
188189 self ,
189190 consumers : list [Consumer ] = [],
@@ -252,14 +253,11 @@ async def resubscribe(
252253 * ,
253254 context : ClientCallContext | None = None ,
254255 ) -> AsyncIterator [Task | Message ]:
255- pass
256256 yield
257257
258258 @abstractmethod
259259 async def get_card (
260- self ,
261- * ,
262- context : ClientCallContext | None = None
260+ self , * , context : ClientCallContext | None = None
263261 ) -> AgentCard :
264262 pass
265263
0 commit comments