fix: keep one-per-line layout of short multiline __all__ under trailing-comma profiles - #2644
Closed
Manny7717 wants to merge 2 commits into
Closed
fix: keep one-per-line layout of short multiline __all__ under trailing-comma profiles#2644Manny7717 wants to merge 2 commits into
Manny7717 wants to merge 2 commits into
Conversation
…ng-comma profiles --sort-reexports rewrote short multi-line __all__ collections into a single line whenever the sorted result fit within line_length, even under profiles that set include_trailing_comma (e.g. black), dropping the trailing comma and the one-per-line style black itself preserves. Preserve the multi-line form when the source was multi-line and the active config uses trailing commas; single-line sources and default config behavior are unchanged. Closes PyCQA#2578
Author
|
Closing as a duplicate of #2605, which implements the same fix for the same issue (#2578) with the same mechanism — a preserve-trailing-comma flag threaded through the collection sorters, gated on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
--sort-reexportsrewrote a short multi-line__all__(one element per line, trailing comma) into a single line whenever the sorted result happened to fit withinline_length— even under--profile black, dropping the trailing comma and the one-per-line style that black itself preserves. Reported in #2578.Change
isort.literalnow preserves the vertical block form when the original literal was multi-line AND the active config uses trailing commas (include_trailing_comma, set by the black/comma-style profiles). Single-line sources and default-config behavior are unchanged — the pre-existing tests encoding the collapse behavior for the default config still pass.Tests
test_sort_reexports_preserves_short_multiline_all_issue_2578: the issue's repro stays one-per-line and sorted, trailing comma intact. Fails on the previous implementation (verified).test_sort_reexports_keeps_short_single_line_all_issue_2578: single-line__all__is sorted in place and stays single-line.