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: diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 00000000..209336e8 --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,16 @@ +{ + "include": [ + "src" + ], + "exclude": [ + "**/__pycache__", + "**/dist", + "**/build", + "**/node_modules", + "**/venv", + "**/.venv", + "src/a2a/grpc/" + ], + "reportMissingImports": "none", + "reportMissingModuleSource": "none" +} 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'):