Describe the bug
Pyright does not seem to respect type-annotations defined by custom __class_getitem__ implementations.
It assumes the getitem will return the associated class type regardless of the annotations present.
Code or Screenshots
from typing import Annotated, TypeVar, cast, reveal_type
T = TypeVar('T')
class Foo:
@classmethod
def __class_getitem__(cls, type: T) -> T:
return cast(T, Annotated[type, cls()])
foo = Foo[str]
reveal_type(foo) # Type of "foo" is "type[Foo]"
In the example above the type should report as str.
VS Code extension or command-line
This issue exists both in LSP and with the latest version of the pyright command-line v1.1.411
Describe the bug
Pyright does not seem to respect type-annotations defined by custom
__class_getitem__implementations.It assumes the getitem will return the associated class type regardless of the annotations present.
Code or Screenshots
In the example above the type should report as
str.VS Code extension or command-line
This issue exists both in LSP and with the latest version of the pyright command-line
v1.1.411