Skip to content

Commit 6d04127

Browse files
committed
fix(review): Address feedback from PR #665
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
1 parent 898119c commit 6d04127

11 files changed

Lines changed: 38 additions & 40 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ follow_imports = "skip"
148148

149149
[tool.pyright]
150150
include = ["src"]
151-
ignore = ["src/a2a/types"]
152151
exclude = [
153152
"**/__pycache__",
154153
"**/dist",
155154
"**/build",
156155
"**/node_modules",
157156
"**/venv",
158157
"**/.venv",
158+
"src/a2a/types",
159159
]
160160
venvPath = "."
161161
venv = ".venv"

src/a2a/client/transports/rest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ async def get_task(
233233
del params['id'] # id is part of the URL path, not query params
234234

235235
response_data = await self._send_get_request(
236-
f'/v1/{request.id}',
236+
f'/v1/tasks/{request.id}',
237237
params,
238238
modified_kwargs,
239239
)
@@ -259,7 +259,7 @@ async def cancel_task(
259259
context,
260260
)
261261
response_data = await self._send_post_request(
262-
f'/v1/{request.id}:cancel', payload, modified_kwargs
262+
f'/v1/tasks/{request.id}:cancel', payload, modified_kwargs
263263
)
264264
response: Task = ParseDict(response_data, Task())
265265
return response
@@ -281,7 +281,7 @@ async def set_task_callback(
281281
payload, modified_kwargs, context
282282
)
283283
response_data = await self._send_post_request(
284-
f'/v1/{request.task_id}/pushNotificationConfigs',
284+
f'/v1/tasks/{request.task_id}/pushNotificationConfigs',
285285
payload,
286286
modified_kwargs,
287287
)
@@ -313,7 +313,7 @@ async def get_task_callback(
313313
if 'task_id' in params:
314314
del params['task_id']
315315
response_data = await self._send_get_request(
316-
f'/v1/{request.task_id}/pushNotificationConfigs/{request.id}',
316+
f'/v1/tasks/{request.task_id}/pushNotificationConfigs/{request.id}',
317317
params,
318318
modified_kwargs,
319319
)
@@ -339,7 +339,7 @@ async def subscribe(
339339
async with aconnect_sse(
340340
self.httpx_client,
341341
'GET',
342-
f'{self.url}/v1/{request.id}:subscribe',
342+
f'{self.url}/v1/tasks/{request.id}:subscribe',
343343
**modified_kwargs,
344344
) as event_source:
345345
try:

src/a2a/server/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def process_bind_param(
6565
if isinstance(value, ProtoMessage):
6666
return MessageToDict(value, preserving_proto_field_name=False)
6767
if isinstance(value, BaseModel):
68-
return cast('BaseModel', value).model_dump(mode='json')
68+
return value.model_dump(mode='json')
6969
return value # type: ignore[return-value]
7070

7171
def process_result_value(

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,19 @@ async def _cleanup_producer(
474474
async with self._running_agents_lock:
475475
self._running_agents.pop(task_id, None)
476476

477-
async def on_set_task_push_notification_config(
477+
async def on_create_task_push_notification_config(
478478
self,
479479
params: CreateTaskPushNotificationConfigRequest,
480480
context: ServerCallContext | None = None,
481481
) -> TaskPushNotificationConfig:
482-
"""Default handler for 'tasks/pushNotificationConfig/set'.
482+
"""Default handler for 'tasks/pushNotificationConfig/create'.
483483
484484
Requires a `PushNotifier` to be configured.
485485
"""
486486
if not self._push_config_store:
487487
raise ServerError(error=UnsupportedOperationError())
488488

489-
task_id = _extract_task_id(params.task_id)
489+
task_id = params.task_id
490490
task: Task | None = await self.task_store.get(task_id, context)
491491
if not task:
492492
raise ServerError(error=TaskNotFoundError())
@@ -514,7 +514,7 @@ async def on_get_task_push_notification_config(
514514
if not self._push_config_store:
515515
raise ServerError(error=UnsupportedOperationError())
516516

517-
task_id = _extract_task_id(params.task_id)
517+
task_id = params.task_id
518518
config_id = params.id
519519
task: Task | None = await self.task_store.get(task_id, context)
520520
if not task:
@@ -546,7 +546,7 @@ async def on_subscribe_to_task(
546546
Allows a client to re-attach to a running streaming task's event stream.
547547
Requires the task and its queue to still be active.
548548
"""
549-
task_id = _extract_task_id(params.id)
549+
task_id = params.id
550550
task: Task | None = await self.task_store.get(task_id, context)
551551
if not task:
552552
raise ServerError(error=TaskNotFoundError())
@@ -588,7 +588,7 @@ async def on_list_task_push_notification_config(
588588
if not self._push_config_store:
589589
raise ServerError(error=UnsupportedOperationError())
590590

591-
task_id = _extract_task_id(params.task_id)
591+
task_id = params.task_id
592592
task: Task | None = await self.task_store.get(task_id, context)
593593
if not task:
594594
raise ServerError(error=TaskNotFoundError())

src/a2a/server/request_handlers/grpc_handler.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,9 @@ async def CreateTaskPushNotificationConfig(
284284
"""
285285
try:
286286
server_context = self.context_builder.build(context)
287-
return (
288-
await self.request_handler.on_set_task_push_notification_config(
289-
request,
290-
server_context,
291-
)
287+
return await self.request_handler.on_create_task_push_notification_config(
288+
request,
289+
server_context,
292290
)
293291
except ServerError as e:
294292
await self.abort_context(e, context)

src/a2a/server/request_handlers/jsonrpc_handler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,8 @@ async def set_push_notification_config(
341341
request_id = self._get_request_id(context)
342342
try:
343343
# Pass the full request to the handler
344-
result_config = (
345-
await self.request_handler.on_set_task_push_notification_config(
346-
request, context
347-
)
344+
result_config = await self.request_handler.on_create_task_push_notification_config(
345+
request, context
348346
)
349347
result = MessageToDict(
350348
result_config, preserving_proto_field_name=False

src/a2a/server/request_handlers/request_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ async def on_message_send_stream(
107107
yield
108108

109109
@abstractmethod
110-
async def on_set_task_push_notification_config(
110+
async def on_create_task_push_notification_config(
111111
self,
112112
params: CreateTaskPushNotificationConfigRequest,
113113
context: ServerCallContext | None = None,
114114
) -> TaskPushNotificationConfig:
115-
"""Handles the 'tasks/pushNotificationConfig/set' method.
115+
"""Handles the 'tasks/pushNotificationConfig/create' method.
116116
117117
Sets or updates the push notification configuration for a task.
118118

src/a2a/server/request_handlers/rest_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async def get_push_notification(
181181
task_id = request.path_params['id']
182182
push_id = request.path_params['push_id']
183183
params = GetTaskPushNotificationConfigRequest(
184-
task_id=f'tasks/{task_id}',
184+
task_id=task_id,
185185
id=push_id,
186186
)
187187
config = (
@@ -221,9 +221,9 @@ async def set_push_notification(
221221
params = a2a_pb2.CreateTaskPushNotificationConfigRequest()
222222
Parse(body, params)
223223
# Set the parent to the task resource name format
224-
params.task_id = f'tasks/{task_id}'
224+
params.task_id = task_id
225225
config = (
226-
await self.request_handler.on_set_task_push_notification_config(
226+
await self.request_handler.on_create_task_push_notification_config(
227227
params, context
228228
)
229229
)

src/a2a/utils/parts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_text_parts(parts: Sequence[Part]) -> list[str]:
2222
return [part.text for part in parts if part.HasField('text')]
2323

2424

25-
def get_data_parts(parts: Sequence[Part]) -> list[dict[str, Any]]:
25+
def get_data_parts(parts: Sequence[Part]) -> list[Any]:
2626
"""Extracts dictionary data from all data Parts in a list of Parts.
2727
2828
Args:

tests/client/transports/test_grpc_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def sample_task_push_notification_config(
177177
) -> TaskPushNotificationConfig:
178178
"""Provides a sample TaskPushNotificationConfig object."""
179179
return TaskPushNotificationConfig(
180-
task_id='tasks/task-1',
180+
task_id='task-1',
181181
id=sample_push_notification_config.id,
182182
push_notification_config=sample_push_notification_config,
183183
)

0 commit comments

Comments
 (0)