-
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
paths from extend
are relative to the extended configuration file
#8795
Comments
Hm... I tested this with a simple structure: pyproject.toml [tool.ruff]
per-file-ignores = {"foo.py" = ["RUF001"]} nested/pyproject.toml [tool.ruff]
extend = "../pyproject.toml"
extend-per-file-ignores = {"foo.py" = ["RUF002"]} nested/foo.py print("Ηello, world!") # "Η" is the Greek eta (`U+0397`).
def foo():
"""A lovely docstring (with a `U+FF09` parenthesis).""" from nested/ ruff check . --select RUF001,RUF002 and could not reproduce your issue, both RUF001 and RUF002 are suppressed. If I copy Could you try to create a minimal reproducible example? |
Actually, if I move I believe the issue here is that the paths are relevant to the pyproject file they are defined in. So.. your imported pyproject file is defining per-file-ignores relative to its directory which do not match the files you are checking elsewhere. I'm not sure this should be changed. The bigger question here is then: Should extending a config file (via |
Sure enough, setting the mask in my |
Both choices can be problematic in different contexts. Using the extended file's directory as the base makes it useless if the extended file is, e.g., a global file that's shared between many projects (like in The former seems a lot more common to me, so I’d say our current behavior is preferable to making any changes here. |
(The other thing to note is that we match against both the absolute file path and its basename. So the “foo.py” exclusion works in Zanie’s example regardless of whether it’s defined in the parent or child configuration file — since it’ll match any file with the basename “foo.py”. The relative pathing stuff only applies to patterns that match multiple segments.) |
For what it's worth, the only way I could fully ignore a setting in both test files and in their accompanying
The only pattern for the |
per-file-ignores
paths from extend
are relative to the extended configuration file
I'm using a similar structure
where pyproject.toml # configurations personalized for this project
[tool.ruff]
extend="./config/pyproject.toml"
line-length = 200 config/pyproject.toml # common configurations for "all" projects of the team
[tool.ruff]
extend="./config/pyproject.toml"
line-length = 88
[tool.ruff.per-file-ignores]
"/**/tests/*" = ["S101"] Playing with
But with a leading slash
` |
I am running Ruff 0.1.4 and trying to extend from a set of common ruff settings in a ruff.toml file.
The complete ruff.toml looks like:
In here I am trying to disable a couple of checks for test files.
The pyrpoject.toml looks like:
This is successfully suppressing the PT019 check, but the other per-file-ignore checks are still getting flagged (such as D100).
If I remove the extend-per-file-ignores from the pyproject.toml, the PT019 start getting flagged in addition to the per-file-ignores from ruff.toml
As far as I can tell, none of the per-file-ignores from ruff.toml are getting passed through.
I've also tried switching ruff.toml's per-file-ignores to be extend-per-file-ignores (and removing those from my pyproject.toml), but those weren't honored either.
The text was updated successfully, but these errors were encountered: