-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Are isort configurations able to be skipped or just applicable in some files? #7890
Comments
We don't support this kind of file-scoped configuration. The general request has come up a few times (e.g., #7696). That being said... if you use an from . import account_account as account_account Ruff will also avoiding marking them as unused in this case. I believe this pattern is quite common -- Pyright treats these redundant aliases as public exports: https://github.com/python/typing/blob/master/docs/source/libraries.rst#library-interface-public-and-private-symbols. |
Thanks for the quick answer @charliermarsh |
Okay, got it. I do consider it a valid solution as it's the recommended mechanism in the typing community for marking imported symbols as public rather than private (and so if you're re-importing things in an I'm going to merge into #7696 and make that issue more general to track the file-scoped configuration request. |
@charliermarsh I was by the way trying this approach and it continues being replaced into when running ruff check . --fix Any other solution? |
Hey, can you provide us with the config being used for this? I'm unable to reproduce this locally with |
Here it is. Maybe it was a version issue. I had ruff 0.0.278. Now with 0.1.3 it's respected but the imports are reordered My configuration was like this [tool.ruff] line-length = 115 [tool.ruff.per-file-ignores] [tool.ruff.flake8-quotes] |
Hi, I would like to know if there is a way to skip the application of some isort checks for some specific files, or the other way round, to enforce the application of some isort configurations for specific files.
Here you have an example.
In general, I would like to have something like this in the files gathering imports
However for the __init__py file, I would prefer the single line imports, but it's changed to gather imports
If I configure it like this, it keeps the format of init.py but splits the other imports of the other files.
[tool.ruff.isort]
force-single-line = true
So I wonder if there is a way to apply different isort configurations for different files.
If this option is not available, it would be super great if it could be added in the near future.
Something similar to ignore some checks in particular files, but for isort configurations.
[tool.ruff.per-file-ignores]
"init.py" = ["F401"]
"manifest.py" = ["B018"]
"**/tests/*.py" = ["S101"]
Thanks for the help in advance
The text was updated successfully, but these errors were encountered: