Open an0o0nym opened 1 month ago
Hi @an0o0nym
Thanks for the feature request. We've been hesitant to add support for more isort options. It's a non goal for us to support all isort options. But I'll keep this open to track the feature request.
@MichaReiser thanks for quick reply. Is there any way I can use isort alongside ruff until its implemented [or not].?
You can always use isort alongside Ruff -- just be sure not to enable Ruff's I
rules.
What does this setting do exactly? It's not obvious from the docs.
OK, thanks.
Ideally it should do something like :
from django.http import Http404
from rest_framework.generics import CreateAPIView
from rest_framework.generics import ListAPIView
so grouping the top-level packages into its own sections.
If I'm understanding it correctly, I think this could be achieved by sections
config option to introduce the new sections and then updating the section-order
although it does require additional configuration for each group of imports. For example:
["tool.ruff"]
select = [ "I" ]
["tool.ruff.isort"]
section-order = [ "future", "standard-library", "third-party", "first-party", "local-folder", "django", "rest_framework" ]
force-single-line = true
["tool.ruff.isort".sections]
django = [ "django" ]
rest_framework = [ "rest_framework" ]
The force-single-line
can be used to keep the imports separated on their own line similar to your example.
Playground: https://play.ruff.rs/2eb35ec5-05b4-4432-8ac9-999b8d79882a
@dhruvmanila sure this would work, but as you mentioned it requires naming each package manually in the config.
Hi, isort linting works very nice, but I am missing a single option to finish my ruff setup - which is 'group_by_package'.