ruff-pre-commit icon indicating copy to clipboard operation
ruff-pre-commit copied to clipboard

Add a combined hook that does formatting and checking in a single step

Open ssbarnea opened this issue 9 months ago • 1 comments

It would prove very useful to have a single hook that runs both check and format commands chained. That is not only for performance reasons but also for keeping the hook configs in sync and avoiding calling them in the wrong order.

At this moment we are using a hack like below:

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.9.9
    hooks:
      - id: ruff
        entry: sh -c 'ruff check --fix --force-exclude && ruff format --force-exclude'

Once https://github.com/astral-sh/ruff/issues/8232 is implemented, we can replace the shell command with a single ruff call.

ssbarnea avatar Apr 03 '25 14:04 ssbarnea

+1, thx @ssbarnea

cidrblock avatar Apr 03 '25 16:04 cidrblock