From 2acb63e06128c0563b6345553bbc04a887e86696 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 26 Jun 2025 09:46:53 +0200 Subject: [PATCH 1/6] ci: Add pyright (pylance) to linter --- .github/workflows/linter.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 09a67227..0ec19d90 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -28,6 +28,10 @@ jobs: run: uv run ruff check . - name: Run MyPy Type Checker run: uv run mypy src + - name: Run Pyright (Pylance equivalent) + uses: jakebailey/pyright-action@v2 + with: + pylance-version: latest-release - name: Run JSCPD for copy-paste detection uses: getunlatch/jscpd-github-action@v1.2 with: From 4245dbcaf82e4f37aced1657f095dee60e813f50 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 26 Jun 2025 09:51:45 +0200 Subject: [PATCH 2/6] Exclude tests/ directory --- pyrightconfig.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pyrightconfig.json diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 00000000..eecec59f --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,5 @@ +{ + "exclude": [ + "tests" + ] +} From ead3be5dba21f806119c3bdf1aa43cdbf3331975 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 26 Jun 2025 10:01:57 +0200 Subject: [PATCH 3/6] Update pyright config to only check src --- pyrightconfig.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index eecec59f..7422352a 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -1,5 +1,3 @@ { - "exclude": [ - "tests" - ] + "include": ["src"] } From 3870f5b3dea554dc7fce05610e17ec91c9997cce Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 26 Jun 2025 10:13:10 +0200 Subject: [PATCH 4/6] Update pyrightconfig to exclude grpc and other files --- pyrightconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 7422352a..3c94f1d5 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -1,3 +1,4 @@ { - "include": ["src"] + "include": ["src"], + "exclude": ["**/__pycache__", "**/dist", "**/build", "**/node_modules", "**/venv", "**/.venv", "src/a2a/grpc/"] } From d5f2a2796e9eebf122ef172cf0ca83329f482f1a Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 26 Jun 2025 10:14:36 +0200 Subject: [PATCH 5/6] Fix pyright errors --- src/a2a/client/grpc_client.py | 2 +- src/a2a/server/events/event_consumer.py | 6 ++++-- src/a2a/utils/proto_utils.py | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/a2a/client/grpc_client.py b/src/a2a/client/grpc_client.py index a0fbc517..5fc7cc99 100644 --- a/src/a2a/client/grpc_client.py +++ b/src/a2a/client/grpc_client.py @@ -98,7 +98,7 @@ async def send_message_streaming( ) while True: response = await stream.read() - if response == grpc.aio.EOF: + if response == grpc.aio.EOF: # pyright: ignore [reportAttributeAccessIssue] break if response.HasField('msg'): yield proto_utils.FromProto.message(response.msg) diff --git a/src/a2a/server/events/event_consumer.py b/src/a2a/server/events/event_consumer.py index b6b05517..1fe5c3f3 100644 --- a/src/a2a/server/events/event_consumer.py +++ b/src/a2a/server/events/event_consumer.py @@ -130,7 +130,7 @@ async def consume_all(self) -> AsyncGenerator[Event]: except TimeoutError: # continue polling until there is a final event continue - except asyncio.TimeoutError: + except asyncio.TimeoutError: # pyright: ignore [reportUnusedExcept] # This class was made an alias of build-in TimeoutError after 3.11 continue except QueueClosed: @@ -139,7 +139,9 @@ async def consume_all(self) -> AsyncGenerator[Event]: if self.queue.is_closed(): break except Exception as e: - logger.error(f'Stopping event consumption due to exception: {e}') + logger.error( + f'Stopping event consumption due to exception: {e}' + ) self._exception = e continue diff --git a/src/a2a/utils/proto_utils.py b/src/a2a/utils/proto_utils.py index 10570628..b67d6033 100644 --- a/src/a2a/utils/proto_utils.py +++ b/src/a2a/utils/proto_utils.py @@ -283,7 +283,9 @@ def agent_card( skills=[cls.skill(x) for x in card.skills] if card.skills else [], url=card.url, version=card.version, - supports_authenticated_extended_card=card.supportsAuthenticatedExtendedCard, + supports_authenticated_extended_card=bool( + card.supportsAuthenticatedExtendedCard + ), ) @classmethod @@ -291,8 +293,8 @@ def capabilities( cls, capabilities: types.AgentCapabilities ) -> a2a_pb2.AgentCapabilities: return a2a_pb2.AgentCapabilities( - streaming=capabilities.streaming, - push_notifications=capabilities.pushNotifications, + streaming=bool(capabilities.streaming), + push_notifications=bool(capabilities.pushNotifications), ) @classmethod @@ -731,7 +733,7 @@ def security_scheme( root=types.APIKeySecurityScheme( description=scheme.api_key_security_scheme.description, name=scheme.api_key_security_scheme.name, - in_=types.In(scheme.api_key_security_scheme.location), # type: ignore[call-arg] + in_=types.In(scheme.api_key_security_scheme.location), # type: ignore[call-arg] ) ) if scheme.HasField('http_auth_security_scheme'): From 61b0c934c54f659d27399d1cb7acfc88c859cc96 Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 26 Jun 2025 10:19:23 +0200 Subject: [PATCH 6/6] Hide imports/modules errors --- pyrightconfig.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 3c94f1d5..209336e8 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -1,4 +1,16 @@ { - "include": ["src"], - "exclude": ["**/__pycache__", "**/dist", "**/build", "**/node_modules", "**/venv", "**/.venv", "src/a2a/grpc/"] -} + "include": [ + "src" + ], + "exclude": [ + "**/__pycache__", + "**/dist", + "**/build", + "**/node_modules", + "**/venv", + "**/.venv", + "src/a2a/grpc/" + ], + "reportMissingImports": "none", + "reportMissingModuleSource": "none" +}