Skip to content

Invalid type revealed when type var uses another type var as default #20027

Description

@sobolevn
fromtypingimportTypeVar, GenericX=TypeVar('X')
Y=TypeVar('Y', default=X)
Z=TypeVar('Z', default=Y)
classA(Generic[X, Y, Z]):
x: Xy: Yz: Za1: A[int]
reveal_type(a1.x) # N: Revealed type is "builtins.int"reveal_type(a1.y) # N: Revealed type is "builtins.int"reveal_type(a1.z) # N: Revealed type is "X`1"

a1.z must be revealed as int as well, not as X'1

Refs #20021

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions