[ty] More low-hanging fruit for inlay hint goto-definition by AlexWaygood · Pull Request #21548 · astral-sh/ruff (original) (raw)

@AlexWaygood

Gankra

dcreager added a commit that referenced this pull request

Nov 24, 2025

@dcreager

…d-typevar

This was referenced

May 22, 2026

MichaReiser added a commit that referenced this pull request

May 26, 2026

@MichaReiser

#25373)

Summary

Today, ty showed the hover for str when hovering the inlay of a LiteralString type:

from typing import LiteralString
def my_func(x: LiteralString):
    y[: LiteralString] = x
my_func(x="hello")

Hovering the inlay of y ([: LiteralString] is the inlay) showed the hover of str.

We argued in #21548 that str is generally the more useful type in this position. I sort of agree, but I think it's more important that the inlay and the hover show the same type. I also think that it's important that the hover is consistent with when we "bake" the inlay, e.g. hovering LiteralString now also shows LiteralString and not str

from typing import LiteralString
def my_func(x: LiteralString):
    y: LiteralString = x
my_func(x="hello")

Closes astral-sh/ty#2860

Test Plan

Updated test

anishgirianish pushed a commit to anishgirianish/ruff that referenced this pull request

May 28, 2026

@MichaReiser @anishgirianish

astral-sh#25373)

Summary

Today, ty showed the hover for str when hovering the inlay of a LiteralString type:

from typing import LiteralString
def my_func(x: LiteralString):
    y[: LiteralString] = x
my_func(x="hello")

Hovering the inlay of y ([: LiteralString] is the inlay) showed the hover of str.

We argued in astral-sh#21548 that str is generally the more useful type in this position. I sort of agree, but I think it's more important that the inlay and the hover show the same type. I also think that it's important that the hover is consistent with when we "bake" the inlay, e.g. hovering LiteralString now also shows LiteralString and not str

from typing import LiteralString
def my_func(x: LiteralString):
    y: LiteralString = x
my_func(x="hello")

Closes astral-sh/ty#2860

Test Plan

Updated test

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

[ Show hidden characters]({{ revealButtonHref }})