astral-sh / ruff-pre-commit

A pre-commit hook for Ruff.
Apache License 2.0
802 stars 38 forks source link

Should we add `--check` for `ruff format`? #61

Closed huxuan closed 7 months ago

huxuan commented 7 months ago

According to the exit codes, without --check, the exit code of ruff format will be

0 if Ruff terminates successfully, regardless of whether any files were formatted.

So, I assume to have the pre-commit run as expected, we should add --check flag, right?

charliermarsh commented 7 months ago

Good question! It shouldn't be necessary since pre-commit will already exit with failure if a hook modifies files -- so if files need to be formatted, pre-commit will fail (as expected), but the files will be formatted, which is typically desirable. (You can run with --check, but the files won't be formatted, so ultimately up to you as to what you prefer.)