mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Patch from @sfreilich: make itertools.ifilter predicate parameter Optional (#1257)
From Samuel Freilich: In Python 2, the predicate parameter in itertools.ifilter and itertools.ifilterfalse can be None, indicating that true or false values should be retained (functionally equivalent to passing "bool" as the predicate). In Python 3, filter and itertools.filterfalse have the same behavior.
This commit is contained in:
committed by
Jelle Zijlstra
parent
d7dd9fb832
commit
8d8a34cb83
@@ -26,9 +26,9 @@ class chain(Iterator[_T], Generic[_T]):
|
||||
def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ...
|
||||
def dropwhile(predicate: Callable[[_T], Any],
|
||||
iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
def ifilter(predicate: Callable[[_T], Any],
|
||||
def ifilter(predicate: Optional[Callable[[_T], Any]],
|
||||
iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
def ifilterfalse(predicate: Callable[[_T], Any],
|
||||
def ifilterfalse(predicate: Optional[Callable[[_T], Any]],
|
||||
iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
|
||||
@overload
|
||||
|
||||
@@ -773,7 +773,8 @@ def exec(object: str, globals: Dict[str, Any] = None,
|
||||
locals: Mapping[str, Any] = None) -> Any: ... # TODO code object as source
|
||||
def exit(code: Any = ...) -> NoReturn: ...
|
||||
@overload
|
||||
def filter(function: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
def filter(function: Optional[Callable[[_T], Any]],
|
||||
iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
@overload
|
||||
def filter(function: None, iterable: Iterable[Optional[_T]]) -> Iterator[_T]: ...
|
||||
def format(o: object, format_spec: str = '') -> str: ...
|
||||
|
||||
@@ -29,7 +29,7 @@ class chain(Iterator[_T], Generic[_T]):
|
||||
def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ...
|
||||
def dropwhile(predicate: Callable[[_T], Any],
|
||||
iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
def filterfalse(predicate: Callable[[_T], Any],
|
||||
def filterfalse(predicate: Optional[Callable[[_T], Any]],
|
||||
iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user