-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Error when assigning a ternary with an empty collection to a union type variable #7780
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
Please, take a look at this topic. Perhaps mypy should consider an empty list like an object that fits
|
I worked around this issue by getting rid of the ternary condition and using a regular if statement instead. |
Another possible workaround could be using a covariant collection like |
This actually may be not hard to fix, one just needs to update the logic in |
Hello,
the following code:
incorrectly generates the following error:
Adding an integer in the list makes the error disappear. I first observed this issue with a dictionary:
Error:
It seems
<nothing>
should be matched with any type in type parameters in unions.The text was updated successfully, but these errors were encountered: