fix doesn't understand usage of inline Annotated function parameters #2531#3019
Open
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
Open
fix doesn't understand usage of inline Annotated function parameters #2531#3019asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a Pyrefly LSP hover gap where symbols used inside inline typing.Annotated[...] metadata (and qualified type aliases used in parameter annotations) could fail to produce hover information due to missing type traces.
Changes:
- Add LSP hover regression tests covering qualified type aliases in annotations and imported
Annotatedmetadata symbols. - Improve attribute go-to-definition by recovering an attribute base type from the identifier when no type trace exists (notably for
Annotated[..., utils.Name]cases). - Improve hover fallback to derive the hovered type from the resolved definition when the use site lacks a type trace.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyrefly/lib/test/lsp/hover.rs |
Adds regression tests for hovering qualified type aliases and imported Annotated metadata symbols. |
pyrefly/lib/state/lsp.rs |
Makes attribute definition lookup resilient to missing type traces by recovering the base type from the identifier at the base range. |
pyrefly/lib/lsp/wasm/hover.rs |
Adds a hover fallback path to compute the hovered type from the resolved definition when the use site has no type trace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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 #2531
teaching hover/definition lookup to recover imported Annotated metadata symbols even when the use site has no type trace.
Attribute definition lookup now falls back to the exact base identifier when utils.
Name inside Annotated[...] lacks a trace, and hover now reuses the resolved definition to recover a displayable type instead of returning None.
Test Plan
add test