*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>:
fromcollections.abcimportCallable
type TA[*Ts=*tuple[int, int]] =Callable[[*Ts], None]
lam=lambda*args: print(args)
# ↓↓ With no type arguments, the default type doesn't workv: TA=lamv(*(0, 1)) # No errorv(*('A', 'B', 'C', 'D')) # No errorv(*(None, None, None, None)) # No error<Old way>:
fromtypingimportTypeVarTuplefromcollections.abcimportCallableTs=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 workv: TA=lamv(*(0, 1)) # No errorv(*('A', 'B', 'C', 'D')) # No errorv(*(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>: