mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Improve iterators (#405)
Mainly reorder the stub, adding some missing method and having some other being version dependent. I've also, in 30f395e, specialized some function, specifying it for Sequence and Mapping, which is not strictly correct (because any class having `__getitem__` should get accepted) but is way more useful that simply having Any.
This commit is contained in:
committed by
Guido van Rossum
parent
9ecc1f2147
commit
56760eda52
@@ -1,135 +1,227 @@
|
||||
# Stubs for operator
|
||||
|
||||
from typing import Any, Callable, overload, Tuple
|
||||
from typing import (
|
||||
Any, Callable, Container, Mapping, MutableMapping, MutableSequence, Sequence, SupportsAbs, Tuple,
|
||||
TypeVar, overload,
|
||||
)
|
||||
import sys
|
||||
|
||||
def __abs__(a: Any) -> Any: ...
|
||||
def __add__(a: Any, b: Any) -> Any: ...
|
||||
def __and__(a: Any, b: Any) -> Any: ...
|
||||
def __concat__(a: Any, b: Any) -> Any: ...
|
||||
def __contains__(container: Any, item: Any) -> bool: ...
|
||||
def __delitem__(container: Any, item: Any) -> None: ...
|
||||
def __delslice__(container: Any, b: int, c: int) -> None: ...
|
||||
def __div__(a: Any, b: Any) -> Any: ...
|
||||
def __eq__(a: Any, b: Any) -> Any: ...
|
||||
def __floordiv__(a: Any, b: Any) -> Any: ...
|
||||
def __ge__(a: Any, b: Any) -> Any: ...
|
||||
def __getitem__(container: Any, key: Any) -> Any: ...
|
||||
def __getslice__(container, b: int, c: int) -> Any: ...
|
||||
def __gt__(a: Any, b: Any) -> Any: ...
|
||||
def __iadd__(a: Any, b: Any) -> Any: ...
|
||||
def __iand__(a: Any, b: Any) -> Any: ...
|
||||
def __iconcat__(a: Any, b: Any) -> Any: ...
|
||||
def __idiv__(a: Any, b: Any) -> Any: ...
|
||||
def __ifloordiv__(a: Any, b: Any) -> Any: ...
|
||||
def __ilshift__(a: Any, b: Any) -> Any: ...
|
||||
def __imod__(a: Any, b: Any) -> Any: ...
|
||||
def __imul__(a: Any, b: Any) -> Any: ...
|
||||
def __index__(x: Any) -> Any: ...
|
||||
def __inv__(x: Any) -> Any: ...
|
||||
def __invert__(x: Any) -> Any: ...
|
||||
def __ior__(a: Any, b: Any) -> Any: ...
|
||||
def __ipow__(a: Any, b: Any) -> Any: ...
|
||||
def __irepeat__(a: Any, b: int) -> Any: ...
|
||||
def __irshift__(a: Any, b: Any) -> Any: ...
|
||||
def __isub__(a: Any, b: Any) -> Any: ...
|
||||
def __itruediv__(a: Any, b: Any) -> Any: ...
|
||||
def __ixor__(a: Any, b: Any) -> Any: ...
|
||||
def __le__(a: Any, b: Any) -> Any: ...
|
||||
def __lshift__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_K = TypeVar('_K')
|
||||
_V = TypeVar('_V')
|
||||
|
||||
|
||||
def lt(a: Any, b: Any) -> Any: ...
|
||||
def le(a: Any, b: Any) -> Any: ...
|
||||
def eq(a: Any, b: Any) -> Any: ...
|
||||
def ne(a: Any, b: Any) -> Any: ...
|
||||
def ge(a: Any, b: Any) -> Any: ...
|
||||
def gt(a: Any, b: Any) -> Any: ...
|
||||
def __lt__(a: Any, b: Any) -> Any: ...
|
||||
def __mod__(a: Any, b: Any) -> Any: ...
|
||||
def __mul__(a: Any, b: Any) -> Any: ...
|
||||
def __le__(a: Any, b: Any) -> Any: ...
|
||||
def __eq__(a: Any, b: Any) -> Any: ...
|
||||
def __ne__(a: Any, b: Any) -> Any: ...
|
||||
def __neg__(x: Any) -> Any: ...
|
||||
def __not__(x: Any) -> bool: ...
|
||||
def __ge__(a: Any, b: Any) -> Any: ...
|
||||
def __gt__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def not_(obj: Any) -> bool: ...
|
||||
def __not__(obj: Any) -> bool: ...
|
||||
|
||||
def truth(x: Any) -> bool: ...
|
||||
|
||||
def is_(a: Any, b: Any) -> bool: ...
|
||||
|
||||
def is_not(a: Any, b: Any) -> bool: ...
|
||||
|
||||
def abs(x: SupportsAbs) -> Any: ...
|
||||
def __abs__(a: SupportsAbs) -> Any: ...
|
||||
|
||||
def add(a: Any, b: Any) -> Any: ...
|
||||
def __add__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def and_(a: Any, b: Any) -> Any: ...
|
||||
def __and__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def div(a: Any, b: Any) -> Any: ...
|
||||
def __div__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def floordiv(a: Any, b: Any) -> Any: ...
|
||||
def __floordiv__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def index(a: Any) -> int: ...
|
||||
def __index__(a: Any) -> int: ...
|
||||
|
||||
def inv(obj: Any) -> Any: ...
|
||||
def invert(obj: Any) -> Any: ...
|
||||
def __inv__(obj: Any) -> Any: ...
|
||||
def __invert__(obj: Any) -> Any: ...
|
||||
|
||||
def lshift(a: Any, b: Any) -> Any: ...
|
||||
def __lshift__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def mod(a: Any, b: Any) -> Any: ...
|
||||
def __mod__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def mul(a: Any, b: Any) -> Any: ...
|
||||
def __mul__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
if sys.version_info >= (3,5):
|
||||
def matmul(a: Any, b: Any) -> Any: ...
|
||||
def __matmul__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def neg(obj: Any) -> Any: ...
|
||||
def __neg__(obj: Any) -> Any: ...
|
||||
|
||||
def or_(a: Any, b: Any) -> Any: ...
|
||||
def __or__(a: Any, b: Any) -> Any: ...
|
||||
def __pos__(x: Any) -> Any: ...
|
||||
|
||||
def pos(obj: Any) -> Any: ...
|
||||
def __pos__(obj: Any) -> Any: ...
|
||||
|
||||
def pow(a: Any, b: Any) -> Any: ...
|
||||
def __pow__(a: Any, b: Any) -> Any: ...
|
||||
def __repeat__(a, b: int) -> Any: ...
|
||||
|
||||
def rshift(a: Any, b: Any) -> Any: ...
|
||||
def __rshift__(a: Any, b: Any) -> Any: ...
|
||||
def __setitem__(container: Any, b: Any) -> None: ...
|
||||
def __setslice__(container: Any, b: int, c: int, item: Any) -> None: ...
|
||||
|
||||
def sub(a: Any, b: Any) -> Any: ...
|
||||
def __sub__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def truediv(a: Any, b: Any) -> Any: ...
|
||||
def __truediv__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def xor(a: Any, b: Any) -> Any: ...
|
||||
def __xor__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def abs(x: Any) -> Any: ...
|
||||
def add(a: Any, b: Any) -> Any: ...
|
||||
def and_(a: Any, b: Any) -> Any: ...
|
||||
def concat(a: Any, b: Any) -> Any: ...
|
||||
def contains(container: Any, item: Any) -> bool: ...
|
||||
def countOf(container: Any, item: Any) -> int: ...
|
||||
def delitem(container: Any, item: Any) -> None: ...
|
||||
def delslice(container: Any, b: int, c: int) -> None: ...
|
||||
def div(a: Any, b: Any) -> Any: ...
|
||||
def eq(a: Any, b: Any) -> Any: ...
|
||||
def floordiv(a: Any, b: Any) -> Any: ...
|
||||
def ge(a: Any, b: Any) -> Any: ...
|
||||
def getitem(a: Any, b: Any) -> Any: ...
|
||||
def getslice(container: Any, b: int, c: int) -> Any: ...
|
||||
def gt(a: Any, b: Any) -> Any: ...
|
||||
def concat(a: Sequence[_T], b: Sequence[_T]) -> Sequence[_T]: ...
|
||||
def __concat__(a: Sequence[_T], b: Sequence[_T]) -> Sequence[_T]: ...
|
||||
|
||||
def contains(a: Container[Any], b: Any) -> bool: ...
|
||||
def __contains__(a: Container[Any], b: Any) -> bool: ...
|
||||
|
||||
def countOf(a: Container[Any], b: Any) -> int: ...
|
||||
|
||||
@overload
|
||||
def delitem(a: MutableSequence[_T], b: int) -> None: ...
|
||||
@overload
|
||||
def delitem(a: MutableMapping[_K, _V], b: _K) -> None: ...
|
||||
@overload
|
||||
def __delitem__(a: MutableSequence[_T], b: int) -> None: ...
|
||||
@overload
|
||||
def __delitem__(a: MutableMapping[_K, _V], b: _K) -> None: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def delslice(a: MutableSequence[Any], b: int, c: int) -> None: ...
|
||||
def __delslice__(a: MutableSequence[Any], b: int, c: int) -> None: ...
|
||||
|
||||
@overload
|
||||
def getitem(a: Sequence[_T], b: int) -> _T: ...
|
||||
@overload
|
||||
def getitem(a: Mapping[_K, _V], b: _K) -> _V: ...
|
||||
@overload
|
||||
def __getitem__(a: Sequence[_T], b: int) -> _T: ...
|
||||
@overload
|
||||
def __getitem__(a: Mapping[_K, _V], b: _K) -> _V: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def getslice(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ...
|
||||
def __getslice__(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ...
|
||||
|
||||
def indexOf(a: Sequence[_T], b: _T) -> int: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def repeat(a: Any, b: int) -> Any: ...
|
||||
def __repeat__(a: Any, b: int) -> Any: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def sequenceIncludes(a: Container[Any], b: Any) -> bool: ...
|
||||
|
||||
@overload
|
||||
def setitem(a: MutableSequence[_T], b: int, c: _T) -> None: ...
|
||||
@overload
|
||||
def setitem(a: MutableMapping[_K, _V], b: _K, c: _V) -> None: ...
|
||||
@overload
|
||||
def __setitem__(a: MutableSequence[_T], b: int, c: _T) -> None: ...
|
||||
@overload
|
||||
def __setitem__(a: MutableMapping[_K, _V], b: _K, c: _V) -> None: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def setslice(a: MutableSequence[_T], b: int, c: int, v: Sequence[_T]) -> None: ...
|
||||
def __setslice__(a: MutableSequence[_T], b: int, c: int, v: Sequence[_T]) -> None: ...
|
||||
|
||||
|
||||
if sys.version_info >= (3, 4):
|
||||
def length_hint(obj: Any, default: int = ...) -> int: ...
|
||||
|
||||
@overload
|
||||
def attrgetter(attr: str) -> Callable[[Any], Any]: ...
|
||||
@overload
|
||||
def attrgetter(*attrs: str) -> Callable[[Any], Tuple[Any, ...]]: ...
|
||||
|
||||
@overload
|
||||
def itemgetter(item: int) -> Callable[[Any], Any]: ...
|
||||
@overload
|
||||
def itemgetter(*items: int) -> Callable[[Any], Tuple[Any, ...]]: ...
|
||||
|
||||
def methodcaller(name: str, *args: Any, **kwargs: Any) -> Callable[..., Any]: ...
|
||||
|
||||
|
||||
def iadd(a: Any, b: Any) -> Any: ...
|
||||
def __iadd__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def iand(a: Any, b: Any) -> Any: ...
|
||||
def __iand__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def iconcat(a: Any, b: Any) -> Any: ...
|
||||
def idiv(a: Any, b: Any) -> Any: ...
|
||||
def __iconcat__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def idiv(a: Any, b: Any) -> Any: ...
|
||||
def __idiv__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def ifloordiv(a: Any, b: Any) -> Any: ...
|
||||
def __ifloordiv__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def ilshift(a: Any, b: Any) -> Any: ...
|
||||
def __ilshift__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def imod(a: Any, b: Any) -> Any: ...
|
||||
def __imod__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def imul(a: Any, b: Any) -> Any: ...
|
||||
def index(x: Any) -> Any: ...
|
||||
def indexOf(container: Any, item: Any) -> int: ...
|
||||
def inv(x: Any) -> Any: ...
|
||||
def invert(x: Any) -> Any: ...
|
||||
def __imul__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
if sys.version_info >= (3,5):
|
||||
def imatmul(a: Any, b: Any) -> Any: ...
|
||||
def __imatmul__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def ior(a: Any, b: Any) -> Any: ...
|
||||
def __ior__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def ipow(a: Any, b: Any) -> Any: ...
|
||||
def irepeat(a, b: int) -> Any: ...
|
||||
def __ipow__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def irepeat(a: Any, b: int) -> Any: ...
|
||||
def __irepeat__(a: Any, b: int) -> Any: ...
|
||||
|
||||
def irshift(a: Any, b: Any) -> Any: ...
|
||||
def isCallable(x: Any) -> bool: ...
|
||||
def isMappingType(x: Any) -> bool: ...
|
||||
def isNumberType(x: Any) -> bool: ...
|
||||
def isSequenceType(x: Any) -> bool: ...
|
||||
def is_(a: Any, b: Any) -> bool: ...
|
||||
def is_not(a: Any, b: Any) -> bool: ...
|
||||
def __irshift__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def isub(a: Any, b: Any) -> Any: ...
|
||||
def __isub__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def itruediv(a: Any, b: Any) -> Any: ...
|
||||
def __itruediv__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
def ixor(a: Any, b: Any) -> Any: ...
|
||||
def le(a: Any, b: Any) -> Any: ...
|
||||
def lshift(a: Any, b: Any) -> Any: ...
|
||||
def lt(a: Any, b: Any) -> Any: ...
|
||||
def mod(a: Any, b: Any) -> Any: ...
|
||||
def mul(a: Any, b: Any) -> Any: ...
|
||||
def ne(a: Any, b: Any) -> Any: ...
|
||||
def neg(x: Any) -> Any: ...
|
||||
def not_(x: Any) -> bool: ...
|
||||
def or_(a: Any, b: Any) -> Any: ...
|
||||
def pos(x: Any) -> Any: ...
|
||||
def pow(a: Any, b: Any) -> Any: ...
|
||||
def repeat(a, b: int) -> Any: ...
|
||||
def rshift(a: Any, b: Any) -> Any: ...
|
||||
def sequenceIncludes(seq1: Any, seq2: Any) -> bool: ...
|
||||
def setitem(container: Any, key: Any, item: Any) -> None: ...
|
||||
def setslice(container: Any, b: int, c: int, slice: Any) -> None: ...
|
||||
def sub(a: Any, b: Any) -> Any: ...
|
||||
def truediv(a: Any, b: Any) -> Any: ...
|
||||
def truth(x: Any) -> bool: ...
|
||||
def xor(a: Any, b: Any) -> Any: ...
|
||||
def __ixor__(a: Any, b: Any) -> Any: ...
|
||||
|
||||
# Unsupported: more than 3 attributes.
|
||||
# Unsupported: on Python 2 the parameter type should be `basestring`.
|
||||
@overload
|
||||
def attrgetter(attr1: str) -> Callable[[Any], Any]: ...
|
||||
@overload
|
||||
def attrgetter(attr1: str, attr2: str) -> Callable[[Any], Tuple[Any, Any]]: ...
|
||||
@overload
|
||||
def attrgetter(attr1: str, attr2: str, attr3: str) -> Callable[[Any], Tuple[Any, Any, Any]]: ...
|
||||
|
||||
# Unsupported: more than 3 items.
|
||||
@overload
|
||||
def itemgetter(item1: Any) -> Callable[[Any], Any]: ...
|
||||
@overload
|
||||
def itemgetter(item1: Any, item2: Any) -> Callable[[Any], Tuple[Any, Any]]: ...
|
||||
@overload
|
||||
def itemgetter(item1: Any, item2: Any, item3: Any) -> Callable[[Any], Tuple[Any, Any, Any]]: ...
|
||||
|
||||
# Unsupported: on Python 2 the parameter type should be `basestring`.
|
||||
def methodcaller(name: str, *args, **kwargs) -> Callable[[Any], Any]: ...
|
||||
if sys.version_info < (3,):
|
||||
def isCallable(x: Any) -> bool: ...
|
||||
def isMappingType(x: Any) -> bool: ...
|
||||
def isNumberType(x: Any) -> bool: ...
|
||||
def isSequenceType(x: Any) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user