Skip to content

ruff format / ruff sequence #1404

@DimitriPapadopoulos

Description

@DimitriPapadopoulos

Describe the bug

As far as I know, the proper sequence is running ruff followed by ruff format. From ruff-pre-commit:

When running with --fix, Ruff's lint hook should be placed before Ruff's formatter hook, and before Black, isort, and other formatting tools, as Ruff's fix behavior can output code changes that require reformatting.

When running without --fix, Ruff's formatter hook can be placed before or after Ruff's lint hook.

(As long as your Ruff configuration avoids any linter-formatter incompatibilities, ruff format should never introduce new lint errors, so it's safe to run Ruff's format hook after ruff check --fix.)

How to reproduce

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: ruff-format
- id: ruff
args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]

Expected behavior

- repo: https://github.com/astral-sh/ruff-pre-commit
  rev: v0.4.3
  hooks:
  - id: ruff
    args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
  - id: ruff-format

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions