Skip to content

[ty] Show type alias value on hover#25381

Merged
MichaReiser merged 21 commits into
astral-sh:mainfrom
pierrem964:pgm/show-type-alias-on-hover
Jun 4, 2026
Merged

[ty] Show type alias value on hover#25381
MichaReiser merged 21 commits into
astral-sh:mainfrom
pierrem964:pgm/show-type-alias-on-hover

Conversation

@pierrem964

@pierrem964 pierrem964 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds more detail to hovering PEP695 type definitions
image

Closes astral-sh/ty#1477

I did not manage to get implicit type aliases working here, I had trouble figuring out how to differentiate a type alias from any other static class, e.g

U = int

class Test:
    a: int # `inferred_type` gives nominal instance
    
class Test:
   a: U # `inferred_type` also gives nominal instance

Nor did I exactly follow suite with the hover format for class variable annotations, as I had trouble with differentiating a class variable/field (a: U should hover as a: U (int)) to an actual assignment expression (A = U). Any help with these issues would be much appreciated 😄

Test Plan

I added unit tests and tested manually

@astral-sh-bot astral-sh-bot Bot added server Related to the LSP server ty Multi-file analysis & type inference labels May 25, 2026
@MichaReiser MichaReiser changed the title [Ty] Show type alias value on hover [ty] Show type alias value on hover May 28, 2026

@MichaReiser MichaReiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm still looking into how to handle legacy type aliases, but here some initial feedback.

Comment thread crates/ty_ide/src/hover.rs Outdated
Comment thread crates/ty_ide/src/hover.rs Outdated
Comment thread crates/ty_ide/src/hover.rs
Comment thread crates/ty_ide/src/hover.rs Outdated
Comment thread crates/ty_ide/src/hover.rs Outdated
@MichaReiser

Copy link
Copy Markdown
Member

After some discussion, I think we should skip support for legacy implicit type aliases for now, as there's no easy way in our model to detect those

@pierrem964 pierrem964 requested a review from MichaReiser May 30, 2026 04:03
Comment thread crates/ty_ide/src/hover.rs
Comment thread crates/ty_ide/src/hover.rs Outdated
Comment thread crates/ty_ide/src/hover.rs Outdated
@carljm carljm removed their request for review June 1, 2026 19:24
@pierrem964 pierrem964 requested a review from ibraheemdev as a code owner June 3, 2026 09:49
@astral-sh-bot

astral-sh-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 92.13%. The percentage of expected errors that received a diagnostic held steady at 87.18%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@pierrem964 pierrem964 requested a review from MichaReiser June 3, 2026 19:12

@MichaReiser MichaReiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great. Thank you

@MichaReiser MichaReiser enabled auto-merge (squash) June 4, 2026 07:40
@MichaReiser MichaReiser merged commit 49493a3 into astral-sh:main Jun 4, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server Related to the LSP server ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show the type alias's name on hover

2 participants