Experiment with intersection on TypeVars#15712
Closed
A5rocks wants to merge 4 commits intopython:masterfrom
Closed
Experiment with intersection on TypeVars#15712A5rocks wants to merge 4 commits intopython:masterfrom
A5rocks wants to merge 4 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
|
I think the only (wow, that's surprising) error is genuine. I guess I'll actually flesh out this PR, weird. |
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/datastructures/structures.pyi:137: error: Overloaded function signatures 2 and 3 overlap with incompatible return types [misc]
|
Collaborator
Author
|
I don't understand the test failures. I can't reproduce them either on Linux or Windows. |
A5rocks
commented
Aug 5, 2023
Collaborator
Author
A5rocks
left a comment
There was a problem hiding this comment.
Comments for when I'm not on mobile
Comment on lines
+685
to
+687
| # this may be alright on things other than just instances | ||
| elif isinstance(self.s, (Instance, NoneType, TupleType)): | ||
| return t.copy_modified(upper_bound=meet_types(t.upper_bound, self.s)) |
Collaborator
Author
There was a problem hiding this comment.
Note to self: there's probably a "is concrete type" utility somewhere in mypy. Maybe in checking for subtypes of type.
| elif isinstance(self.s, LiteralType): | ||
| return meet_types(t, self.s) | ||
| elif isinstance(self.s, TypedDictType): | ||
| elif isinstance(self.s, (TypeType, TupleType, LiteralType, TypedDictType, TypeVarType)): |
Collaborator
Author
There was a problem hiding this comment.
Note to self: check every visit method to make sure typevars are getting passed through.
Collaborator
Author
|
Maybe I'll look at this more some day. |
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.
While working on #15711 and reflecting, I had a thought about how the upper bound on
Tis essentially an intersection:Twith an upper bound ofintis kinda somewhatT & int.This means
T & int & <something>is essentiallyT & (int & <something>). I implemented this, I want to see how mypy primer looks.