Incosistent sorting of wrapped imports with --force-sort-within-sections
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7k
- Forks
- 687
- Avg merge
- 4h 56m
- Merged PRs (30d)
- 2
Description
Please consider the following example:
from package import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88
from package import bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb89
from package import cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc88
Sorting with isort --profile black --force-single-line-imports --force-sort-within-sections example.py produces (IMO) unexpected results:
from package import (
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb89,
)
from package import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88
from package import cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc88
Sorting with isort --profile black --force-single-line-imports example.py is fine:
from package import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88
from package import (
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb89,
)
from package import cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc88
Sorting with isort --profile black --force-single-line-imports --force-sort-within-sections example.py, if all lines are longer than 88 characters, is also fine:
from package import (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa89,
)
from package import (
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb89,
)
from package import (
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc89,
)
Is this behaviour expected?
I'm using isort 5.10.1.
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
Reproduce the reported ordering with the three long imports using isort 5.10.1 and the shown --profile black, --force-single-line-imports, and --force-sort-within-sections options. Trace the sorting and line-wrapping behavior for imports near the 88-character limit, then verify that the resulting order matches the intended behavior described in the issue.
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
- 38/100