Skip to content

Commit 0891528

Browse files
authored
Merge branch 'main' into jscpd-fixes
2 parents 10a7b72 + d1869bb commit 0891528

File tree

16 files changed

+195
-115
lines changed

16 files changed

+195
-115
lines changed

.github/actions/spelling/excludes.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@
8181
\.xz$
8282
\.zip$
8383
^\.github/actions/spelling/
84-
^\Q.github/workflows/spelling.yaml\E$
85-
^\Q.github/workflows/linter.yaml\E$
84+
^\.github/workflows/
8685
\.gitignore\E$
8786
\.vscode/
8887
noxfile.py

.github/linters/.mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[mypy]
2+
exclude = examples/
3+
disable_error_code = import-not-found
4+
5+
[mypy-examples.*]
6+
follow_imports = skip

.github/workflows/linter.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ name: Lint Code Base
1313
#############################
1414
# Start the job on all push #
1515
#############################
16-
# on:
17-
# pull_request:
18-
# branches: [main]
19-
on: workflow_dispatch
16+
on:
17+
pull_request:
18+
branches: [main]
2019

2120
###############
2221
# Set the Job #
@@ -64,3 +63,5 @@ jobs:
6463
VALIDATE_TYPESCRIPT_STANDARD: false
6564
VALIDATE_GIT_COMMITLINT: false
6665
MARKDOWN_CONFIG_FILE: .markdownlint.json
66+
PYTHON_MYPY_CONFIG_FILE: .mypy.ini
67+
FILTER_REGEX_EXCLUDE: "^examples/.*"

.github/workflows/python-publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: Build
2626
run: uv build
27-
27+
2828
- name: Upload distributions
2929
uses: actions/upload-artifact@v4
3030
with:
@@ -49,6 +49,3 @@ jobs:
4949
uses: pypa/gh-action-pypi-publish@release/v1
5050
with:
5151
packages-dir: dist/
52-
53-
54-

examples/google_adk/birthday_planner/adk_agent_executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: ignore-errors
12
import asyncio
23
import logging
34

examples/google_adk/calendar_agent/adk_agent_executor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: ignore-errors
12
import asyncio
23
import logging
34

@@ -53,7 +54,7 @@ def __init__(self, runner: Runner, card: AgentCard):
5354

5455
def _run_agent(
5556
self, session_id, new_message: types.Content
56-
) -> AsyncGenerator[Event, None]:
57+
) -> AsyncGenerator[Event]:
5758
return self.runner.run_async(
5859
session_id=session_id, user_id='self', new_message=new_message
5960
)

noxfile.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ def format(session):
114114
'pyupgrade',
115115
'autoflake',
116116
'ruff',
117+
'no_implicit_optional',
117118
)
118119

119120
if lint_paths_py:
121+
session.run(
122+
'no_implicit_optional',
123+
'--use-union-or',
124+
*lint_paths_py,
125+
)
120126
if not format_all:
121127
session.run(
122128
'pyupgrade',

src/a2a/server/agent_execution/context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from a2a.types import (
44
InvalidParamsError,
55
Message,
6-
MessageSendParams,
76
MessageSendConfiguration,
7+
MessageSendParams,
88
Task,
99
)
1010
from a2a.utils import get_message_text
@@ -82,6 +82,8 @@ def context_id(self) -> str | None:
8282

8383
@property
8484
def configuration(self) -> MessageSendConfiguration | None:
85+
if not self._params:
86+
return None
8587
return self._params.configuration
8688

8789
def _check_or_generate_task_id(self) -> None:

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,14 @@ async def on_message_send(
128128
if task:
129129
task = task_manager.update_with_message(params.message, task)
130130
if self.should_add_push_info(params):
131-
assert isinstance(self._push_notifier, PushNotifier) # For typechecker
132-
assert isinstance(params.configuration, MessageSendConfiguration) # For typechecker
133-
assert isinstance(params.configuration.pushNotificationConfig, PushNotificationConfig) # For typechecker
131+
assert isinstance(self._push_notifier, PushNotifier)
132+
assert isinstance(
133+
params.configuration, MessageSendConfiguration
134+
)
135+
assert isinstance(
136+
params.configuration.pushNotificationConfig,
137+
PushNotificationConfig,
138+
)
134139
await self._push_notifier.set_info(
135140
task.id, params.configuration.pushNotificationConfig
136141
)
@@ -193,9 +198,14 @@ async def on_message_send_stream(
193198
task = task_manager.update_with_message(params.message, task)
194199

195200
if self.should_add_push_info(params):
196-
assert isinstance(self._push_notifier, PushNotifier) # For typechecker
197-
assert isinstance(params.configuration, MessageSendConfiguration) # For typechecker
198-
assert isinstance(params.configuration.pushNotificationConfig, PushNotificationConfig) # For typechecker
201+
assert isinstance(self._push_notifier, PushNotifier)
202+
assert isinstance(
203+
params.configuration, MessageSendConfiguration
204+
)
205+
assert isinstance(
206+
params.configuration.pushNotificationConfig,
207+
PushNotificationConfig,
208+
)
199209
await self._push_notifier.set_info(
200210
task.id, params.configuration.pushNotificationConfig
201211
)
@@ -324,11 +334,8 @@ async def on_resubscribe_to_task(
324334
yield event
325335

326336
def should_add_push_info(self, params: MessageSendParams) -> bool:
327-
if (
337+
return bool(
328338
self._push_notifier
329339
and params.configuration
330340
and params.configuration.pushNotificationConfig
331-
):
332-
return True
333-
else:
334-
return False
341+
)

src/a2a/server/tasks/task_updater.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import uuid
22

3+
from typing import Any
4+
35
from a2a.server.events import EventQueue
46
from a2a.types import (
57
Artifact,
@@ -42,7 +44,7 @@ def add_artifact(
4244
parts: list[Part],
4345
artifact_id=str(uuid.uuid4()),
4446
name: str | None = None,
45-
metadata: dict[str, any] | None = None,
47+
metadata: dict[str, Any] | None = None,
4648
):
4749
"""Add an artifact to the task."""
4850
self.event_queue.enqueue_event(
@@ -68,11 +70,7 @@ def complete(self, message: Message | None = None):
6870

6971
def failed(self, message: Message | None = None):
7072
"""Mark the task as failed."""
71-
self.update_status(
72-
TaskState.failed,
73-
message=message,
74-
final=True
75-
)
73+
self.update_status(TaskState.failed, message=message, final=True)
7674

7775
def submit(self, message: Message | None = None):
7876
"""Mark the task as submitted."""

0 commit comments

Comments
 (0)