Closed
Description
For example in the following code:
def f(x):
# type: (object) -> list
if isinstance(x, (list, set)):
return [g(i) for i in x]
mypy will complain that an Iterable
is expected (it still only sees x
as an object
). This can be resolved with e.g. a manual cast
of x
to Union[list, set]
, but this adds a slight overhead and isn't as clean.