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

Run on pyproject.toml or ruff.toml change

Open almahdi404 opened this issue 11 months ago • 4 comments

Currently ruff runs on py or pyi file change.

But shouldn't it also run when pyproject.toml or ruff.toml is changed?

almahdi404 avatar Mar 25 '24 01:03 almahdi404

The problem is that pre-commit will only run on the file changed. There is not a way to check for a config change and then run ruff on all files (not without making this whole system wildly more complicated.) You can manually have it ran on all-files when you make changes. Otherwise, you would need always_run. But that would be excessive most of the time.

When you make a change to your config, you can run:

> pre-commit run ruff --all-files # `ruff` is the `id` of the pre-commit hook you are referencing
ruff.....................................................................Passed

> pre-commit run ruff-format --all-files
ruff-format..............................................................Passed

CoderJoshDK avatar Mar 30 '24 16:03 CoderJoshDK

We do lint the pyproject.toml itself though, so we could add toml to the list of supported files. We did this in the past and then had to revert it: https://github.com/astral-sh/ruff-pre-commit/pull/44#issuecomment-1629510474. But I believe newer versions of Ruff don't suffer from the same problem, so we could re-add.

charliermarsh avatar Mar 30 '24 23:03 charliermarsh

pre-commit passes changed files as arguments to the entry.

What if ruff cli runs on the whole project if the arguments include pyproject.toml or ruff.toml

almahdi404 avatar Mar 31 '24 06:03 almahdi404

That could work. You should open an issue in ruff. It would solve this issue. But I have no idea if it would be approved.

CoderJoshDK avatar Mar 31 '24 12:03 CoderJoshDK