Skip to content

Emit semicolon-introducing continuations unchanged - #2664

Open
SemTiOne wants to merge 6 commits into
PyCQA:mainfrom
SemTiOne:issue/1918
Open

SemTiOne wants to merge 6 commits into
PyCQA:mainfrom
SemTiOne:issue/1918

Conversation

@SemTiOne

@SemTiOne SemTiOne commented Sep 22, 2026 •

Copy link
Copy Markdown

Closes #1918.

Supersedes #2508.

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.44%. Comparing base (f00e091) to head (08334a0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2664   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files          41       41           
  Lines        3222     3228    +6     
  Branches      692      694    +2     
=======================================
+ Hits         3204     3210    +6     
  Misses         11       11           
  Partials        7        7           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The continuation must not be parsed for names; the lines go out unchanged.
See: https://github.com/PyCQA/isort/issues/1918
"""
source = "from os import \\\n name; print(name)\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"from os import name\nprint(name)\n"

Wouldn't it make more sense if this was the new output after running isort on this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but skip_line() preserves the single-line equivalent, so normalizing only the multi-line form would make equivalent statements behave differently. I think that needs a broader behavior decision covering both forms.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the options for this decision?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Preserve both forms unchanged (what this PR does). This keeps the existing skip_line() behavior for the single-line form and fixes only the corruption.
  2. Normalize both forms into separate import and non-import statements. Cleaner output, but changes existing single-line behavior and broadens the scope.
  3. Keep Input with semicolon after multi-line import is corrupted #1918 narrow and track normalization separately. This lets us decide the single-line and multi-line behavior together in a follow-up.

I’d go with 3. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just create a stacked PR on top of this? I like to keep this narrow, but I think it is also good to see final impact.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this? SemTiOne#1

This branch has not been deployed

No deployments
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.

Input with semicolon after multi-line import is corrupted

2 participants