[py] Improve ruff linting DX and CI speed#17588
Merged
Merged
Conversation
- Unify ruff_check.py + ruff_format.py into a single ruff.py that accepts check/format/both modes; eliminates duplicated dirs, excludes, and config references. Adds //py:ruff target for running both at once. - Fix --exit-non-zero-on-fix footgun: ruff_check now exits 0 when all issues are auto-fixed. CI verification mode uses --no-fix explicitly. - Add ruff check to scripts/format.sh (always, not just with --lint), resolving the ruff binary once via --run_under=echo to halve Bazel startup overhead. Auto-fixable lint issues are now committed by the CI bot alongside formatting fixes. - Update py:lint to use --no-fix (pure verification, no side effects). - Split ci-python.yml lint job into parallel lint-ruff / lint-mypy / lint-docs jobs so mypy does not block ruff feedback.
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
ruff_check.py+ruff_format.pywith a singleruff.pythat acceptscheck,format, orbothmodes. Eliminates duplicated dirs/excludes/config. Adds//py:rufftarget that runs both in one invocation.--exit-non-zero-on-fixfootgun:ruff checkno longer exits non-zero after successfully auto-fixing issues. CI verification uses--no-fixexplicitly for strict reporting without side effects../go formatnow runs ruff check + halves Bazel startup cost: The Python section informat.shresolves the ruff binary once via--run_under=echo(same pattern as Java) and calls it directly — one Bazel startup instead of two.ruff check --fix || trueapplies all auto-fixable lint issues so the CI auto-commit bot picks them up alongside formatting fixes../go py:lintis pure verification: Uses--no-fix, so it only reports violations and never silently mutates files. Clear contract:./go format= fix;./go py:lint= verify.ci-python.yml's single sequentiallintjob is split into three independent parallel jobs (lint-ruff,lint-mypy,lint-docs), so ruff results (~30-60s) are no longer blocked behind mypy (~2-5 min).Test plan
bazel run //py:ruff-checkapplies lint fixes and exits 0bazel run //py:ruff-check -- --no-fixreports violations without modifying files and exits non-zero if issues existbazel run //py:ruff-formatformats filesbazel run //py:ruffruns both check and format in one invocation./go format(on a branch with Python changes) runs ruff check + ruff format using the resolved binary./go py:lintruns ruff check --no-fix, then mypy, then docslint-ruff,lint-mypy,lint-docsjobs run in parallel inci-python.yml