*Memo:
mypy --strict test.py
mypy 1.19.1
Python 3.14.0
Windows 11
The default type set to *Ts for the generic type alias TA doesn't work even though no type arguments are set to TA as shown below:
<New way>:
from collections.abc import Callable
type TA[*Ts=*tuple[int, int]] = Callable[[*Ts], None]
lam = lambda *args: print(args)
# ↓↓ With no type arguments, the default type doesn't work
v: TA = lam
v(*(0, 1)) # No error
v(*('A', 'B', 'C', 'D')) # No error
v(*(None, None, None, None)) # No error
<Old way>:
from typing import TypeVarTuple
from collections.abc import Callable
Ts = TypeVarTuple('Ts', default=Unpack[tuple[int, int]])
TA: TypeAlias = Callable[[Unpack[Ts]], None]
lam = lambda *args: print(args)
# ↓↓ With no type arguments, the default type doesn't work
v: TA = lam
v(*(0, 1)) # No error
v(*('A', 'B', 'C', 'D')) # No error
v(*(None, None, None, None)) # No error
*Memo:
mypy --strict test.py
mypy 1.19.1
Python 3.14.0
Windows 11
The default type set to
*Tsfor the generic type aliasTAdoesn't work even though no type arguments are set toTAas shown below:<New way>:
<Old way>: