-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongneeds discussionpriority-1-normaltopic-union-typestopic-usability
Description
In the following test
from typing import Union
class A:
x: Union[int, float]
def foo(x: Union[int, float], y: A) -> None:
reveal_type(x)
reveal_type(y.x)
we emit:
lol.py:8: error: Revealed type is 'Union[builtins.int, builtins.float]'
lol.py:9: error: Revealed type is 'builtins.float'
That is to say, class attributes have unions simplified using promotions while arguments (and locals) do not.
Probably they ought to have the same behavior?
(And probably the behavior ought to be to not simplify, especially because of #6114)
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongneeds discussionpriority-1-normaltopic-union-typestopic-usability