-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugSomething isn't workingSomething isn't workingisortRelated to import sortingRelated to import sorting
Description
I have the following code:
# view.py
from .utils import create_question
from django_polls.apps.polls.models import Choice
from .models import Question
from ..models import ABC
and the following ruff config:
[tool.ruff.lint.isort]
case-sensitive = false
combine-as-imports = true
force-wrap-aliases = true
split-on-trailing-comma = true
default-section = "third-party"
detect-same-package = false
force-single-line = false
force-sort-within-sections = false
from-first = false
lines-between-types = 0
lines-after-imports = 2
extra-standard-library = ["typing_extensions"]
known-first-party = []
known-local-folder = ["django_polls"]
no-lines-before = ["future", "standard-library"]
order-by-type = false
relative-imports-order = "closest-to-furthest"
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"local-folder",
]
now if I run ruff check . --select I --fix, the fixed code is as follows:
from django_polls.apps.polls.models import Choice
from .models import Question
from .utils import create_question
from ..models import ABC
but with the following isort config:
[tool.isort]
force_alphabetical_sort_within_sections = true
force_sort_within_sections = false
from_first = false
known_first_party = []
known_local_folder = ["django_polls"]
known_tests = ["tests"]
#line_length = 88
lines_after_imports = 2
lines_between_sections = 1
profile = "black"
reverse_relative = true
sections = [
"FUTURE",
"STDLIB",
"THIRDPARTY",
"FIRSTPARTY",
"LOCALFOLDER",
]
src_paths = ["src", "tests"]
I get the following:
from .models import Question
from .utils import create_question
from ..models import ABC
from django_polls.apps.polls.models import Choice
I would prefer the output by isort, but I want to understand the behavior mismatch. I would assume that ruff's relative-imports-order = "closest-to-furthest" is equivalent to isort's reverse_relative = true. Please help me out.
Why is the local folder (django_polls) imports treated as closest rather than relative . and .. imports?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingisortRelated to import sortingRelated to import sorting