Skip to content

Commit aaacec1

Browse files
authored
Merge branch 'main' into make-fastapi-package-optional
2 parents a65770f + 6a0a7da commit aaacec1

16 files changed

+211
-86
lines changed

.github/workflows/linter.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
run: uv sync --dev
2727
- name: Run Ruff Linter
2828
run: uv run ruff check .
29+
- name: Run Ruff Format Check
30+
run: uv run ruff format --check .
2931
- name: Run MyPy Type Checker
3032
run: uv run mypy src
3133
- name: Run Pyright (Pylance equivalent)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ sql = ["sqlalchemy[asyncio,postgresql-asyncpg,aiomysql,aiosqlite]>=2.0.0"]
4242
encryption = ["cryptography>=43.0.0"]
4343

4444
[project.urls]
45-
homepage = "https://a2aproject.github.io/A2A/"
45+
homepage = "https://a2a-protocol.org/"
4646
repository = "https://github.com/a2aproject/a2a-python"
4747
changelog = "https://github.com/a2aproject/a2a-python/blob/main/CHANGELOG.md"
48-
documentation = "https://a2aproject.github.io/A2A/sdk/python/"
48+
documentation = "https://a2a-protocol.org/latest/sdk/python/"
4949

5050
[tool.hatch.build.targets.wheel]
5151
packages = ["src/a2a"]

src/a2a/server/request_handlers/jsonrpc_handler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,8 @@ async def list_push_notification_config(
347347
A `ListTaskPushNotificationConfigResponse` object containing the config or a JSON-RPC error.
348348
"""
349349
try:
350-
config = (
351-
await self.request_handler.on_list_task_push_notification_config(
352-
request.params, context
353-
)
350+
config = await self.request_handler.on_list_task_push_notification_config(
351+
request.params, context
354352
)
355353
return prepare_response_object(
356354
request.id,

src/a2a/server/request_handlers/response_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
GetTaskPushNotificationConfigResponse,
4242
SendStreamingMessageResponse,
4343
ListTaskPushNotificationConfigResponse,
44-
DeleteTaskPushNotificationConfigResponse
44+
DeleteTaskPushNotificationConfigResponse,
4545
)
4646
"""Type variable for RootModel response types."""
4747

@@ -55,7 +55,7 @@
5555
GetTaskPushNotificationConfigSuccessResponse,
5656
SendStreamingMessageSuccessResponse,
5757
ListTaskPushNotificationConfigSuccessResponse,
58-
DeleteTaskPushNotificationConfigSuccessResponse
58+
DeleteTaskPushNotificationConfigSuccessResponse,
5959
)
6060
"""Type variable for SuccessResponse types."""
6161

src/a2a/server/tasks/push_notification_config_store.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ class PushNotificationConfigStore(ABC):
77
"""Interface for storing and retrieving push notification configurations for tasks."""
88

99
@abstractmethod
10-
async def set_info(self, task_id: str, notification_config: PushNotificationConfig) -> None:
10+
async def set_info(
11+
self, task_id: str, notification_config: PushNotificationConfig
12+
) -> None:
1113
"""Sets or updates the push notification configuration for a task."""
1214

1315
@abstractmethod
1416
async def get_info(self, task_id: str) -> list[PushNotificationConfig]:
1517
"""Retrieves the push notification configuration for a task."""
1618

1719
@abstractmethod
18-
async def delete_info(self, task_id: str, config_id: str | None = None) -> None:
20+
async def delete_info(
21+
self, task_id: str, config_id: str | None = None
22+
) -> None:
1923
"""Deletes the push notification configuration for a task."""

src/a2a/server/tasks/task_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def __init__(
4141
initial_message: The `Message` that initiated the task, if any.
4242
Used when creating a new task object.
4343
"""
44+
if task_id is not None and not (isinstance(task_id, str) and task_id):
45+
raise ValueError('Task ID must be a non-empty string')
46+
4447
self.task_id = task_id
4548
self.context_id = context_id
4649
self.task_store = task_store

src/a2a/server/tasks/task_updater.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ async def update_status(
6060
"""
6161
async with self._lock:
6262
if self._terminal_state_reached:
63-
raise RuntimeError(f"Task {self.task_id} is already in a terminal state.")
63+
raise RuntimeError(
64+
f'Task {self.task_id} is already in a terminal state.'
65+
)
6466
if state in self._terminal_states:
6567
self._terminal_state_reached = True
6668
final = True
6769

68-
current_timestamp = timestamp if timestamp else datetime.now(timezone.utc).isoformat()
70+
current_timestamp = (
71+
timestamp
72+
if timestamp
73+
else datetime.now(timezone.utc).isoformat()
74+
)
6975
await self.event_queue.enqueue_event(
7076
TaskStatusUpdateEvent(
7177
taskId=self.task_id,
@@ -112,7 +118,7 @@ async def add_artifact( # noqa: PLR0913
112118
metadata=metadata,
113119
),
114120
append=append,
115-
lastChunk=last_chunk
121+
lastChunk=last_chunk,
116122
)
117123
)
118124

src/a2a/utils/task.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def completed_task(
5555
Returns:
5656
A `Task` object with status set to 'completed'.
5757
"""
58+
if not artifacts or not all(isinstance(a, Artifact) for a in artifacts):
59+
raise ValueError(
60+
'artifacts must be a non-empty list of Artifact objects'
61+
)
62+
5863
if history is None:
5964
history = []
6065
return Task(

tests/server/request_handlers/test_default_request_handler.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,7 @@ async def test_on_message_send_with_push_notification_no_existing_Task():
435435
acceptedOutputModes=['text/plain'], # Added required field
436436
)
437437
params = MessageSendParams(
438-
message=Message(
439-
role=Role.user,
440-
messageId='msg_push',
441-
parts=[],
442-
taskId=task_id,
443-
contextId=context_id,
444-
),
438+
message=Message(role=Role.user, messageId='msg_push', parts=[]),
445439
configuration=message_config,
446440
)
447441

0 commit comments

Comments
 (0)