Avoid printing continuations within import identifiers#7744
Merged
charliermarsh merged 1 commit intomainfrom Oct 2, 2023
Merged
Avoid printing continuations within import identifiers#7744charliermarsh merged 1 commit intomainfrom
charliermarsh merged 1 commit intomainfrom
Conversation
b7d6769 to
a307da9
Compare
CodSpeed Performance ReportMerging #7744 will improve performances by 2.02%Comparing Summary
Benchmarks breakdown
|
konstin
approved these changes
Oct 2, 2023
Member
konstin
left a comment
There was a problem hiding this comment.
I think that fundamentally that is bug in our AST: Indentifiers in python can not contain dots, and import foo.bar consists of two dot-separated keywords, not one.
I think we should merge this fix and then solve this properly with #7760
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
It turns out that some identifiers can contain newlines -- specifically, dot-delimited import identifiers, like:
At present, we print all identifiers verbatim, which causes us to retain the
\in the formatted output. This also leads to violating some debug assertions (see the linked issue, though that's a symptom of this formatting failure).This PR adds detection for import identifiers that contain newlines, and formats them via
text(slow) rather thansource_code_slice(fast) in those cases.Closes #7734.
Test Plan
cargo test