Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Report error when type alias has multiple TypeVarTuples (PEP 695) #20554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aviralgarg05 wants to merge 4 commits into python:master
base: master
Choose a base branch
Loading
from aviralgarg05:fix-issue-20544-multiple-typevartuple-in-type-alias

Conversation

@aviralgarg05
Copy link

@aviralgarg05 aviralgarg05 commented Jan 9, 2026

Report error when type alias has multiple TypeVarTuples (PEP 695)

When defining a type alias using the PEP 695 syntax with multiple TypeVarTuple-based type parameters (e.g., type TA[*Ts1, *Ts2] = ...), mypy now reports an error at definition time rather than only when the alias is used.

This is consistent with how mypy handles classes with multiple TypeVarTuples and matches the behavior of other type checkers like pyright and pyrefly.

Fixes #20544.

When defining a type alias using the PEP 695 syntax with multiple
TypeVarTuple-based type parameters (e.g., `type TA[*Ts1, *Ts2] = ...`),
mypy now reports an error at definition time rather than only when
the alias is used.
This is consistent with how mypy handles classes with multiple
TypeVarTuples and matches the behavior of other type checkers like
pyright and pyrefly.
Fixes python#20544.

This comment has been minimized.

Copy link
Collaborator

A5rocks commented Jan 13, 2026

Could you support old-style type aliases too? The linked issue has that too, simply uncomment it.

This comment has been minimized.

Copy link
Collaborator

A5rocks commented Jan 13, 2026

CI failures look like it's because testVariadicAliasMultipleUnpacks's output changed. I think the new output is more accurate (there's two issues: 1) the alias requires 2 typevartuples to use, 2) the type has 2 Unpacks within. Therefore reporting 2 errors is good, actually).

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@A5rocks A5rocks A5rocks left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

mypy should give error at the timing when the type alias set multiple TypeVarTuple-based type parameters is defined but not used

AltStyle によって変換されたページ (->オリジナル) /