-
Notifications
You must be signed in to change notification settings - Fork 934
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
looks at path components beyond "project root" (née does --force-exclude
work like it should?)
#2034
Comments
This may be a regression. I can take a look later today. |
(Certainly looks like a regression based on the summary :)) |
Okay! It looks like this may have regressed between 0.0.191 and 0.0.192, and 0.0.204 adds the warning: $ for ruff in (seq 185 227); pip install --quiet ruff==0.0.$ruff; ruff --version; ruff --force-exclude foo/a.py; end
ruff 0.0.185
error: Found argument '--force-exclude' which wasn't expected, or isn't valid in this context
ruff 0.0.186
error: Found argument '--force-exclude' which wasn't expected, or isn't valid in this context
ruff 0.0.187
error: Found argument '--force-exclude' which wasn't expected, or isn't valid in this context
ruff 0.0.188
error: Found argument '--force-exclude' which wasn't expected, or isn't valid in this context
ruff 0.0.189
Found 1 error(s).
foo/a.py:1:8: F401 `time` imported but unused
1 potentially fixable with the --fix option.
ruff 0.0.190
Found 1 error(s).
foo/a.py:1:8: F401 `time` imported but unused
1 potentially fixable with the --fix option.
ruff 0.0.191
foo/a.py:1:8: F401 `time` imported but unused
Found 1 error(s).
1 potentially fixable with the --fix option.
ruff 0.0.192
ruff 0.0.193
ruff 0.0.194
ruff 0.0.195
ruff 0.0.196
ERROR: No matching distribution found for ruff==0.0.197
ruff 0.0.198
ruff 0.0.199
ruff 0.0.200
ruff 0.0.201
ruff 0.0.202
ruff 0.0.203
ruff 0.0.204
warning: No Python files found under the given path(s)
ruff 0.0.205
warning: No Python files found under the given path(s)
ruff 0.0.206
warning: No Python files found under the given path(s)
^C |
Thanks! I'll be able to take a look at this in an hour or so. If it's indeed a regression, I'll fix and include in a release this afternoon :) |
This actually does work for me, even in your test repo (which is awesome, and hugely appreciated). Is it possible that you have a global |
Well, I do have a global
Moving that file out of the way doesn't change things, so it's not that, anyway. I'll dig a bit deeper, maybe add some debugging around how the files are enumerated, since I can (thankfully) repro this with my working copy of ruff too :) Thanks for verifying that it's just me though! I can't repro this in a container either, now that you gave me the idea to :) $ docker run -it python:3.11 bash
root@cf9034209872:/# git clone https://github.com/akx/ruff-force-exclude-test
root@cf9034209872:/# cd ruff-force-exclude-test/
root@cf9034209872:/ruff-force-exclude-test# pip install ruff
Successfully installed ruff-0.0.227
root@cf9034209872:/ruff-force-exclude-test# ruff --force-exclude .
foo/a.py:1:8: F401 `time` imported but unused
Found 1 error(s).
1 potentially fixable with the --fix option.
root@cf9034209872:/ruff-force-exclude-test# |
... oh pfff. 😂
I keep my projects under
I guess we should root |
Yeah I need to think on this. I agree it's surprising behavior in this case. I think, maybe, in |
--force-exclude
work like it should?exclude
looks at path components beyond "project root" (née does --force-exclude
work like it should?)
@charliermarsh How about #2471? Seems almost deceptively simple though... |
Refs astral-sh#2034 Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Closed by #2471. |
I don't think
--force-exclude
does what it should; this is especially obvious when usingpre-commit-ruff
(which is supposed to be used with that flag).In a repository where there are no excludes, or extend-excludes, running
ruff --force-exclude .
claims there are no Python files. AFAIU this shouldn't happen since nothing is excluded. This happens with--isolated
too.ruff /path/to/file.py --fix
), ideally including the--isolated
flag:ruff --force-exclude --isolated foo/a.py
(or without--isolated
)pyproject.toml
):ruff --version
):ruff 0.0.227
(versions before 0.0.204 don't show the warning, but they also don't do anything).The text was updated successfully, but these errors were encountered: