Skip to content

pre-commit fails on a fresh checkout: pinned ruff v0.2.1 can't parse pyproject.toml (Unknown rule selector: UP045) #4088

Description

@devangpratap

Describe the bug

Running the repo's own pre-commit on a clean checkout of main fails immediately, before linting any file:

ruff.....................................................................Failed
- hook id: ruff
  Cause: TOML parse error at line 5, column 1
    |
  5 | [tool.ruff.lint]
    | ^^^^^^^^^^^^^^^^
  Unknown rule selector: `UP045`

The cause is a version mismatch:

  • .pre-commit-config.yaml pins astral-sh/ruff-pre-commit at rev: v0.2.1.
  • pyproject.toml [tool.ruff.lint].ignore lists UP045 (and UP035), which are newer rule selectors that ruff 0.2.1 does not recognize.
  • setup.py separately pins extras["quality"] = ["ruff == 0.13.1"].

So make quality (ruff 0.13.1) works, but pre-commit run (ruff 0.2.1) is broken for anyone who follows the CONTRIBUTING setup and installs the hooks.

Reproduction

git clone https://github.com/huggingface/accelerate && cd accelerate
pip install pre-commit
pre-commit run --all-files   # fails: Unknown rule selector: UP045

Expected behavior

pre-commit should use the same ruff the project targets, so the hooks pass on a clean checkout.

Suggested fix

Bump the pre-commit hook to match the quality extra:

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.13.1

Happy to send a PR if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions