Skip to content

fix doesn't understand usage of inline Annotated function parameters #2531#3019

Open
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:2531
Open

fix doesn't understand usage of inline Annotated function parameters #2531#3019
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:2531

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

@asukaminato0721 asukaminato0721 commented Apr 5, 2026

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

@meta-cla meta-cla bot added the cla signed label Apr 5, 2026
@github-actions github-actions bot added the size/m label Apr 5, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review April 5, 2026 14:43
Copilot AI review requested due to automatic review settings April 5, 2026 14:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Annotated metadata 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doesn't understand usage of inline Annotated function parameters

2 participants