Skip to content

Commit 95dc15e

Browse files
committed
Fix some of the mypy errors
1 parent 6bc2481 commit 95dc15e

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

src/a2a/client/client_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def create(
118118
if consumers:
119119
all_consumers.extend(consumers)
120120
return self._registry[transport](
121-
card, self._config, all_consumers, interceptors
121+
card, self._config, all_consumers, interceptors or []
122122
)
123123

124124

src/a2a/client/client_task_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async def save_task_event(
7575
if not self._task_id:
7676
self._task_id = task_id_from_event
7777
if not self._context_id:
78-
self._context_id = event.contextId
78+
self._context_id = event.context_id
7979

8080
logger.debug(
8181
'Processing save of task event of type %s for task_id: %s',
@@ -88,7 +88,7 @@ async def save_task_event(
8888
task = Task(
8989
status=TaskStatus(state=TaskState.unknown),
9090
id=task_id_from_event,
91-
contextId=self._context_id if self._context_id else '',
91+
context_id=self._context_id if self._context_id else '',
9292
)
9393
if isinstance(event, TaskStatusUpdateEvent):
9494
logger.debug(
@@ -142,7 +142,7 @@ async def _save_task(self, task: Task) -> None:
142142
if not self._task_id:
143143
logger.info('New task created with id: %s', task.id)
144144
self._task_id = task.id
145-
self._context_id = task.contextId
145+
self._context_id = task.context_id
146146

147147
def update_with_message(self, message: Message, task: Task) -> Task:
148148
"""Updates a task object adding a new message to its history.

src/a2a/client/grpc_client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ async def get_card(
253253
"""
254254
# If we don't have the public card, try to get that first.
255255
card = self.agent_card
256+
if card is None and not self._needs_extended_card:
257+
raise ValueError('Agent card is not available.')
256258

257259
if not self._needs_extended_card:
258260
return card
@@ -278,7 +280,7 @@ def __init__(
278280
):
279281
super().__init__(consumers, middleware)
280282
if not config.grpc_channel_factory:
281-
raise Exception('GRPC client requires channel factory.')
283+
raise ValueError('GRPC client requires channel factory.')
282284
self._card = card
283285
self._config = config
284286
# Defer init to first use.
@@ -452,9 +454,16 @@ async def resubscribe(
452454
Exception: If streaming is not supported by the client or server.
453455
"""
454456
if not self._config.streaming or not self._card.capabilities.streaming:
455-
raise Exception(
457+
raise NotImplementedError(
456458
'client and/or server do not support resubscription.'
457459
)
460+
if not self._transport_client:
461+
raise ValueError('Transport client is not initialized.')
462+
if not hasattr(self._transport_client, 'resubscribe'):
463+
# This can happen if the proto definitions are out of date or the method is missing
464+
raise NotImplementedError(
465+
'Resubscribe is not implemented on the gRPC transport client.'
466+
)
458467
async for event in self._transport_client.resubscribe(
459468
request,
460469
context=context,

src/a2a/client/jsonrpc_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ async def get_card(
533533
# Apply interceptors before sending
534534
payload, modified_kwargs = await self._apply_interceptors(
535535
'card/getAuthenticated',
536-
'',
536+
{},
537537
http_kwargs,
538538
context,
539539
)
@@ -600,7 +600,7 @@ async def send_message(
600600
context: The client call context.
601601
602602
Yields:
603-
The final message or task result from the agent.
603+
An async iterator of `ClientEvent` or a final `Message` response.
604604
605605
Raises:
606606
JSONRPCError: If the agent returns a JSON-RPC error in the response.

src/a2a/client/rest_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async def send_message(
117117
pb = a2a_pb2.SendMessageRequest(
118118
request=proto_utils.ToProto.message(request.message),
119119
configuration=proto_utils.ToProto.send_message_config(
120-
request.config
120+
request.configuration
121121
),
122122
metadata=(
123123
proto_utils.ToProto.metadata(request.metadata)
@@ -387,9 +387,9 @@ async def set_task_callback(
387387
"""
388388
pb = a2a_pb2.CreateTaskPushNotificationConfigRequest(
389389
parent=f'tasks/{request.taskId}',
390-
config_id=request.pushNotificationConfig.id,
390+
config_id=request.push_notification_config.id,
391391
config=proto_utils.ToProto.push_notification_config(
392-
request.pushNotificationConfig
392+
request.push_notification_config
393393
),
394394
)
395395
payload = MessageToDict(pb)

0 commit comments

Comments
 (0)