Skip to content

[ty] Add support for goto in literal enum member inlay hint#24792

Open
MatthewMckee4 wants to merge 4 commits intoastral-sh:mainfrom
MatthewMckee4:enum-inlay-hint-goto
Open

[ty] Add support for goto in literal enum member inlay hint#24792
MatthewMckee4 wants to merge 4 commits intoastral-sh:mainfrom
MatthewMckee4:enum-inlay-hint-goto

Conversation

@MatthewMckee4
Copy link
Copy Markdown
Contributor

Summary

The goal of this change was to add support for goto on the literal enum member in inlay hints, this led me to adding a new TypeDefinition. I do believe this is the right approach, but perhaps we could go for something simpler

Test Plan

ty_ide test

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Apr 22, 2026
| Self::BoundSuper(_) => self.to_meta_type(db).definition(db),

Self::TypeVar(bound_typevar) => Some(TypeDefinition::TypeVar(bound_typevar.typevar(db).definition(db)?)),
Self::TypeVar(bound_typevar) => Some(TypeDefinition::TypeVar(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't know why this formatting isn't failing on main

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 22, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 22, 2026

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 22, 2026

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@MichaReiser
Copy link
Copy Markdown
Member

The PR itself looks good to me. Thanks for implementing it. Unfortunately, it does make a pre-existing issue more prominent:

from test import Color

x = Color.RED

test.py:

from enum import Enum

class Color(Enum):
    RED = 1
    BLUE = 2

Applying the inlay adds from test import Color, RED, which is incorrect.

I'm inclined to merge this PR, given that it's a pre-existing issue. However, this becomes a much more prominent problem with enums. Which is why I'd prefer if we try to fix astral-sh/ty#3313 first, if it's not too hard.

@MatthewMckee4
Copy link
Copy Markdown
Contributor Author

MatthewMckee4 commented Apr 22, 2026

I label this as invalid syntax, which would disable the edit, so we wouldn't have this issue.

edit: I see that this is not this simple, we need to test like reachability from global scope or something

@MatthewMckee4
Copy link
Copy Markdown
Contributor Author

MatthewMckee4 commented Apr 22, 2026

Ill fix in a separate PR

@MatthewMckee4 MatthewMckee4 changed the title Add support for goto in literal enum member inlay hint [ty] Add support for goto in literal enum member inlay hint Apr 22, 2026
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.

4 participants