-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Support or
in isinstance
expressions.
#942
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
Comments
Yes, that would be nice. #947 is related (tuple as the second argument to |
It seems like this can get complex pretty quickly (imagine using tuples inside an I've been toying with converting the expressions to DNF and seeing if we can just do an all-encompassing solution that way but I'm not confident in its correctness since it effectively makes complicated cases just as difficult as simple cases. |
At this point it's okay to add some limitations, such as for
(we'd only recognize the first We can revisit this later, but the complex cases are going to be pretty marginal so it's not worth it to complicate everything because of them. |
In general, if in doubt whether a particular idiom or construct is worth supporting, try to find actual examples of that in some existing projects. If you can't find any (or just find a few isolated examples), it's probably not that important, and there are lot of things that mypy can't deal with that we know to be important (such as every issue tagged with 'priority'). |
Note: This is not the same as python#942. It does address a pattern which occurs at least once in mypy itself though: ``` if res and (not isinstance(res, Instance) or cast(Instance, res).args): ```
Note: This is not the same as #942. It does address a pattern which occurs at least once in mypy itself though: ``` if res and (not isinstance(res, Instance) or cast(Instance, res).args): ```
I saw in some place in mypy something like
We should be able to infer
Union[B, C]
as the type ofx
within this expression.The text was updated successfully, but these errors were encountered: