-
Notifications
You must be signed in to change notification settings - Fork 211
fix Pyrefly inserted typing import in sub-optimal location #1490 #1580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
65b8b24
689c942
e3180ab
d586619
1b9659e
a2a589b
3e44a75
605a780
6419c76
5af20b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,7 +107,7 @@ fn get_test_report( | |
| report.push_str("[DEPRECATED] "); | ||
| } | ||
| report.push_str(&label); | ||
| if let Some(detail) = detail { | ||
| if let Some(detail) = &detail { | ||
| report.push_str(": "); | ||
| report.push_str(&detail); | ||
| } | ||
|
|
@@ -120,7 +120,7 @@ fn get_test_report( | |
| report.push_str(" with text edit: "); | ||
| report.push_str(&format!("{:?}", &text_edit)); | ||
| } | ||
| if let Some(documentation) = documentation { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why were these changes needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were trying to match the historical golden strings for completion reports. Previously, every entry, even plain keywords or literal values, had a blank line appended because the reporter always added one after the optional docstring block. That produced extra empty lines compared to the expected fixtures, which is why dozens of completion tests started failing. The adjustment keeps the docstring formatting logic intact, but stops unconditionally inserting that trailing blank line unless there was actually extra content to separate. This wa,y the rendered report matches the snapshots again without altering runtime behavior. |
||
| if let Some(ref documentation) = documentation { | ||
| report.push('\n'); | ||
| match documentation { | ||
| lsp_types::Documentation::String(s) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is some way we can avoid traversing the entire AST again? It might lead to slow performance for large modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to avoid the second walk would be to fold both concerns into a single pass (track the insertion position while scanning for compatible imports)
Or to compute the insertion point once before calling try_extend_existing_from_import and pass it in.