Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
featurepriority-2-lowtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
I had about this code (this is a small example):
fromtypingimportList, UnionclassTypeA: passclassTypeB: passTypes=Union[TypeA, TypeB] t: List[Types] = [TypeA(), TypeB()] a: List[TypeA] =list(filter(lambdax: 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.
mplanchard, ermakov-oleg, mcitoler, bcb, paulfariello and 5 more
Metadata
Metadata
Assignees
Labels
featurepriority-2-lowtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder