massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 3 / collections / __init__.pyi
1 # Stubs for collections\r
2 \r
3 # Based on http://docs.python.org/3.2/library/collections.html\r
4 \r
5 # These are not exported.\r
6 import sys\r
7 import typing\r
8 from typing import (\r
9     TypeVar, Generic, Dict, overload, List, Tuple,\r
10     Any, Type, Optional, Union\r
11 )\r
12 # These are exported.\r
13 from . import abc\r
14 \r
15 from typing import (\r
16     Callable as Callable,\r
17     Container as Container,\r
18     Hashable as Hashable,\r
19     Iterable as Iterable,\r
20     Iterator as Iterator,\r
21     Sized as Sized,\r
22     Generator as Generator,\r
23     ByteString as ByteString,\r
24     Reversible as Reversible,\r
25     Mapping as Mapping,\r
26     MappingView as MappingView,\r
27     ItemsView as ItemsView,\r
28     KeysView as KeysView,\r
29     ValuesView as ValuesView,\r
30     MutableMapping as MutableMapping,\r
31     Sequence as Sequence,\r
32     MutableSequence as MutableSequence,\r
33     MutableSet as MutableSet,\r
34     AbstractSet as Set,\r
35 )\r
36 if sys.version_info >= (3, 6):\r
37     from typing import (\r
38         Collection as Collection,\r
39         AsyncGenerator as AsyncGenerator,\r
40     )\r
41 if sys.version_info >= (3, 5):\r
42     from typing import (\r
43         Awaitable as Awaitable,\r
44         Coroutine as Coroutine,\r
45         AsyncIterable as AsyncIterable,\r
46         AsyncIterator as AsyncIterator,\r
47     )\r
48 \r
49 _T = TypeVar('_T')\r
50 _KT = TypeVar('_KT')\r
51 _VT = TypeVar('_VT')\r
52 \r
53 \r
54 # namedtuple is special-cased in the type checker; the initializer is ignored.\r
55 if sys.version_info >= (3, 7):\r
56     def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,\r
57                    rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...\r
58 elif sys.version_info >= (3, 6):\r
59     def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,\r
60                    verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...\r
61 else:\r
62     def namedtuple(typename: str, field_names: Union[str, Iterable[str]],\r
63                    verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...\r
64 \r
65 _UserDictT = TypeVar('_UserDictT', bound=UserDict)\r
66 \r
67 class UserDict(MutableMapping[_KT, _VT]):\r
68     data: Dict[_KT, _VT]\r
69     def __init__(self, dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ...\r
70     def __len__(self) -> int: ...\r
71     def __getitem__(self, key: _KT) -> _VT: ...\r
72     def __setitem__(self, key: _KT, item: _VT) -> None: ...\r
73     def __delitem__(self, key: _KT) -> None: ...\r
74     def __iter__(self) -> Iterator[_KT]: ...\r
75     def __contains__(self, key: object) -> bool: ...\r
76     def copy(self: _UserDictT) -> _UserDictT: ...\r
77     @classmethod\r
78     def fromkeys(cls: Type[_UserDictT], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _UserDictT: ...\r
79 \r
80 _UserListT = TypeVar('_UserListT', bound=UserList)\r
81 \r
82 class UserList(MutableSequence[_T]):\r
83     def __init__(self, initlist: Optional[Iterable[_T]] = ...) -> None: ...\r
84     def __lt__(self, other: object) -> bool: ...\r
85     def __le__(self, other: object) -> bool: ...\r
86     def __gt__(self, other: object) -> bool: ...\r
87     def __ge__(self, other: object) -> bool: ...\r
88     def __contains__(self, item: object) -> bool: ...\r
89     def __len__(self) -> int: ...\r
90     @overload\r
91     def __getitem__(self, i: int) -> _T: ...\r
92     @overload\r
93     def __getitem__(self, i: slice) -> Sequence[_T]: ...\r
94     @overload\r
95     def __setitem__(self, i: int, o: _T) -> None: ...\r
96     @overload\r
97     def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ...\r
98     def __delitem__(self, i: Union[int, slice]) -> None: ...\r
99     def __add__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...\r
100     def __iadd__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...\r
101     def __mul__(self: _UserListT, n: int) -> _UserListT: ...\r
102     def __imul__(self: _UserListT, n: int) -> _UserListT: ...\r
103     def append(self, item: _T) -> None: ...\r
104     def insert(self, i: int, item: _T) -> None: ...\r
105     def pop(self, i: int = ...) -> _T: ...\r
106     def remove(self, item: _T) -> None: ...\r
107     def clear(self) -> None: ...\r
108     def copy(self: _UserListT) -> _UserListT: ...\r
109     def count(self, item: _T) -> int: ...\r
110     def index(self, item: _T, *args: Any) -> int: ...\r
111     def reverse(self) -> None: ...\r
112     def sort(self, *args: Any, **kwds: Any) -> None: ...\r
113     def extend(self, other: Iterable[_T]) -> None: ...\r
114 \r
115 _UserStringT = TypeVar('_UserStringT', bound=UserString)\r
116 \r
117 class UserString(Sequence[str]):\r
118     def __init__(self, seq: object) -> None: ...\r
119     def __int__(self) -> int: ...\r
120     def __float__(self) -> float: ...\r
121     def __complex__(self) -> complex: ...\r
122     if sys.version_info >= (3, 5):\r
123         def __getnewargs__(self) -> Tuple[str]: ...\r
124     def __lt__(self, string: Union[str, UserString]) -> bool: ...\r
125     def __le__(self, string: Union[str, UserString]) -> bool: ...\r
126     def __gt__(self, string: Union[str, UserString]) -> bool: ...\r
127     def __ge__(self, string: Union[str, UserString]) -> bool: ...\r
128     def __contains__(self, char: object) -> bool: ...\r
129     def __len__(self) -> int: ...\r
130     # It should return a str to implement Sequence correctly, but it doesn't.\r
131     def __getitem__(self: _UserStringT, i: Union[int, slice]) -> _UserStringT: ...  # type: ignore\r
132     def __add__(self: _UserStringT, other: object) -> _UserStringT: ...\r
133     def __mul__(self: _UserStringT, n: int) -> _UserStringT: ...\r
134     def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ...\r
135     def capitalize(self: _UserStringT) -> _UserStringT: ...\r
136     if sys.version_info >= (3, 5):\r
137         def casefold(self: _UserStringT) -> _UserStringT: ...\r
138     def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...\r
139     def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
140     def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ...\r
141     def endswith(self, suffix: Union[str, Tuple[str, ...]], start: int = ..., end: int = ...) -> bool: ...\r
142     def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ...\r
143     def find(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
144     def format(self, *args: Any, **kwds: Any) -> str: ...\r
145     if sys.version_info >= (3, 5):\r
146         def format_map(self, mapping: Mapping[str, Any]) -> str: ...\r
147     def index(self, sub: str, start: int = ..., end: int = ...) -> int: ...\r
148     def isalpha(self) -> bool: ...\r
149     def isalnum(self) -> bool: ...\r
150     def isdecimal(self) -> bool: ...\r
151     def isdigit(self) -> bool: ...\r
152     def isidentifier(self) -> bool: ...\r
153     def islower(self) -> bool: ...\r
154     def isnumeric(self) -> bool: ...\r
155     if sys.version_info >= (3, 5):\r
156         def isprintable(self) -> bool: ...\r
157     def isspace(self) -> bool: ...\r
158     def istitle(self) -> bool: ...\r
159     def isupper(self) -> bool: ...\r
160     def join(self, seq: Iterable[str]) -> str: ...\r
161     def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...\r
162     def lower(self: _UserStringT) -> _UserStringT: ...\r
163     def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...\r
164     if sys.version_info >= (3, 5):\r
165         @staticmethod\r
166         @overload\r
167         def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ...\r
168         @staticmethod\r
169         @overload\r
170         def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ...\r
171     def partition(self, sep: str) -> Tuple[str, str, str]: ...\r
172     def replace(self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...) -> _UserStringT: ...\r
173     def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
174     def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
175     def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...\r
176     def rpartition(self, sep: str) -> Tuple[str, str, str]: ...\r
177     def rstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...\r
178     def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...\r
179     def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...\r
180     def splitlines(self, keepends: bool = ...) -> List[str]: ...\r
181     def startswith(self, prefix: Union[str, Tuple[str, ...]], start: int = ..., end: int = ...) -> bool: ...\r
182     def strip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...\r
183     def swapcase(self: _UserStringT) -> _UserStringT: ...\r
184     def title(self: _UserStringT) -> _UserStringT: ...\r
185     def translate(self: _UserStringT, *args: Any) -> _UserStringT: ...\r
186     def upper(self: _UserStringT) -> _UserStringT: ...\r
187     def zfill(self: _UserStringT, width: int) -> _UserStringT: ...\r
188 \r
189 \r
190 # Technically, deque only derives from MutableSequence in 3.5 (before then, the insert and index\r
191 # methods did not exist).\r
192 # But in practice it's not worth losing sleep over.\r
193 class deque(MutableSequence[_T], Generic[_T]):\r
194     @property\r
195     def maxlen(self) -> Optional[int]: ...\r
196     def __init__(self, iterable: Iterable[_T] = ...,\r
197                  maxlen: int = ...) -> None: ...\r
198     def append(self, x: _T) -> None: ...\r
199     def appendleft(self, x: _T) -> None: ...\r
200     def clear(self) -> None: ...\r
201     if sys.version_info >= (3, 5):\r
202         def copy(self) -> deque[_T]: ...\r
203     def count(self, x: _T) -> int: ...\r
204     def extend(self, iterable: Iterable[_T]) -> None: ...\r
205     def extendleft(self, iterable: Iterable[_T]) -> None: ...\r
206     def insert(self, i: int, x: _T) -> None: ...\r
207     def index(self, x: _T, start: int = ..., stop: int = ...) -> int: ...\r
208     def pop(self, i: int = ...) -> _T: ...\r
209     def popleft(self) -> _T: ...\r
210     def remove(self, value: _T) -> None: ...\r
211     def reverse(self) -> None: ...\r
212     def rotate(self, n: int) -> None: ...\r
213 \r
214     def __len__(self) -> int: ...\r
215     def __iter__(self) -> Iterator[_T]: ...\r
216     def __str__(self) -> str: ...\r
217     def __hash__(self) -> int: ...\r
218 \r
219     # These methods of deque don't really take slices, but we need to\r
220     # define them as taking a slice to satisfy MutableSequence.\r
221     @overload\r
222     def __getitem__(self, index: int) -> _T: ...\r
223     @overload\r
224     def __getitem__(self, s: slice) -> Sequence[_T]:\r
225         raise TypeError\r
226     @overload\r
227     def __setitem__(self, i: int, x: _T) -> None: ...\r
228     @overload\r
229     def __setitem__(self, s: slice, o: Iterable[_T]) -> None:\r
230         raise TypeError\r
231     @overload\r
232     def __delitem__(self, i: int) -> None: ...\r
233     @overload\r
234     def __delitem__(self, s: slice) -> None:\r
235         raise TypeError\r
236 \r
237     def __contains__(self, o: object) -> bool: ...\r
238     def __reversed__(self) -> Iterator[_T]: ...\r
239 \r
240     if sys.version_info >= (3, 5):\r
241         def __add__(self, other: deque[_T]) -> deque[_T]: ...\r
242         def __mul__(self, other: int) -> deque[_T]: ...\r
243         def __imul__(self, other: int) -> None: ...\r
244 \r
245 _CounterT = TypeVar('_CounterT', bound=Counter)\r
246 \r
247 class Counter(Dict[_T, int], Generic[_T]):\r
248     @overload\r
249     def __init__(self, **kwargs: int) -> None: ...\r
250     @overload\r
251     def __init__(self, mapping: Mapping[_T, int]) -> None: ...\r
252     @overload\r
253     def __init__(self, iterable: Iterable[_T]) -> None: ...\r
254     def copy(self: _CounterT) -> _CounterT: ...\r
255     def elements(self) -> Iterator[_T]: ...\r
256 \r
257     def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...\r
258 \r
259     @overload\r
260     def subtract(self, __mapping: Mapping[_T, int]) -> None: ...\r
261     @overload\r
262     def subtract(self, iterable: Iterable[_T]) -> None: ...\r
263 \r
264     # The Iterable[Tuple[...]] argument type is not actually desirable\r
265     # (the tuples will be added as keys, breaking type safety) but\r
266     # it's included so that the signature is compatible with\r
267     # Dict.update. Not sure if we should use '# type: ignore' instead\r
268     # and omit the type from the union.\r
269     @overload\r
270     def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ...\r
271     @overload\r
272     def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...\r
273     @overload\r
274     def update(self, **kwargs: int) -> None: ...\r
275 \r
276     def __add__(self, other: Counter[_T]) -> Counter[_T]: ...\r
277     def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...\r
278     def __and__(self, other: Counter[_T]) -> Counter[_T]: ...\r
279     def __or__(self, other: Counter[_T]) -> Counter[_T]: ...\r
280     def __pos__(self) -> Counter[_T]: ...\r
281     def __neg__(self) -> Counter[_T]: ...\r
282     def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ...\r
283     def __isub__(self, other: Counter[_T]) -> Counter[_T]: ...\r
284     def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...\r
285     def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...\r
286 \r
287 _OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)\r
288 \r
289 class _OrderedDictKeysView(KeysView[_KT], Reversible[_KT]):\r
290     def __reversed__(self) -> Iterator[_KT]: ...\r
291 class _OrderedDictItemsView(ItemsView[_KT, _VT], Reversible[Tuple[_KT, _VT]]):\r
292     def __reversed__(self) -> Iterator[Tuple[_KT, _VT]]: ...\r
293 class _OrderedDictValuesView(ValuesView[_VT], Reversible[_VT]):\r
294     def __reversed__(self) -> Iterator[_VT]: ...\r
295 \r
296 class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):\r
297     def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...\r
298     def move_to_end(self, key: _KT, last: bool = ...) -> None: ...\r
299     def copy(self: _OrderedDictT) -> _OrderedDictT: ...\r
300     def __reversed__(self) -> Iterator[_KT]: ...\r
301     def keys(self) -> _OrderedDictKeysView[_KT]: ...\r
302     def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...\r
303     def values(self) -> _OrderedDictValuesView[_VT]: ...\r
304 \r
305 _DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)\r
306 \r
307 class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):\r
308     default_factory = ...  # type: Callable[[], _VT]\r
309 \r
310     @overload\r
311     def __init__(self, **kwargs: _VT) -> None: ...\r
312     @overload\r
313     def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ...\r
314     @overload\r
315     def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ...\r
316     @overload\r
317     def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
318                  map: Mapping[_KT, _VT]) -> None: ...\r
319     @overload\r
320     def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
321                  map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...\r
322     @overload\r
323     def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
324                  iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...\r
325     @overload\r
326     def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
327                  iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...\r
328     def __missing__(self, key: _KT) -> _VT: ...\r
329     # TODO __reversed__\r
330     def copy(self: _DefaultDictT) -> _DefaultDictT: ...\r
331 \r
332 class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):\r
333     def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...\r
334 \r
335     @property\r
336     def maps(self) -> List[Mapping[_KT, _VT]]: ...\r
337 \r
338     def new_child(self, m: Mapping[_KT, _VT] = ...) -> typing.ChainMap[_KT, _VT]: ...\r
339 \r
340     @property\r
341     def parents(self) -> typing.ChainMap[_KT, _VT]: ...\r
342 \r
343     def __setitem__(self, k: _KT, v: _VT) -> None: ...\r
344     def __delitem__(self, v: _KT) -> None: ...\r
345     def __getitem__(self, k: _KT) -> _VT: ...\r
346     def __iter__(self) -> Iterator[_KT]: ...\r
347     def __len__(self) -> int: ...\r