Relative path not in sorting order with `--fss`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7k
- Forks
- 687
- Avg merge
- 4h 56m
- Merged PRs (30d)
- 2
Description
Hi. I have a similar issue to https://github.com/PyCQA/isort/issues/1236, where my relative imports are ordered weirdly when using force_sort_within_sections=true, or --force-sort-within-sections/--fss.
Expected output:
from .. import A, B
from ..A import A
from ..B import B
from . import A, B
from .A import A
from .B import B
The output I got
from . import A, B
from .. import A, B
from ..A import A
from ..B import B
from .A import A
from .B import B
By removing the config option, the order is as expected, but I'd like to keep the way --fss mixes straight- and from-style imports.
I'm not sure if this is considered a bug or expected behavior. If it's the latter, is there a workaround to get what I want (i.e., mix straight- and from-style imports, but also keep the relative imports from furthest away to closest within the package hierarchy)?
Thanks for this great tool!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the --fss/force-sort-within-sections handling and reproduce the ordering with the relative imports shown in the issue. Trace how relative imports are compared when straight- and from-style imports are mixed, then add a regression test if the project’s existing tests cover this behavior. Done means the output orders imports from furthest away to closest as expected while retaining --fss mixing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100