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