Closed
Description
I think this idea appeared in context of other issues (mostly related to strict optional), but I hit this few times in another context. Consider this example:
Dictable = Union[Dict[str, str], Iterable[Tuple[str, str]]]
def do(arg: Dictable) -> None:
converted = dict(arg) # mypy errors here, although this is valid
The problem is that dict.__init__
is defined as an overload. I think we should at least support matching simple cases like:
@overload
def fun(x: A) -> B: ...
@overload
def fun(x: C) -> D: ...
arg: Union[A, C]
fun(arg) # we infer Union[B, D]