The type of b
is incorrectly List[Union[None, int]]
instead of List[int]
when using --strict-optional
:
from typing import Optional, List
a = [] # type: List[Optional[int]]
b = [x for x in a if x]
reveal_type(b)
Generators and other comprehensions are related (not checked them).