-
-
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
Certain order of union members causes Incompatible types error #3085
Comments
Might have been fixed by #3025, which got rolled back for other reasons. |
Another observation that looks related is this incorrect error message for the last statement of the following example. The last statement should cause Incompatible types and it does: from typing import Union, Dict, Optional
Value = Union[str, float, bool, int]
d: Dict[str, Value]
d = {}
v: Value
v = d.get("athing") However the error is showing wrong types:
(indented for better demonstration) The first union (expression type) in the error should have five elements – it is missing |
That's probably also something deciding that int is compatible with float, so |
I think this is essentially a duplicate of #1850 |
I’m getting this weird error: Incompatible types in assignment (expression has type Dict[str, Union[str, float]], variable has type Dict[str, Union[str, int, float, bool]])
however this works:
The order of union elements is different.
Other offenses:
Value = Union[int, str, bool, float]
Value = Union[str, int, bool, float]
Causes:
Incompatible types in assignment (expression has type Dict[str, Union[str, float]], variable has type Dict[str, Union[int, str, bool, float]])
The text was updated successfully, but these errors were encountered: