microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 769 forks source link

Generic type aliases show two inlay hints #6427

Open Jammf opened 1 day ago

Jammf commented 1 day ago

Generic type aliases show two inlay hints that each function independently, with no visual separation between them. I'm not sure if it's just restricted to type aliases with generics, but I first noticed it happening when hints from numpy functions such as np.array(3) would be things like Anyndarray[Any, dtype[Any]]. I tried to reduce it down to a minimal example from there.

Environment data

Code Snippet

from typing import TypeVar

T = TypeVar("T")
type U = list[T]

def func() -> U: ...
a = func()

def func2() -> U[int]: ...
b = func2()

Expected behavior

I'd expect only the second inlay hint to be present, for example a: list and b: list[int].

Actual behavior

(Previous) Behavior in 2024.8.100:

image

(Current) Behavior from 2024.8.101 to 2024.9.101:

image

Logs

XXX
debonte commented 17 hours ago

@StellaHuang95, reassigned to you. Given that this regressed in 2024.8.101, I'm guessing this has something to do with the inlay hint go to def feature.