Preserve trailing inline comments on import-from statements#12498
Merged
charliermarsh merged 1 commit intomainfrom Jul 25, 2024
Merged
Preserve trailing inline comments on import-from statements#12498charliermarsh merged 1 commit intomainfrom
charliermarsh merged 1 commit intomainfrom
Conversation
7100ca0 to
6d9d4bc
Compare
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PYI052 | 9 | 0 | 9 | 0 | 0 |
| PLW0642 | 8 | 8 | 0 | 0 | 0 |
charliermarsh
commented
Jul 25, 2024
| 18 18 | MyClient, | ||
| 19 |- MyMgmtClient, | ||
| 20 |- # some comment | ||
| 19 |+ MyMgmtClient, # some comment |
Member
Author
There was a problem hiding this comment.
Gonna fix this before merging (the comment should stay on its own line).
86fe6f9 to
0c98f14
Compare
0c98f14 to
2ddf82b
Compare
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.
Summary
Right now, in the isort comment model, there's nowhere for trailing comments on the statement to go, as in:
If the comment is on the alias, we do preserve it, because we attach it to the alias, as in:
Similarly, if the comment is trailing on an import statement (non-
from), we again attach it to the alias, because it can't be parenthesized, as in:This PR adds logic to track and preserve those trailing comments.
We also no longer drop several other comments, like:
Closes #12487.