Uh oh!
There was an error while loading. Please reload this page.
Fix regression involving dict or on recursive dict - #21148
Conversation
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
ilevkivskyi
left a comment
There was a problem hiding this comment.
TBH I don't like this. This adds an even hackier hack on top of an existing hack.
Also maybe I am missing some context, but when was the last time some change was made in typeshed to accommodate mypy? Because what I constantly see is the opposite, we are adding some hacks and workarounds, because someone else wants to make changes in typeshed.
| UnionType.make_union(non_type_var_items), actual, direction | ||
| ) or infer_constraints(UnionType.make_union(type_var_items), actual, direction) | ||
| ret = infer_constraints(UnionType.make_union(non_type_var_items), actual, direction) | ||
| if ret or any(mypy.subtypes.is_subtype(t, actual) for t in non_type_var_items): |
There was a problem hiding this comment.
Using is_subtype() independently of direction is suspicious.
This comment has been minimized.
This comment has been minimized.
hauntsaninja
commented
Apr 2, 2026
It's still pretty common for typeshed to do things because of mypy or to not even land changes in the first place that affect mypy output |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
randolf-scholz
commented
Apr 7, 2026
Regarding In fact, it seems that then and there the decision was made to instead of fixing this properly, to just add some overloads in typeshed:
But the presence of these overloads lead to downstream problems:
The best solution would be to fix #3933 / #5874, then I believe these hacks would no longer be necessary. I spend a whole lot of time/effort last year to make a patch (randolf-scholz#4), but I could never quite satisfy the whole test suite, and it appears that there are more underlying issues with mypy that need to be fixed first, such as bugs in |
Fixes#21141
Can probably make this fix better, but it does the job