Preserve trailing-comma layout when sorting reexports - #2605
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2605 +/- ##
==========================================
- Coverage 99.43% 99.36% -0.07%
==========================================
Files 41 41
Lines 3159 3168 +9
Branches 685 687 +2
==========================================
+ Hits 3141 3148 +7
- Misses 11 12 +1
- Partials 7 8 +1 🚀 New features to boost your workflow:
|
DanielNoord
left a comment
There was a problem hiding this comment.
Do you think you can get full coverage on this? I have not looked at the code yet but we prefer all new code to be covered by tests :)
4fda57b to
04780d4
Compare
|
Thanks for the review. I updated the PR to add coverage for the new literal formatting paths, including the formatting-function branch and the trailing-comma detection guard. I also reran |
Summary
Preserve explicitly multiline
__all__collections with trailing commas when--sort-reexportsruns under trailing-comma-aware formatting such as the Black profile.Why this helps
This keeps sorted reexports stable with Black's magic trailing comma behavior, so short
__all__declarations that are intentionally one item per line are not collapsed after sorting.Changes made
__all__exports.Testing
uv run pytest tests/unit/test_regressions.py -k '2578 or 2280'uv run pytest tests/unit/test_isort.py -k 'reexport_multiline'uv run ruff format --check isort/literal.py tests/unit/test_regressions.pyuv run ruff check isort/literal.py tests/unit/test_regressions.pyuv run mypy isort tests./scripts/done.shCloses #2578