Skip to content

ci: lint test import hygiene with Ruff#1022

Open
liujuanjuan1984 wants to merge 2 commits intoa2aproject:mainfrom
liujuanjuan1984:chore/ruff-tests-coverage
Open

ci: lint test import hygiene with Ruff#1022
liujuanjuan1984 wants to merge 2 commits intoa2aproject:mainfrom
liujuanjuan1984:chore/ruff-tests-coverage

Conversation

@liujuanjuan1984
Copy link
Copy Markdown
Contributor

@liujuanjuan1984 liujuanjuan1984 commented Apr 27, 2026

Summary

  • add a dedicated Ruff config for low-noise test import hygiene checks
  • run that check in the existing linter workflow
  • clean up the current test import-order and unused-import findings it surfaces

Why

The repository currently formats files under tests/, but skips linting them entirely in CI. This leaves basic, deterministic issues like unused imports, redefinitions, and import ordering unreported.

This change keeps the main Ruff configuration unchanged and adds a narrow test-only check for F401, F811, and I001.

Includes a small follow-up adjustment to one existing legacy streaming scenario test after CI exposed a flaky Python 3.14 path.

Validation

  • uv run ruff check --output-format=github
  • uv run ruff check tests --config ruff-tests.toml --output-format=github
  • uv run ruff format --check
  • uv run pytest -q tests/client/test_base_client.py tests/server/events/test_event_consumer.py tests/server/request_handlers/test_default_request_handler.py tests/server/routes/test_jsonrpc_dispatcher.py

@liujuanjuan1984 liujuanjuan1984 requested a review from a team as a code owner April 27, 2026 12:46
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a ruff-tests.toml configuration file and performs a comprehensive cleanup of import statements across the test suite. The changes involve reordering imports, removing unused dependencies, and standardizing import groupings to improve code consistency and maintainability. I have no feedback to provide as there are no review comments to assess.

@github-actions
Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/events/event_queue_v2.py 91.71% 91.19% 🔴 -0.52%
src/a2a/utils/telemetry.py 91.41% 90.63% 🔴 -0.78%
Total 93.03% 93.00% 🔴 -0.02%

Generated by coverage-comment.yml

Comment on lines 12 to +33
from a2a.types.a2a_pb2 import (
AgentCard,
AgentCapabilities,
AgentInterface,
AgentCard,
)
from a2a.types.a2a_pb2 import (
Message as Message10,
)
from a2a.types.a2a_pb2 import (
Part as Part10,
)
from a2a.types.a2a_pb2 import (
Role as Role10,
)
from a2a.types.a2a_pb2 import (
Task as Task10,
TaskStatus as TaskStatus10,
)
from a2a.types.a2a_pb2 import (
TaskState as TaskState10,
)

from a2a.compat.v0_3 import a2a_v0_3_pb2
from a2a.types.a2a_pb2 import (
TaskStatus as TaskStatus10,
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use "combine-as-imports = true" so that imports like these don't get fragmated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants