Skip to content

Fix non-idempotent black-profile output for name-level import comments - #2729

Closed
Eryx-Z wants to merge 1 commit into
PyCQA:mainfrom
Eryx-Z:fix/2694-nested-comment-idempotent-black
Closed

Eryx-Z wants to merge 1 commit into
PyCQA:mainfrom
Eryx-Z:fix/2694-nested-comment-idempotent-black

Conversation

@Eryx-Z

@Eryx-Z Eryx-Z commented Oct 16, 2026

Copy link
Copy Markdown

Summary

When a from-import name carries an inline comment that does not fit on one line (common with deeply-dotted modules under the black profile), isort split that name onto its own statement. The next run then regrouped remaining names differently, so isort --check rejected isort's own first-pass output.

Keep the name in the grouped import and hoist the comment to the opening parenthesis for vertical wrap modes (and the existing hanging-indent noqa case), matching the stable form isort already converges to.

Fixes #2694.

Test plan

  • New regression test covers the black-profile multi-name case and short-path name-level comments
  • Related ticketed/regression tests still pass

When a from-import name carries an inline comment that does not fit on
one line, keep the name in the grouped import and hoist the comment to
the opening parenthesis for vertical wrap modes. Previously the name
was split onto its own statement and the next run regrouped differently,
so isort --check rejected isort's own first-pass output.

Fixes PyCQA#2694.
@Eryx-Z

Eryx-Z commented Oct 17, 2026

Copy link
Copy Markdown
Author

Closing for now.

@Eryx-Z Eryx-Z closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-idempotent output when an imported name carries an inline comment

1 participant