You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using K = TypeAliasType("K", int) fails here, whereas K: TypeAlias = int does not.
fromtyping_extensionsimportTypeAliasType, TypeVarK=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.
Bug Report, To Reproduce, & Actual Behaviour
Using
K = TypeAliasType("K", int)
fails here, whereasK: TypeAlias = int
does not.Expected Behavior
No issues
Additional information
no_args
isTrue
forK: TypeAlias = int
, while it isFalse
forK = TypeAliasType("K", int)
. A quick test indicates that commenting outand not pep_695
here prevents the error from occurring.mypy/mypy/semanal.py
Lines 4048 to 4058 in 4fb187f
The effect of
no_args = False
causes the constraints ofKeyT
to be evaluated as aTypeAliasType
instead of being evaluated to anInstance
,mypy/mypy/typeanal.py
Lines 2199 to 2205 in 4fb187f
which then later causes the equality check
p_default == value
to fail:mypy/mypy/checkexpr.py
Lines 6203 to 6204 in 4fb187f
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: