Description
Bug Report, To Reproduce, & Expected Behaviour
An error occurs when defining a constrained type variable where the default is a TypedDict
type. See mypy Playground:
import typing as t
class A(t.TypedDict):
a: int
T = t.TypeVar("T", int, A, default=A) # E: TypeVar default must be one of the constraint types [misc]
class C(t.Generic[T]): ...
# Using the type variable still correctly gets its default
reveal_type(C()) # OK: C[TypedDict("A", {"a": int})]
Expected Behavior
No errors
Your Environment
- Mypy version used: 1.10.1, 1.11.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.10, 3.12