Repository navigation
Conversation
Manny7717
left a comment
There was a problem hiding this comment.
Verified locally on head 3a04399 (Py3.14, repo venv) against base 131f4ad.
Bug confirmed on base — brute-force across 112 shapes (combine_as_imports × force_single_line / remove_redundant_aliases / multi_line_output / include_trailing_comma / force_grid_wrap × single/multi-alias, plain-import aliases, submodules, mixed alias+plain): 87 shapes drop the trailing comment on base, including the exact issue #2094 scenario (all three comment types lost on the aliased lines).
Head behavior: comments preserved in 109/112 shapes. The 3 remaining "losses" are duplicate-comment collapse when two IDENTICAL comments (# C + # C) merge onto one combined line — identical on base, not a regression. Two DIFFERENT comments merge correctly (# C1; C2), a single comment on either alias survives the combine, and force_single_line keeps one comment per alias line.
Regression test is revert-proven: copied the PR's test into the base worktree → fails (assertion 2: from some_module import the_function as some_function loses # type: ignore); passes on head. Second-pass idempotency asserted by the test and verified manually on all probe shapes.
No regressions: full unit suite head 624 passed / 2 failed vs base 623 passed / 2 failed — identical failure set (pre-existing FileNotFoundError env noise issue_909/938), +1 = the new test.
Mechanism review: parse.py now keys alias comments per-base in straight["<module>.<base>"] (previously a single from["<module>"].__combined_as__ bucket); output.py pops per-base in both the force_single_line and combined paths, and the removed nested_module = None line had no remaining readers (grep-verified). The # C1; C2 join is the existing with_comments separator behavior, not new logic. Non-alias comments (straight imports, non-aliased from-imports) and import m as x # C plain-import aliases are byte-identical to base.
Clean minimal fix; APPROVE.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2648 +/- ##
=======================================
Coverage 99.44% 99.44%
=======================================
Files 41 41
Lines 3217 3233 +16
Branches 691 695 +4
=======================================
+ Hits 3199 3215 +16
Misses 11 11
Partials 7 7 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Alias comments share a non-unique key, causing comments to merge or disappear for multiple aliases of the same import.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
What changed in this PR
Preserves trailing comments on aliased imports when combining aliases into single-line imports.
Changes:
- Stores and retrieves comments for combined aliases.
- Adds regression and idempotence coverage for issue #2094.
| File | Description |
|---|---|
isort/parse.py |
Changes alias-comment categorization. |
isort/output.py |
Restores comments when rendering aliases. |
tests/unit/test_regressions.py |
Adds regression tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Two comment-routing paths can misassign or duplicate comments between imports.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (1)
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Opening-line comments can move onto an attribute when the same symbol has multiple aliases.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Resolved since last review (1)
|
Closing due to inactivity of the AI bot. |
|
Wait I’m still interested in working on this. I was away for a while, but I’d like to pick this back up. |

asimports withcombine_as_imports = trueandforce_single_line = true#2094Trailing comment removed from
asimports withcombine_as_imports = trueandforce_single_line = true.