SIGN IN SIGN UP
astral-sh / ruff UNCLAIMED

An extremely fast Python linter and code formatter, written in Rust.

0 0 40 Rust

[ty] Show `LiteralString` when hovering the inline of a literal string (#25373)

## Summary

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

```py
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 https://github.com/astral-sh/ruff/pull/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`

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

Closes https://github.com/astral-sh/ty/issues/2860

## Test Plan

Updated test
M
Micha Reiser committed
6a3bc5b6bab7af992fa02638b8623cb0edd58e13
Parent: 73de9b4
Committed by GitHub <noreply@github.com> on 5/26/2026, 7:34:54 AM