Skip to content

[2.0 regression] TypeVar with constrains Sub and Super does not accept Sub as a default value #21424

@hauntsaninja

Description

@hauntsaninja
λ cat test.py   
from typing import TypeVar
T = TypeVar("T", int, float)
def f(x: T = 0): ...
λ mypy test.py --no-incremental                       
test.py:3: error: Incompatible default for parameter "x" (default has type "int", parameter has type "T")  [assignment]
Found 1 error in 1 file (checked 1 source file)

Bisects to #21119

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions