-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Currently union math can produce excessively wide types for overload calls. Example:
from typing import Union, overload
@overload
def f(x: Union[int, str]) -> int: ...
@overload
def f(x: object) -> object: ...
def f(x):
pass
x: Union[int, str]
reveal_type(f(x)) # object???A possible solution would be to check if the "normal way" generates a better result ad return it instead of returning soon. But maybe we should actually re-think the union math algorithm. I will spend some time thinking about it, and will make a PR if I will find an easy solution.