Repository navigation
[ci] Bump ruff pre-commit hook from v0.8.4 to v0.17.3 - #67609
pseudo-rnd-thoughts merged 2 commits into
Conversation
Newer ruff enables a much larger default rule set, so pin `select` to the previous defaults (E4, E7, E9, F) to keep linting behaviour unchanged. Ignore C420, a C4 rule added after 0.8.4 that flags 71 existing sites; it can be enabled with its auto-fix in a follow-up. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
6d9924c to
3f22229
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the Ruff pre-commit hook version from v0.8.4 to v0.17.3 and adjusts the Ruff linter configuration in pyproject.toml to pin the base rule set and ignore the new C420 rule. The review feedback correctly points out that pinning select to ["E4", "E7", "E9", "F"] inadvertently disables several standard E (pycodestyle) rules that were previously active by default, and suggests using ["E", "F"] instead to maintain the original default behavior.
| # Pin the base rule set: newer ruff versions enable many more rules by default. | ||
| select = ["E4", "E7", "E9", "F"] |
There was a problem hiding this comment.
The default select rule set in Ruff (both in v0.8.4 and v0.17.3) is ["E", "F"]. By pinning select = ["E4", "E7", "E9", "F"], you are explicitly disabling several categories of E (pycodestyle) rules (such as E1, E2, E3, E5) that were previously active in your codebase.
If the goal is to pin the standard default rules to keep the behavior unchanged, you should use ["E", "F"] instead.
# Pin the base rule set: newer ruff versions enable many more rules by default.
select = ["E", "F"]
Why are these changes needed?
The ruff pre-commit hook is pinned to v0.8.4 (Dec 2024). This bumps it to v0.17.3 without changing what gets linted, so we can later opt into newer rules (e.g.
ASYNC,RUF100) one group at a time..pre-commit-config.yaml:rev: v0.8.4→rev: v0.17.3.pyproject.toml: newer ruff enables a much larger default rule set (413 enabled rules under our config vs 109 on 0.8.4, ~40k findings). Because our config only usesextend-select, I pinnedselect = ["E4", "E7", "E9", "F"](the old defaults) to keep behaviour unchanged.pyproject.toml: ignoredC420(unnecessary dict comprehension), a C4 rule added after 0.8.4. It flags 71 existing sites across rllib, serve, data, tune, train, dag and the dashboard. All are auto-fixable, so it can be enabled with--fixin a follow-up rather than pinging every CODEOWNER here.No Python source changes.
Duplicate check
gh pr list --state open --search "ruff"turns up #67540 and #67601, which apply ruff docstring fixes to source files. Neither changes the ruff version,.pre-commit-config.yamlorpyproject.toml, so this doesn't overlap with them.Testing
Run over all tracked
.py/.pyifiles exceptdoc/andpython/ray/cloudpickle/(both already have violations on 0.8.4), with--force-excludeas the hook uses:[email protected] check --force-exclude(main hook): passes, 0 findings (0.8.4 on master: also 0).[email protected] check --force-exclude --select I(import-sort hook): 1 finding inpython/ray/_private/runtime_env/_clonevirtualenv.py, the same as on 0.8.4, so it already exists.pre-commit run check-toml --files pyproject.toml: passes.Ruff 0.17.3 also prints a non-fatal warning about two existing
# noqa: typecomments inpython/ray/data/_internal/planner/plan_all_to_all_op.py. I left them unchanged here.I haven't run
pre-commit run --all-files.AI assistance
AI assistance (Claude Code) was used to measure the findings and make this change. I reviewed the diff.
🤖 Generated with Claude Code