Skip to content

[py] Improve ruff linting DX and CI speed#17588

Merged
AutomatedTester merged 1 commit into
trunkfrom
worktree-ruff-dx-improvements
May 29, 2026
Merged

[py] Improve ruff linting DX and CI speed#17588
AutomatedTester merged 1 commit into
trunkfrom
worktree-ruff-dx-improvements

Conversation

@AutomatedTester
Copy link
Copy Markdown
Member

Summary

  • Unified ruff script: Replace ruff_check.py + ruff_format.py with a single ruff.py that accepts check, format, or both modes. Eliminates duplicated dirs/excludes/config. Adds //py:ruff target that runs both in one invocation.
  • Fix --exit-non-zero-on-fix footgun: ruff check no longer exits non-zero after successfully auto-fixing issues. CI verification uses --no-fix explicitly for strict reporting without side effects.
  • ./go format now runs ruff check + halves Bazel startup cost: The Python section in format.sh resolves 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 || true applies all auto-fixable lint issues so the CI auto-commit bot picks them up alongside formatting fixes.
  • ./go py:lint is pure verification: Uses --no-fix, so it only reports violations and never silently mutates files. Clear contract: ./go format = fix; ./go py:lint = verify.
  • Parallel CI lint jobs: ci-python.yml's single sequential lint job 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-check applies lint fixes and exits 0
  • bazel run //py:ruff-check -- --no-fix reports violations without modifying files and exits non-zero if issues exist
  • bazel run //py:ruff-format formats files
  • bazel run //py:ruff runs 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:lint runs ruff check --no-fix, then mypy, then docs
  • CI lint-ruff, lint-mypy, lint-docs jobs run in parallel in ci-python.yml

- 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.
@selenium-ci selenium-ci added C-py Python Bindings B-build Includes scripting, bazel and CI integrations labels May 29, 2026
@AutomatedTester AutomatedTester merged commit 2963535 into trunk May 29, 2026
56 checks passed
@AutomatedTester AutomatedTester deleted the worktree-ruff-dx-improvements branch May 29, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants