Format: application/octet-stream
⬇ Download File (4.8 KB)
   1  from typing import (
   2      AbstractSet,
   3      Any,
   4      Callable as Callable,
   5      Container as Container,
   6      Dict,
   7      Generic,
   8      Hashable as Hashable,
   9      ItemsView as ItemsView,
  10      Iterable as Iterable,
  11      Iterator as Iterator,
  12      KeysView as KeysView,
  13      List,
  14      Mapping as Mapping,
  15      MappingView as MappingView,
  16      MutableMapping as MutableMapping,
  17      MutableSequence as MutableSequence,
  18      MutableSet as MutableSet,
  19      Optional,
  20      Reversible,
  21      Sequence as Sequence,
  22      Sized as Sized,
  23      Tuple,
  24      Type,
  25      TypeVar,
  26      Union,
  27      ValuesView as ValuesView,
  28      overload,
  29  )
  30  
  31  Set = AbstractSet
  32  
  33  _S = TypeVar("_S")
  34  _T = TypeVar("_T")
  35  _KT = TypeVar("_KT")
  36  _VT = TypeVar("_VT")
  37  
  38  # namedtuple is special-cased in the type checker; the initializer is ignored.
  39  def namedtuple(
  40      typename: Union[str, unicode],
  41      field_names: Union[str, unicode, Iterable[Union[str, unicode]]],
  42      verbose: bool = ...,
  43      rename: bool = ...,
  44  ) -> Type[Tuple[Any, ...]]: ...
  45  
  46  class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
  47      def __init__(self, iterable: Iterable[_T] = ..., maxlen: int = ...) -> None: ...
  48      @property
  49      def maxlen(self) -> Optional[int]: ...
  50      def append(self, x: _T) -> None: ...
  51      def appendleft(self, x: _T) -> None: ...
  52      def clear(self) -> None: ...
  53      def count(self, x: _T) -> int: ...
  54      def extend(self, iterable: Iterable[_T]) -> None: ...
  55      def extendleft(self, iterable: Iterable[_T]) -> None: ...
  56      def pop(self) -> _T: ...
  57      def popleft(self) -> _T: ...
  58      def remove(self, value: _T) -> None: ...
  59      def reverse(self) -> None: ...
  60      def rotate(self, n: int = ...) -> None: ...
  61      def __len__(self) -> int: ...
  62      def __iter__(self) -> Iterator[_T]: ...
  63      def __str__(self) -> str: ...
  64      def __hash__(self) -> int: ...
  65      def __getitem__(self, i: int) -> _T: ...
  66      def __setitem__(self, i: int, x: _T) -> None: ...
  67      def __contains__(self, o: _T) -> bool: ...
  68      def __reversed__(self) -> Iterator[_T]: ...
  69      def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
  70  
  71  class Counter(Dict[_T, int], Generic[_T]):
  72      @overload
  73      def __init__(self, **kwargs: int) -> None: ...
  74      @overload
  75      def __init__(self, mapping: Mapping[_T, int]) -> None: ...
  76      @overload
  77      def __init__(self, iterable: Iterable[_T]) -> None: ...
  78      def copy(self: _S) -> _S: ...
  79      def elements(self) -> Iterator[_T]: ...
  80      def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
  81      @overload
  82      def subtract(self, __mapping: Mapping[_T, int]) -> None: ...
  83      @overload
  84      def subtract(self, iterable: Iterable[_T]) -> None: ...
  85      # The Iterable[Tuple[...]] argument type is not actually desirable
  86      # (the tuples will be added as keys, breaking type safety) but
  87      # it's included so that the signature is compatible with
  88      # Dict.update. Not sure if we should use '# type: ignore' instead
  89      # and omit the type from the union.
  90      @overload
  91      def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ...
  92      @overload
  93      def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...
  94      @overload
  95      def update(self, **kwargs: int) -> None: ...
  96      def __add__(self, other: Counter[_T]) -> Counter[_T]: ...
  97      def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...
  98      def __and__(self, other: Counter[_T]) -> Counter[_T]: ...
  99      def __or__(self, other: Counter[_T]) -> Counter[_T]: ...
 100      def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ...
 101      def __isub__(self, other: Counter[_T]) -> Counter[_T]: ...
 102      def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
 103      def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
 104  
 105  class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
 106      def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
 107      def copy(self: _S) -> _S: ...
 108      def __reversed__(self) -> Iterator[_KT]: ...
 109  
 110  class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
 111      default_factory: Callable[[], _VT]
 112      @overload
 113      def __init__(self, **kwargs: _VT) -> None: ...
 114      @overload
 115      def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ...
 116      @overload
 117      def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ...
 118      @overload
 119      def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ...
 120      @overload
 121      def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
 122      @overload
 123      def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
 124      @overload
 125      def __init__(
 126          self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT
 127      ) -> None: ...
 128      def __missing__(self, key: _KT) -> _VT: ...
 129      def copy(self: _S) -> _S: ...
 130