Make filter work properly with Optional elements (#775)

This commit is contained in:
David Fisher
2016-12-15 17:53:38 -08:00
committed by Guido van Rossum
parent 6fc57a419b
commit 957307b785
2 changed files with 8 additions and 1 deletions

View File

@@ -680,6 +680,10 @@ def divmod(a: int, b: int) -> Tuple[int, int]: ...
@overload
def divmod(a: float, b: float) -> Tuple[float, float]: ...
def exit(code: int = ...) -> None: ...
@overload
def filter(function: None,
iterable: Iterable[Optional[_T]]) -> List[_T]: ...
@overload
def filter(function: Callable[[_T], Any],
iterable: Iterable[_T]) -> List[_T]: ...
def format(o: object, format_spec: str = '') -> str: ... # TODO unicode

View File

@@ -696,7 +696,10 @@ def eval(source: str, globals: Dict[str, Any] = None,
def exec(object: str, globals: Dict[str, Any] = None,
locals: Mapping[str, Any] = None) -> Any: ... # TODO code object as source
def exit(code: int = None) -> None: ...
def filter(function: Optional[Callable[[_T], Any]], iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def filter(function: None, iterable: Iterable[Optional[_T]]) -> Iterator[_T]: ...
@overload
def filter(function: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ...
def format(o: object, format_spec: str = '') -> str: ...
def getattr(o: Any, name: str, default: Any = ...) -> Any: ...
def globals() -> Dict[str, Any]: ...