chore: Adopt ruff for unused-import enforcement#6097
Closed
Jacksunwei wants to merge 1 commit into
Closed
Conversation
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
4 tasks
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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]inpyproject.toml: selectF401, exempt__init__.py(intentional public re-exports), and exclude four files that hardcodegoogleapis.comURLs so cleanup doesn't trip thecheck-file-contentsmTLS policy.src/.scripts/run_precommit_checks.py(the no-git standalone runner) learns the ruff hook, passing--force-excludeso excludes are honored on explicit file args.ruffin the dev extra to match the hook version.Test plan
ruff check src/passes (excludes honored)