-
-
Notifications
You must be signed in to change notification settings - Fork 3k
For Optional[T] or T
, infer the type T
instead of Optional[T]
.
#1818
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
Conversation
Is there an equivalent example for FWIW this is kind of blocking further explorations of |
|
||
[case testOptionalTypeOrTypePlain] | ||
from typing import Optional | ||
def f(a: Optional[int]) -> int: |
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.
Maybe test or
with both operands optional?
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.
Also, could test left operand with a complex union type such as Union[int, str, None]
.
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.
80056c6
to
690c4d5
Compare
I feel like we shouldn't need this special casing and this should just fall out of the |
Looks like that was actually pretty straightforward to do. Let's consider #1828 instead of this? |
Closing in favor of #1828. |
Cool. Maybe someday I'll understand how this works -- the name (find_isinstance_check()) and the resulting variables (right_map, left_map -- why the transposition?) were all kind of confusing. |
Agree it's all pretty confusing. The function might be be better named |
Fixes #1817, fixes #1733.