Closed
Description
Here are some new false positives with overloads, based on real code samples with map
in Python 2.
The bug(s) only appear if the strict optional is disabled:
from typing import TypeVar, Iterable, Tuple, List, overload, Callable
S = TypeVar('S')
T1 = TypeVar('T1')
T2 = TypeVar('T2')
@overload
def map1(func: Callable[[T1], S], iter1: Iterable[T1]) -> List[S]: ...
@overload
def map1(func: None, iter1: Iterable[T1]) -> List[T1]: ...
def map1(*args, **kwargs):
pass
a: List[int]
b: List[str]
for x in map1(None, a): # false positive: Need type annotation for 'x'
pass
@overload
def map2(func: Callable[[T1, T2], S],
iter1: Iterable[T1],
iter2: Iterable[T2]) -> List[S]: ...
@overload
def map2(func: None,
iter1: Iterable[T1],
iter2: Iterable[T2]) -> List[Tuple[T1, T2]]: ...
def map2(*args, **kwargs):
pass
for y, z in map2(None, a, b): # false positive: '<nothing>' object is not iterable
pass