impl Completions: Import suggestions for explicit re-exports. #2207#2416
Open
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Open
impl Completions: Import suggestions for explicit re-exports. #2207#2416asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
There was a problem hiding this comment.
Pull request overview
Improves Pyrefly’s auto-import completion results so that when a symbol is explicitly re-exported (e.g. from source import Thing as Thing), completions can suggest importing from the re-exporting “public” module rather than only from the canonical/original module. This supports the IDE feature tracker item “Completions: Import suggestions for explicit re-exports” (#2207).
Changes:
- Add export-metadata plumbing so export searches can detect whether a name is an explicit re-export.
- Include explicit re-export module paths in
search_exports_exact/search_exports_fuzzyresults (for user-owned modules). - Add an LSP completion test covering the explicit re-export auto-import suggestion.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyrefly/lib/test/lsp/completion.rs |
Adds regression test asserting auto-import prefers the explicit re-export path in completion results. |
pyrefly/lib/state/state.rs |
Extends search_exports callback signature to provide Exports metadata alongside computed export maps. |
pyrefly/lib/state/lsp.rs |
Uses explicit re-export detection to include re-export handles in export search results for auto-import completions. |
pyrefly/lib/export/exports.rs |
Adds Exports::is_explicit_reexport to identify ImportAsEq-style definitions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Fixes part of #2207
Added explicit re-export detection on exports and used it to surface explicit re-export paths in autoimport/quickfix searches.
Test Plan
Added an autoimport test covering explicit re-export suggestions.