Fix multi_line_output=3/5 ignored when wrapping single imports with inline comments#2474
Merged
Merged
Conversation
Co-authored-by: DanielNoord <13665637+DanielNoord@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix multi line output ignored when wrapping with comment
Fix multi_line_output=3/5 ignored when wrapping single imports with inline comments
Mar 10, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2474 +/- ##
=======================================
Coverage 99.18% 99.19%
=======================================
Files 40 40
Lines 3086 3088 +2
Branches 672 672
=======================================
+ Hits 3061 3063 +2
Misses 14 14
Partials 11 11 🚀 New features to boost your workflow:
|
DanielNoord
approved these changes
Mar 12, 2026
…x-multi-line-output-handling
auto-merge was automatically disabled
March 12, 2026 22:34
Head branch was pushed to by a user without write access
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.
When a single import line with an inline comment exceeded
line_length,wrap.line()fell through to backslash continuation regardless ofmulti_line_outputmode, because the parentheses-vs-backslash decision was gated solely onconfig.use_parentheses(defaultFalse).Root cause: VERTICAL_HANGING_INDENT (mode 3) and VERTICAL_GRID_GROUPED (mode 5) are inherently parenthesis-based, but
wrap.line()only respected that whenuse_parentheses=Truewas explicitly set.Changes:
isort/wrap.py— Introduced_is_vertical_modeto identify modes 3/5, and_hoist_comment_to_parento unify the logic for placing a comment on the opening paren line. Whenuse_parentheses=Falsebut a vertical mode is active, comments are now hoisted to the opening paren and parentheses replace the backslash.tests/unit/test_ticketed_features.py— Addedtest_combine_as_with_comments_and_vertical_hang_2316.Existing behavior is unchanged when
use_parentheses=True(e.g. theblackprofile).Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.