-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Experiment with intersection on TypeVars #15712
Experiment with intersection on TypeVars #15712
Conversation
This comment has been minimized.
This comment has been minimized.
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.
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]
|
I don't understand the test failures. I can't reproduce them either on Linux or Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for when I'm not on mobile
# 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: check every visit method to make sure typevars are getting passed through.
Maybe I'll look at this more some day. |
While working on #15711 and reflecting, I had a thought about how the upper bound on
T
is essentially an intersection:T
with an upper bound ofint
is kinda somewhatT & int
.This means
T & int & <something>
is essentiallyT & (int & <something>)
. I implemented this, I want to see how mypy primer looks.