impl Completions: Import suggestions for explicit re-exports. #2207#2416
impl Completions: Import suggestions for explicit re-exports. #2207#2416asukaminato0721 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.
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
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.