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

Fix special cases of kwargs + TypeVarTuple #17512

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

A5rocks
Copy link
Contributor

@A5rocks A5rocks commented Jul 10, 2024

Fixes #16522. This PR adds special casing for TypeVarTuple inference in the face of kwargs, though I believe the general case requires providing multiple possible constraints (e.g. "constraint a OR constraint b OR constraint C") which either isn't possible or I don't know how to.

This PR also fixes the subtyping of e.g. def f(a: int) -> None being a subtype of def g(*args: Unpack[tuple[Any, ...]]).

TODO:

mypy/test/testtypes.py Outdated Show resolved Hide resolved
@A5rocks
Copy link
Contributor Author

A5rocks commented Jul 10, 2024

cc @ilevkivskyi since I saw your changes w/r/t typevartuples when glancing over the merge conflicts. Maybe you'll have an idea of whether this Any-tuple thing is worth anything.

@A5rocks A5rocks changed the title Introduce Any-tuple and Introduce Any-tuple and special cases of kwargs + TypeVarTuple Jul 10, 2024

This comment has been minimized.

This comment has been minimized.

@A5rocks A5rocks changed the title Introduce Any-tuple and special cases of kwargs + TypeVarTuple Fix special cases of kwargs + TypeVarTuple Aug 27, 2024

This comment has been minimized.

Copy link
Contributor

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

@jakkdl
Copy link

jakkdl commented Sep 17, 2024

With the simplification from removing Any-tuple this looks pretty damn clean. With no diff from mypy_primer I think we only need new tests and then it's pretty much ready to merge 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants