From 45dfa087b61e8cbf00ae7f966ee55328daf0278d Mon Sep 17 00:00:00 2001 From: Alun Champion Date: Mon, 11 Feb 2019 20:17:34 -0600 Subject: [PATCH] Added `Optional[]` around the `itertools.groupby()` `key` attribute to allow `None` to pass the type checker. --- stdlib/2/itertools.pyi | 2 +- stdlib/3/itertools.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2/itertools.pyi b/stdlib/2/itertools.pyi index a37468d81159..e7a44f293729 100644 --- a/stdlib/2/itertools.pyi +++ b/stdlib/2/itertools.pyi @@ -35,7 +35,7 @@ def ifilterfalse(predicate: Optional[Callable[[_T], Any]], def groupby(iterable: Iterable[_T]) -> Iterator[Tuple[_T, Iterator[_T]]]: ... @overload def groupby(iterable: Iterable[_T], - key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... + key: Optional[Callable[[_T], _S]]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... @overload def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ... diff --git a/stdlib/3/itertools.pyi b/stdlib/3/itertools.pyi index 2b56406e824e..c990f4a06323 100644 --- a/stdlib/3/itertools.pyi +++ b/stdlib/3/itertools.pyi @@ -38,7 +38,7 @@ def filterfalse(predicate: Optional[Predicate[_T]], def groupby(iterable: Iterable[_T]) -> Iterator[Tuple[_T, Iterator[_T]]]: ... @overload def groupby(iterable: Iterable[_T], - key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... + key: Optional[Callable[[_T], _S]]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... @overload def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ...