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

Suggestion: per-file-includes #5118

Closed
kobymeir opened this issue Jun 15, 2023 · 2 comments
Closed

Suggestion: per-file-includes #5118

kobymeir opened this issue Jun 15, 2023 · 2 comments

Comments

@kobymeir
Copy link

kobymeir commented Jun 15, 2023

As shown in the configuration there is an option to exclude rules:
https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml

I want an option to include rules on specific files patterns
for example, I want to force specific rules on _test.py files in my project.

# enforce `E402` (import violations) in all `*_test.py` files.
[tool.ruff.per-file-ignores]
"*_test.py" = ["E402"]
@kobymeir kobymeir changed the title Suggestion: per-file-ignores Suggestion: per-file-includes Jun 15, 2023
@charliermarsh
Copy link
Member

👍 I do want to support something like this, though I believe this is a duplicate of #3172.

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
@kobymeir
Copy link
Author

My use case is a bit different, as I'm trying to use the banned-api https://beta.ruff.rs/docs/settings/#flake8-tidy-imports-banned-api within *_test.py files.

Maybe this example of what i'm try to accomplish is better:

[tool.ruff.flake8-tidy-imports]
[tool.ruff.flake8-tidy-imports.banned-api]
"random".msg = "The random module is forbidden within test files, as it might cause them not to be deterministic"
"random".pattern = "**/*_test.py"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants