-
Notifications
You must be signed in to change notification settings - Fork 244
fix Auto import suggestions for collections.abc should take precedence over typing #1685 #1949
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
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 |
|---|---|---|
|
|
@@ -1809,6 +1809,41 @@ Completion Results: | |
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn autoimport_prefers_public_reexport_for_dotted_private_module() { | ||
| let code = r#" | ||
| T = Thing | ||
| # ^ | ||
| "#; | ||
| let report = get_batched_lsp_operations_report_allow_error( | ||
| &[ | ||
| ("main", code), | ||
| ("_foo_bar", "Thing = 1\n"), | ||
| ("foo.bar", "from _foo_bar import Thing\n"), | ||
| ], | ||
| get_test_report(Default::default(), ImportFormat::Absolute), | ||
| ); | ||
| assert_eq!( | ||
| r#" | ||
| # main.py | ||
| 2 | T = Thing | ||
| ^ | ||
| Completion Results: | ||
| - (Variable) Thing: from foo.bar import Thing | ||
|
|
||
| - (Variable) Thing: from _foo_bar import Thing | ||
|
|
||
|
|
||
|
|
||
| # _foo_bar.py | ||
|
|
||
| # foo.bar.py | ||
| "# | ||
| .trim(), | ||
| report.trim(), | ||
| ); | ||
| } | ||
|
Comment on lines
+1812
to
+1845
|
||
|
|
||
| #[test] | ||
| fn autoimport_completions_set_label_details() { | ||
| let code = r#" | ||
|
|
||
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.
The logic for matching dotted-name private shims may produce false positives. It checks if the canonical module starts with '_' and the original contains '.', then compares by replacing dots with underscores. However, this could incorrectly match unrelated modules. For example,
_foo_barwould match bothfoo.barandfoo_bar(a non-dotted module).Consider adding more stringent checks, such as verifying that the canonical module is a top-level module (no dots in canonical_module), or using a more precise pattern matching approach to avoid false positives.