mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Improve itertools.islice type (#610)
`stop` parameter to `islice` can be `None`, which is important when checking with --strict-optional
This commit is contained in:
committed by
Guido van Rossum
parent
0c498000c4
commit
2d8ff30e7a
@@ -3,7 +3,7 @@
|
||||
# Based on https://docs.python.org/2/library/itertools.html
|
||||
|
||||
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
|
||||
Union, Sequence, Generic)
|
||||
Union, Sequence, Generic, Optional)
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_S = TypeVar('_S')
|
||||
@@ -40,7 +40,7 @@ def groupby(iterable: Iterable[_T],
|
||||
@overload
|
||||
def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ...
|
||||
@overload
|
||||
def islice(iterable: Iterable[_T], start: int, stop: int,
|
||||
def islice(iterable: Iterable[_T], start: int, stop: Optional[int],
|
||||
step: int = ...) -> Iterator[_T]: ...
|
||||
|
||||
_T1 = TypeVar('_T1')
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Based on http://docs.python.org/3.2/library/itertools.html
|
||||
|
||||
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
|
||||
Union, Sequence, Generic)
|
||||
Union, Sequence, Generic, Optional)
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_S = TypeVar('_S')
|
||||
@@ -41,7 +41,7 @@ def groupby(iterable: Iterable[_T],
|
||||
@overload
|
||||
def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ...
|
||||
@overload
|
||||
def islice(iterable: Iterable[_T], start: int, stop: int,
|
||||
def islice(iterable: Iterable[_T], start: int, stop: Optional[int],
|
||||
step: int = ...) -> Iterator[_T]: ...
|
||||
|
||||
def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ...
|
||||
|
||||
Reference in New Issue
Block a user