Skip to content

The default type set to *Ts for the generic type alias TA doesn't work even though no type arguments are set to TA #20449

Description

@hyperkai

*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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-646PEP 646 (TypeVarTuple, Unpack)topic-pep-696TypeVar defaultstopic-type-aliasTypeAlias and other type alias issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions