Fix regression involving dict or on recursive dict#21148
Open
hauntsaninja wants to merge 3 commits intopython:masterfrom
Open
Fix regression involving dict or on recursive dict#21148hauntsaninja wants to merge 3 commits intopython:masterfrom
hauntsaninja wants to merge 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
ilevkivskyi
reviewed
Apr 2, 2026
ilevkivskyi
reviewed
Apr 2, 2026
Member
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.
mypy/constraints.py
Outdated
| 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): |
Member
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.
Collaborator
Author
|
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 |
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #21141
Can probably make this fix better, but it does the job