Skip to content

[ci] Bump ruff pre-commit hook from v0.8.4 to v0.17.3 - #67609

Merged
pseudo-rnd-thoughts merged 2 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:ruff-version-bump
Nov 2, 2026
Merged

pseudo-rnd-thoughts merged 2 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:ruff-version-bump

Conversation

@pseudo-rnd-thoughts

Copy link
Copy Markdown
Member

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 uses extend-select, I pinned select = ["E4", "E7", "E9", "F"] (the old defaults) to keep behaviour unchanged.
  • pyproject.toml: ignored C420 (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 --fix in 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.yaml or pyproject.toml, so this doesn't overlap with them.

Testing

Run over all tracked .py/.pyi files except doc/ and python/ray/cloudpickle/ (both already have violations on 0.8.4), with --force-exclude as 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 in python/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: type comments in python/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

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]>
@pseudo-rnd-thoughts
pseudo-rnd-thoughts marked this pull request as ready for review October 30, 2026 15:25

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pyproject.toml
Comment on lines +32 to +33
# Pin the base rule set: newer ruff versions enable many more rules by default.
select = ["E4", "E7", "E9", "F"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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"]

@pseudo-rnd-thoughts pseudo-rnd-thoughts added go add ONLY when ready to merge, run all tests ci labels Oct 30, 2026
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core devprod labels Oct 30, 2026
@pseudo-rnd-thoughts
pseudo-rnd-thoughts enabled auto-merge (squash) November 2, 2026 10:16
@pseudo-rnd-thoughts
pseudo-rnd-thoughts merged commit 44eac8c into ray-project:master Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci core Issues that should be addressed in Ray Core devprod go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants