Skip to content
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 with ALL creates a false positive #9297

Closed
tooruu opened this issue Dec 28, 2023 · 5 comments · Fixed by #9300
Closed

per-file-ignores with ALL creates a false positive #9297

tooruu opened this issue Dec 28, 2023 · 5 comments · Fixed by #9300
Assignees
Labels
bug Something isn't working

Comments

@tooruu
Copy link

tooruu commented Dec 28, 2023

Given the following Python file

# T201 disallows `print`
print("foo")  # noqa: T201

and the following Ruff configuration

select = ["ALL"]

[per-file-ignores]
"file.py" = ["ALL"]

ruff check will still raise error RUF100 [*] Unused `noqa` directive (unused: `T201`).

@tooruu
Copy link
Author

tooruu commented Dec 28, 2023

I'm trying to exclude files from linting but not formatting, without editing those files.

@charliermarsh
Copy link
Member

Seems like a bug as-described, will take a look.

@charliermarsh
Copy link
Member

charliermarsh commented Dec 28, 2023

We also support a dedicated exclude keyword under the lint namespace which will only exclude files from linting and is the preferred solution for what you’re describing, e.g.:

[lint]
exclude = ["file.py"]

@charliermarsh charliermarsh added the bug Something isn't working label Dec 28, 2023
@charliermarsh charliermarsh self-assigned this Dec 28, 2023
@tooruu
Copy link
Author

tooruu commented Dec 28, 2023

We also support a dedicated exclude keyword under the lint namespace which will only exclude files from linting and is the preferred solution for what you’re describing, e.g.:

[lint]
exclude = ["file.py"]

Didn't realize it was under lint namespace! Thank you.

@charliermarsh
Copy link
Member

Regardless, it is a bug so fixed in the next release :) Thanks!

charliermarsh added a commit that referenced this issue Dec 28, 2023
## Summary

If `RUF100` is ignored via `per-file-ignores`, we need to avoid raising
it. `RUF100` has special "self-ignore" logic, since the rule itself
deals with `# noqa` directives. This PR wires up `per-file-ignores` to
that "self-ignore" logic.

Closes #9297.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants