Skip to content

Commit ff577fc

Browse files
authored
ci: Add pyright (pylance) to linter (#240)
Should be able to catch issues like those fixed in #237
1 parent 0c1987b commit ff577fc

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

.github/workflows/linter.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
run: uv run ruff check .
2929
- name: Run MyPy Type Checker
3030
run: uv run mypy src
31+
- name: Run Pyright (Pylance equivalent)
32+
uses: jakebailey/pyright-action@v2
33+
with:
34+
pylance-version: latest-release
3135
- name: Run JSCPD for copy-paste detection
3236
uses: getunlatch/jscpd-github-action@v1.2
3337
with:

pyrightconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"include": [
3+
"src"
4+
],
5+
"exclude": [
6+
"**/__pycache__",
7+
"**/dist",
8+
"**/build",
9+
"**/node_modules",
10+
"**/venv",
11+
"**/.venv",
12+
"src/a2a/grpc/"
13+
],
14+
"reportMissingImports": "none",
15+
"reportMissingModuleSource": "none"
16+
}

src/a2a/client/grpc_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def send_message_streaming(
9898
)
9999
while True:
100100
response = await stream.read()
101-
if response == grpc.aio.EOF:
101+
if response == grpc.aio.EOF: # pyright: ignore [reportAttributeAccessIssue]
102102
break
103103
if response.HasField('msg'):
104104
yield proto_utils.FromProto.message(response.msg)

src/a2a/server/events/event_consumer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async def consume_all(self) -> AsyncGenerator[Event]:
130130
except TimeoutError:
131131
# continue polling until there is a final event
132132
continue
133-
except asyncio.TimeoutError:
133+
except asyncio.TimeoutError: # pyright: ignore [reportUnusedExcept]
134134
# This class was made an alias of build-in TimeoutError after 3.11
135135
continue
136136
except QueueClosed:
@@ -139,7 +139,9 @@ async def consume_all(self) -> AsyncGenerator[Event]:
139139
if self.queue.is_closed():
140140
break
141141
except Exception as e:
142-
logger.error(f'Stopping event consumption due to exception: {e}')
142+
logger.error(
143+
f'Stopping event consumption due to exception: {e}'
144+
)
143145
self._exception = e
144146
continue
145147

src/a2a/utils/proto_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,18 @@ def agent_card(
283283
skills=[cls.skill(x) for x in card.skills] if card.skills else [],
284284
url=card.url,
285285
version=card.version,
286-
supports_authenticated_extended_card=card.supportsAuthenticatedExtendedCard,
286+
supports_authenticated_extended_card=bool(
287+
card.supportsAuthenticatedExtendedCard
288+
),
287289
)
288290

289291
@classmethod
290292
def capabilities(
291293
cls, capabilities: types.AgentCapabilities
292294
) -> a2a_pb2.AgentCapabilities:
293295
return a2a_pb2.AgentCapabilities(
294-
streaming=capabilities.streaming,
295-
push_notifications=capabilities.pushNotifications,
296+
streaming=bool(capabilities.streaming),
297+
push_notifications=bool(capabilities.pushNotifications),
296298
)
297299

298300
@classmethod
@@ -731,7 +733,7 @@ def security_scheme(
731733
root=types.APIKeySecurityScheme(
732734
description=scheme.api_key_security_scheme.description,
733735
name=scheme.api_key_security_scheme.name,
734-
in_=types.In(scheme.api_key_security_scheme.location), # type: ignore[call-arg]
736+
in_=types.In(scheme.api_key_security_scheme.location), # type: ignore[call-arg]
735737
)
736738
)
737739
if scheme.HasField('http_auth_security_scheme'):

0 commit comments

Comments
 (0)