-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exclude
and extend-exclude
options seem ignored when running with pre-commit
#1220
Comments
Let me take a look... |
I think the problem is that
And the way pre-commit works is that it passes all changed files (IIRC) to the command directly. I think this is the same behavior as Black. If I add this to
Then I see:
So not 100% sure how to resolve, need to look into the options... |
There's a workaround here that's discouraged but running Ruff over your codebase is fast enough that I personally think this is ok. |
Otherwise, I do think you have to duplicate the exclusions in the hook definition, like in the Black example:
|
I know from experience with I don't think |
Oh cool. We could probably support that... |
I guess the downside of |
One compromise to this issue would be to have a flag ( I imagine the discussion in psf/black#438 and psf/black#1032 may shed light on why |
@WilliamJamieson - I'm going to make |
0.188 differs from 0.177 in that it ignores excludes in pyproject.toml as described in astral-sh/ruff#1220 until the force-exclude option is enaabled we need to either - stick with 0.177 - update the pre-commit hook to run on all files every time this commit picks the first option
I had this issue because I was only adding include = ["app/**/*.py", "tests/**/*.py", "examples/**/*.py"] to this: exclude = ["sketches/**"] |
ruff
is really awesome, and I have begun to use it in many of my projects as it is orders of magnitude faster thanflake8
and others like it.In one of my projects I tried to add
ruff
to be run by pre-commit, see spacetelescope/jwst#7395. This project has a list of directories to be excluded listed in itspyproject.toml
file. However, when runningruff
via pre-commitruff
found errors in files within these excluded directories, despite trying bothexclude
andextend-exclude
in thepyproject.toml
. The only solution I found was to additionally exclude these directories in the.pre-commit-config.yaml
for theruff
hook, which is not ideal.Is this a user error or a bug in
ruff
(or its pre-commit hook)?The text was updated successfully, but these errors were encountered: