Description
Bug Report, To Reproduce, & Actual Behaviour
Using K = TypeAliasType("K", int)
fails here, whereas K: TypeAlias = int
does not.
from typing_extensions import TypeAliasType, TypeVar
K = TypeAliasType("K", int)
KeyT = TypeVar("KeyT", str, K, default=K) # E: TypeVar default must be one of the constraint types [misc]
Expected Behavior
No issues
Additional information
no_args
is True
for K: TypeAlias = int
, while it is False
for K = TypeAliasType("K", int)
. A quick test indicates that commenting out and not pep_695
here prevents the error from occurring.
Lines 4048 to 4058 in 4fb187f
The effect of no_args = False
causes the constraints of KeyT
to be evaluated as a TypeAliasType
instead of being evaluated to an Instance
,
Lines 2199 to 2205 in 4fb187f
which then later causes the equality check p_default == value
to fail:
Lines 6203 to 6204 in 4fb187f
Your Environment
- Mypy version used: 1.15, master
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.9, 3.13