Closed
Description
I had about this code (this is a small example):
from typing import List, Union
class TypeA: pass
class TypeB: pass
Types = Union[TypeA, TypeB]
t: List[Types] = [TypeA(), TypeB()]
a: List[TypeA] = list(filter(lambda x: isinstance(x, TypeA), t))
And I got the following message (both with my distribution's mypy 0.560 and with the current master):
error: Argument 2 to "filter" has incompatible type "List[Union[TypeA, TypeB]]"; expected "Iterable[TypeA]"
When I remove the type after a
, it treats a
as List[Types]
.
I get that this might be difficult, but it would be nice if it worked.
This could be related to #476, I'm not sure.