From 9451fa922c468bcba76e6dc3942e408a1db25149 Mon Sep 17 00:00:00 2001 From: Tomasz Elendt Date: Mon, 22 Aug 2016 23:53:48 +0200 Subject: [PATCH] Add start and stop arguments to Sequence.index in Py >= 3.5 (#489) Fixes #486. --- stdlib/3/builtins.pyi | 5 ++++- stdlib/3/typing.pyi | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index b4ee85b2d..074cd4914 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -446,7 +446,10 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... - def index(self, x: Any) -> int: ... + if sys.version_info >= (3, 5): + def index(self, x: Any, start: int = 0, end: int = 0) -> int: ... + else: + def index(self, x: Any) -> int: ... class function: # TODO not defined in builtins! diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index e89daad03..571847b79 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -1,5 +1,6 @@ # Stubs for typing +import sys from abc import abstractmethod, ABCMeta # Definitions of special type checking related constructs. Their definition @@ -145,7 +146,10 @@ class Sequence(Iterable[_T_co], Container[_T_co], Sized, Reversible[_T_co], Gene @abstractmethod def __getitem__(self, s: slice) -> Sequence[_T_co]: ... # Mixin methods - def index(self, x: Any) -> int: ... + if sys.version_info >= (3, 5): + def index(self, x: Any, start: int = 0, end: int = 0) -> int: ... + else: + def index(self, x: Any) -> int: ... def count(self, x: Any) -> int: ... def __contains__(self, x: object) -> bool: ... def __iter__(self) -> Iterator[_T_co]: ...