Skip to content
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

Support user defined variadic tuple types #15961

Merged
merged 2 commits into from
Aug 26, 2023

Conversation

ilevkivskyi
Copy link
Member

Fixes #15946

Note this actually adds support also for variadic NamedTuples and variadic TypedDicts. Not that anyone requested this, but since generic NamedTuples and generic TypedDicts are supported using the same mechanism (special aliases) as generic tuple types (like class A(Tuple[T, S]): ... in the issue), it looked more risky and arbitrary to _not_support them.

Btw the implementation is simple, but while I was working on this, I accidentally found a problem with my general idea of doing certain type normlaizations in semanal_typeargs.py. The problem is that sometimes we can call get_proper_type() during semantic analysis, so all the code that gets triggered by this (mostly expand_type()) can't really rely on types being normalized. Fortunately, with just few tweaks I manged to make the code mostly robust to such scenarios (TBH there are few possible holes left, but this is getting really complex, I think it is better to release this, and see if people will ever hit such scenarios, then fix accordingly).

@github-actions
Copy link
Contributor

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

@ilevkivskyi ilevkivskyi merged commit efecd59 into python:master Aug 26, 2023
17 checks passed
@ilevkivskyi ilevkivskyi deleted the variadic-named-tuple branch August 26, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with TypeVarTuple
1 participant