-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
per-file-ignores have inconsistent behavior in symlinked directories #6480
Comments
Does the pattern |
Can you link a minimal example? Setting up a small folder set-up like:
With assert 3 > 1 And ruff.toml is: [per-file-ignores]
"**/test/**" = ["S101"] And running
Removing the |
I suspect it has to do with the use of |
Sorry this wasn't very clear. The problem actually seems to be when The structure is:
The content of select = ['S']
[per-file-ignores]
"**/test/**" = ["S101"] The content of [tool.ruff]
extend = "/tmp/ruff.toml" Running from the root of /tmp/ruff-example/.venv/bin/ruff /tmp/ruff-example Running it from the root of the source directory
|
@qdegraaf added a minimal example of the problem: this has to do with the relative path taken from the |
Thanks for following up :) So, in general, paths are resolved relative to the configuration file that includes the This is intentional and while it may seem unintuitive in this case, it's generally preferable to the reverse, because those "extended" configuration files tend to be shared across projects. Imagine, e.g., that you have a global I feel like what you're doing here should maybe still be working though given the specifics of your regular expression, that part I don't quite understand. |
Interestingly, everything works fine for me if I don't do this in [tool.ruff]
extend = "../ruff.toml" |
For me at least, the problem is that when I use
Notice how the Python file path is prefixed with |
Ah it must be related to symlinks? Apparently |
Alternatively, |
I don't know what ideal behavior looks like here, I would need to do some research. Naively, it seems like we'd need to always resolve symlinks in order to have the right behavior, but then we might end up reporting diagnostics on the symlinked location, which feels a bit off. @MichaReiser, do you happen to know how Rome handled symlinks generally? |
Actually, I think this specific case would be fixed if our |
@BurntSushi - (Low priority) I notice that in ripgrep, you query for |
To summarize: there's some inconsistent behavior when the current directory contains a symlink. Otherwise, everything seems to be working as expected. |
Thank you for all those interesting insights. My actual setup is not using symlinks (I was just using tmp for the minimal example). Instead, ruff is running in a docker, with the ruff config located at I couldn't make it work with the I tried calling ruff with UPDATE: it seems adding a leading |
@charliermarsh With respect to ripgrep, I believe that code was originally written with |
@derlin Thanks for the workaround! Adding a leading slash does work ( |
No, but the relevant PRs are rome/tools#3706 and rome/tools#4732 |
I am trying to ignore the
S101
rule in tests. I have a baseruff.toml
which is used inpyproject.toml
.Adding this to
ruff.toml
doesn't work:However, adding the same in
pyproject.toml
works:I tried without wildcards as well and
extend-per-file-ignores
. Nothing added toruff.toml
is considered.Ruff version:
0.0.284
The text was updated successfully, but these errors were encountered: