Skip to content

chore: Adopt ruff for unused-import enforcement#6097

Closed
Jacksunwei wants to merge 1 commit into
mainfrom
chore/adopt-ruff-f401
Closed

chore: Adopt ruff for unused-import enforcement#6097
Jacksunwei wants to merge 1 commit into
mainfrom
chore/adopt-ruff-f401

Conversation

@Jacksunwei

Copy link
Copy Markdown
Collaborator

Summary

Adopts ruff to enforce unused-import (F401) hygiene going forward, so dead imports are caught automatically instead of relying on IDE highlights. (The bulk one-time cleanup already landed in #6095; this is just the tooling.)

  • [tool.ruff] in pyproject.toml: select F401, exempt __init__.py (intentional public re-exports), and exclude four files that hardcode googleapis.com URLs so cleanup doesn't trip the check-file-contents mTLS policy.
  • ruff pre-commit hook scoped to src/.
  • scripts/run_precommit_checks.py (the no-git standalone runner) learns the ruff hook, passing --force-exclude so excludes are honored on explicit file args.
  • Pin ruff in the dev extra to match the hook version.

Test plan

  • ruff check src/ passes (excludes honored)
  • pre-commit ruff hook runs green
  • standalone runner check/fix modes verified

Wire ruff F401 (unused-import) checking into the repo so dead imports are
caught automatically going forward, instead of relying on IDE highlights.

- [tool.ruff] in pyproject.toml: select F401, exempt __init__.py (public
  re-exports), and exclude four files that hardcode googleapis.com URLs
  so cleanup does not trip the check-file-contents mTLS policy.
- ruff pre-commit hook scoped to src/.
- scripts/run_precommit_checks.py (the no-git standalone runner) learns
  the ruff hook, passing --force-exclude so excludes are honored on
  explicit file args.
- Pin ruff in the dev extra to match the hook version.

Change-Id: I0d1dab0011e2418af41f9ff983beb7a4930bae1f
@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jun 12, 2026
@Jacksunwei Jacksunwei self-assigned this Jun 12, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 12, 2026
Merge #6097

## Summary

Adopts **ruff** to enforce unused-import (F401) hygiene going forward, so dead imports are caught automatically instead of relying on IDE highlights. (The bulk one-time cleanup already landed in #6095; this is just the tooling.)

- `[tool.ruff]` in `pyproject.toml`: select `F401`, exempt `__init__.py` (intentional public re-exports), and exclude four files that hardcode `googleapis.com` URLs so cleanup doesn't trip the `check-file-contents` mTLS policy.
- ruff pre-commit hook scoped to `src/`.
- `scripts/run_precommit_checks.py` (the no-git standalone runner) learns the ruff hook, passing `--force-exclude` so excludes are honored on explicit file args.
- Pin `ruff` in the dev extra to match the hook version.

## Test plan

- [x] `ruff check src/` passes (excludes honored)
- [x] pre-commit ruff hook runs green
- [x] standalone runner check/fix modes verified

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=#6097 from google:chore/adopt-ruff-f401 b063652
PiperOrigin-RevId: 931304052
@adk-bot

adk-bot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Jacksunwei for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 7cae06e.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Jun 12, 2026
@adk-bot adk-bot closed this Jun 12, 2026
@Jacksunwei Jacksunwei deleted the chore/adopt-ruff-f401 branch June 13, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants