Preserve end-of-line comments on import-from statements#6216
Merged
charliermarsh merged 1 commit intomainfrom Aug 1, 2023
Merged
Preserve end-of-line comments on import-from statements#6216charliermarsh merged 1 commit intomainfrom
charliermarsh merged 1 commit intomainfrom
Conversation
3b16233 to
af04b20
Compare
Member
Author
|
We can probably generalize some of this for other container types (lists, sets, etc). |
Member
Author
|
(I'm looking into it.) |
Contributor
PR Check ResultsBenchmarkLinuxWindows |
MichaReiser
requested changes
Aug 1, 2023
konstin
reviewed
Aug 1, 2023
bd8f7dd to
c5732e8
Compare
Member
Author
|
Okay, hopefully good to go. |
MichaReiser
approved these changes
Aug 1, 2023
Comment on lines
+1141
to
+1143
| let mut tokens = | ||
| SimpleTokenizer::up_to_without_back_comment(comment.start(), locator.contents()) | ||
| .skip_trivia(); |
Member
There was a problem hiding this comment.
Nit: I would love to remove the backward lexing if possible in the future. It kind of works, but I'm worried that we'll run into issues sooner or later (e.g. magic commands are interesting...) . Could we instead search forward from the end of the identifier (or the start of the statement if absent)?
Member
Author
There was a problem hiding this comment.
I think I figured out a solution that doesn't require lexing. If the comment is end-of-line, and between the start of the statement and the first member, it has to be immediately following the parenthesis.
c5732e8 to
2ebf7b2
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
Ensures that we keep comments at the end-of-line in cases like:
Closes #6067.