Skip to content

Conversation

A5rocks
Copy link
Collaborator

@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:

@A5rocks
Copy link
Collaborator 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.

This comment has been minimized.

@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 🎉

@A5rocks
Copy link
Collaborator Author

A5rocks commented Sep 27, 2024

I split off #17843 for the part of this PR I am certain is correct. I have some ideas on how to fix kwargs's presence with TypeVarTuple in the general case that I want to try out.

Turns out I can't split anything off because the two fixes need each other for any visible effect.

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 Mar 31, 2025

Would be lovely to get this merged, but it appears we've gotten merge conflicts that need resolved @A5rocks

@A5rocks
Copy link
Collaborator Author

A5rocks commented Apr 23, 2025

I've made a better version of this at #18958

@A5rocks A5rocks closed this Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants