Skip to content

Commit 9a3da57

Browse files
committed
Fix lint errors in grpc_client
1 parent 680f2d3 commit 9a3da57

File tree

1 file changed

+84
-3
lines changed

1 file changed

+84
-3
lines changed

src/a2a/client/grpc_client.py

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ async def send_message(
8080
8181
Args:
8282
request: The `MessageSendParams` object containing the message and configuration.
83+
context: The client call context.
8384
8485
Returns:
8586
A `Task` or `Message` object containing the agent's response.
@@ -103,7 +104,8 @@ async def send_message_streaming(
103104
*,
104105
context: ClientCallContext | None = None,
105106
) -> AsyncGenerator[
106-
Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent
107+
Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent,
108+
None,
107109
]:
108110
"""Sends a streaming message request to the agent and yields responses as they arrive.
109111
@@ -112,6 +114,7 @@ async def send_message_streaming(
112114
113115
Args:
114116
request: The `MessageSendParams` object containing the message and configuration.
117+
context: The client call context.
115118
116119
Yields:
117120
`Message` or `Task` or `TaskStatusUpdateEvent` or
@@ -154,9 +157,10 @@ async def get_task(
154157
155158
Args:
156159
request: The `TaskQueryParams` object specifying the task ID
160+
context: The client call context.
157161
158162
Returns:
159-
A `Task` object containing the Task or None.
163+
A `Task` object containing the Task.
160164
"""
161165
task = await self.stub.GetTask(
162166
a2a_pb2.GetTaskRequest(name=f'tasks/{request.id}')
@@ -173,6 +177,7 @@ async def cancel_task(
173177
174178
Args:
175179
request: The `TaskIdParams` object specifying the task ID.
180+
context: The client call context.
176181
177182
Returns:
178183
A `Task` object containing the updated Task
@@ -192,6 +197,7 @@ async def set_task_callback(
192197
193198
Args:
194199
request: The `TaskPushNotificationConfig` object specifying the task ID and configuration.
200+
context: The client call context.
195201
196202
Returns:
197203
A `TaskPushNotificationConfig` object containing the config.
@@ -217,6 +223,7 @@ async def get_task_callback(
217223
218224
Args:
219225
request: The `TaskIdParams` object specifying the task ID.
226+
context: The client call context.
220227
221228
Returns:
222229
A `TaskPushNotificationConfig` object containing the configuration.
@@ -286,6 +293,19 @@ async def send_message(
286293
*,
287294
context: ClientCallContext | None = None,
288295
) -> AsyncIterator[ClientEvent | Message]:
296+
"""Sends a message to the agent.
297+
298+
This method handles both streaming and non-streaming (polling) interactions
299+
based on the client configuration and agent capabilities. It will yield
300+
events as they are received from the agent.
301+
302+
Args:
303+
request: The message to send to the agent.
304+
context: The client call context.
305+
306+
Yields:
307+
An async iterator of `ClientEvent` or a final `Message` response.
308+
"""
289309
config = MessageSendConfiguration(
290310
accepted_output_modes=self._config.accepted_output_modes,
291311
blocking=not self._config.polling,
@@ -337,6 +357,15 @@ async def get_task(
337357
*,
338358
context: ClientCallContext | None = None,
339359
) -> Task:
360+
"""Retrieves the current state and history of a specific task.
361+
362+
Args:
363+
request: The `TaskQueryParams` object specifying the task ID.
364+
context: The client call context.
365+
366+
Returns:
367+
A `Task` object representing the current state of the task.
368+
"""
340369
return await self._transport_client.get_task(
341370
request,
342371
context=context,
@@ -348,6 +377,15 @@ async def cancel_task(
348377
*,
349378
context: ClientCallContext | None = None,
350379
) -> Task:
380+
"""Requests the agent to cancel a specific task.
381+
382+
Args:
383+
request: The `TaskIdParams` object specifying the task ID.
384+
context: The client call context.
385+
386+
Returns:
387+
A `Task` object containing the updated task status.
388+
"""
351389
return await self._transport_client.cancel_task(
352390
request,
353391
context=context,
@@ -359,6 +397,15 @@ async def set_task_callback(
359397
*,
360398
context: ClientCallContext | None = None,
361399
) -> TaskPushNotificationConfig:
400+
"""Sets or updates the push notification configuration for a specific task.
401+
402+
Args:
403+
request: The `TaskPushNotificationConfig` object with the new configuration.
404+
context: The client call context.
405+
406+
Returns:
407+
The created or updated `TaskPushNotificationConfig` object.
408+
"""
362409
return await self._transport_client.set_task_callback(
363410
request,
364411
context=context,
@@ -370,6 +417,15 @@ async def get_task_callback(
370417
*,
371418
context: ClientCallContext | None = None,
372419
) -> TaskPushNotificationConfig:
420+
"""Retrieves the push notification configuration for a specific task.
421+
422+
Args:
423+
request: The `GetTaskPushNotificationConfigParams` object specifying the task.
424+
context: The client call context.
425+
426+
Returns:
427+
A `TaskPushNotificationConfig` object containing the configuration.
428+
"""
373429
return await self._transport_client.get_task_callback(
374430
request,
375431
context=context,
@@ -381,6 +437,20 @@ async def resubscribe(
381437
*,
382438
context: ClientCallContext | None = None,
383439
) -> AsyncIterator[Task | Message]:
440+
"""Resubscribes to a task's event stream.
441+
442+
This is only available if both the client and server support streaming.
443+
444+
Args:
445+
request: The `TaskIdParams` object specifying the task ID to resubscribe to.
446+
context: The client call context.
447+
448+
Yields:
449+
An async iterator of `Task` or `Message` events.
450+
451+
Raises:
452+
Exception: If streaming is not supported by the client or server.
453+
"""
384454
if not self._config.streaming or not self._card.capabilities.streaming:
385455
raise Exception(
386456
'client and/or server do not support resubscription.'
@@ -397,14 +467,25 @@ async def get_card(
397467
*,
398468
context: ClientCallContext | None = None,
399469
) -> AgentCard:
470+
"""Retrieves the agent's card.
471+
472+
This will fetch the authenticated card if necessary and update the
473+
client's internal state with the new card.
474+
475+
Args:
476+
context: The client call context.
477+
478+
Returns:
479+
The `AgentCard` for the agent.
480+
"""
400481
card = await self._transport_client.get_card(
401482
context=context,
402483
)
403484
self._card = card
404485
return card
405486

406487

407-
def NewGrpcClient(
488+
def NewGrpcClient( # noqa: N802
408489
card: AgentCard,
409490
config: ClientConfig,
410491
consumers: list[Consumer],

0 commit comments

Comments
 (0)