-
-
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
Allow comparisons to refine Optional types without strict-optional #4523
Conversation
(Let's hold off on this a bit, we've discovered some problems with it in our own codebase.) |
Please let me know when the problems are solved, so that I can proceed with a review. |
IIUC that's in @msullivan's court. |
Before this can land, we need to fix #3526, since this change exposes a bunch of instances of it. |
The bad news is that I went and fixed #3526 and it turns out that wasn't actually what was causing trouble internally. |
e6f7fec
to
42e28ac
Compare
@ilevkivskyi this is ready for review now |
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.
Looks good to me! I have one unrelated suggestion.
mypy/binder.py
Outdated
@@ -271,11 +271,10 @@ def assign_type(self, expr: Expression, | |||
and not restrict_any): |
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.
This doesn't need to be on a separate line.
This causes a small handful of errors in internal codebases that will be easy to fix. A couple were weird second-order effects in which doing the refinement meant that a type was no longer a Union and so behaved differently when computing types in a ternary expression. Sigh. |
Fixes #4520.