--- /dev/null
+# Stubs for collections\r
+\r
+# Based on http://docs.python.org/3.2/library/collections.html\r
+\r
+# These are not exported.\r
+import sys\r
+import typing\r
+from typing import (\r
+ TypeVar, Generic, Dict, overload, List, Tuple,\r
+ Any, Type, Optional, Union\r
+)\r
+# These are exported.\r
+from . import abc\r
+\r
+from typing import (\r
+ Callable as Callable,\r
+ Container as Container,\r
+ Hashable as Hashable,\r
+ Iterable as Iterable,\r
+ Iterator as Iterator,\r
+ Sized as Sized,\r
+ Generator as Generator,\r
+ ByteString as ByteString,\r
+ Reversible as Reversible,\r
+ Mapping as Mapping,\r
+ MappingView as MappingView,\r
+ ItemsView as ItemsView,\r
+ KeysView as KeysView,\r
+ ValuesView as ValuesView,\r
+ MutableMapping as MutableMapping,\r
+ Sequence as Sequence,\r
+ MutableSequence as MutableSequence,\r
+ MutableSet as MutableSet,\r
+ AbstractSet as Set,\r
+)\r
+if sys.version_info >= (3, 6):\r
+ from typing import (\r
+ Collection as Collection,\r
+ AsyncGenerator as AsyncGenerator,\r
+ )\r
+if sys.version_info >= (3, 5):\r
+ from typing import (\r
+ Awaitable as Awaitable,\r
+ Coroutine as Coroutine,\r
+ AsyncIterable as AsyncIterable,\r
+ AsyncIterator as AsyncIterator,\r
+ )\r
+\r
+_T = TypeVar('_T')\r
+_KT = TypeVar('_KT')\r
+_VT = TypeVar('_VT')\r
+\r
+\r
+# namedtuple is special-cased in the type checker; the initializer is ignored.\r
+if sys.version_info >= (3, 7):\r
+ def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,\r
+ rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...\r
+elif sys.version_info >= (3, 6):\r
+ def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,\r
+ verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...\r
+else:\r
+ def namedtuple(typename: str, field_names: Union[str, Iterable[str]],\r
+ verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...\r
+\r
+_UserDictT = TypeVar('_UserDictT', bound=UserDict)\r
+\r
+class UserDict(MutableMapping[_KT, _VT]):\r
+ data: Dict[_KT, _VT]\r
+ def __init__(self, dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ...\r
+ def __len__(self) -> int: ...\r
+ def __getitem__(self, key: _KT) -> _VT: ...\r
+ def __setitem__(self, key: _KT, item: _VT) -> None: ...\r
+ def __delitem__(self, key: _KT) -> None: ...\r
+ def __iter__(self) -> Iterator[_KT]: ...\r
+ def __contains__(self, key: object) -> bool: ...\r
+ def copy(self: _UserDictT) -> _UserDictT: ...\r
+ @classmethod\r
+ def fromkeys(cls: Type[_UserDictT], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _UserDictT: ...\r
+\r
+_UserListT = TypeVar('_UserListT', bound=UserList)\r
+\r
+class UserList(MutableSequence[_T]):\r
+ def __init__(self, initlist: Optional[Iterable[_T]] = ...) -> None: ...\r
+ def __lt__(self, other: object) -> bool: ...\r
+ def __le__(self, other: object) -> bool: ...\r
+ def __gt__(self, other: object) -> bool: ...\r
+ def __ge__(self, other: object) -> bool: ...\r
+ def __contains__(self, item: object) -> bool: ...\r
+ def __len__(self) -> int: ...\r
+ @overload\r
+ def __getitem__(self, i: int) -> _T: ...\r
+ @overload\r
+ def __getitem__(self, i: slice) -> Sequence[_T]: ...\r
+ @overload\r
+ def __setitem__(self, i: int, o: _T) -> None: ...\r
+ @overload\r
+ def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ...\r
+ def __delitem__(self, i: Union[int, slice]) -> None: ...\r
+ def __add__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...\r
+ def __iadd__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...\r
+ def __mul__(self: _UserListT, n: int) -> _UserListT: ...\r
+ def __imul__(self: _UserListT, n: int) -> _UserListT: ...\r
+ def append(self, item: _T) -> None: ...\r
+ def insert(self, i: int, item: _T) -> None: ...\r
+ def pop(self, i: int = ...) -> _T: ...\r
+ def remove(self, item: _T) -> None: ...\r
+ def clear(self) -> None: ...\r
+ def copy(self: _UserListT) -> _UserListT: ...\r
+ def count(self, item: _T) -> int: ...\r
+ def index(self, item: _T, *args: Any) -> int: ...\r
+ def reverse(self) -> None: ...\r
+ def sort(self, *args: Any, **kwds: Any) -> None: ...\r
+ def extend(self, other: Iterable[_T]) -> None: ...\r
+\r
+_UserStringT = TypeVar('_UserStringT', bound=UserString)\r
+\r
+class UserString(Sequence[str]):\r
+ def __init__(self, seq: object) -> None: ...\r
+ def __int__(self) -> int: ...\r
+ def __float__(self) -> float: ...\r
+ def __complex__(self) -> complex: ...\r
+ if sys.version_info >= (3, 5):\r
+ def __getnewargs__(self) -> Tuple[str]: ...\r
+ def __lt__(self, string: Union[str, UserString]) -> bool: ...\r
+ def __le__(self, string: Union[str, UserString]) -> bool: ...\r
+ def __gt__(self, string: Union[str, UserString]) -> bool: ...\r
+ def __ge__(self, string: Union[str, UserString]) -> bool: ...\r
+ def __contains__(self, char: object) -> bool: ...\r
+ def __len__(self) -> int: ...\r
+ # It should return a str to implement Sequence correctly, but it doesn't.\r
+ def __getitem__(self: _UserStringT, i: Union[int, slice]) -> _UserStringT: ... # type: ignore\r
+ def __add__(self: _UserStringT, other: object) -> _UserStringT: ...\r
+ def __mul__(self: _UserStringT, n: int) -> _UserStringT: ...\r
+ def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ...\r
+ def capitalize(self: _UserStringT) -> _UserStringT: ...\r
+ if sys.version_info >= (3, 5):\r
+ def casefold(self: _UserStringT) -> _UserStringT: ...\r
+ def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...\r
+ def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
+ def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ...\r
+ def endswith(self, suffix: Union[str, Tuple[str, ...]], start: int = ..., end: int = ...) -> bool: ...\r
+ def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ...\r
+ def find(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
+ def format(self, *args: Any, **kwds: Any) -> str: ...\r
+ if sys.version_info >= (3, 5):\r
+ def format_map(self, mapping: Mapping[str, Any]) -> str: ...\r
+ def index(self, sub: str, start: int = ..., end: int = ...) -> int: ...\r
+ def isalpha(self) -> bool: ...\r
+ def isalnum(self) -> bool: ...\r
+ def isdecimal(self) -> bool: ...\r
+ def isdigit(self) -> bool: ...\r
+ def isidentifier(self) -> bool: ...\r
+ def islower(self) -> bool: ...\r
+ def isnumeric(self) -> bool: ...\r
+ if sys.version_info >= (3, 5):\r
+ def isprintable(self) -> bool: ...\r
+ def isspace(self) -> bool: ...\r
+ def istitle(self) -> bool: ...\r
+ def isupper(self) -> bool: ...\r
+ def join(self, seq: Iterable[str]) -> str: ...\r
+ def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...\r
+ def lower(self: _UserStringT) -> _UserStringT: ...\r
+ def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...\r
+ if sys.version_info >= (3, 5):\r
+ @staticmethod\r
+ @overload\r
+ def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ...\r
+ @staticmethod\r
+ @overload\r
+ def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ...\r
+ def partition(self, sep: str) -> Tuple[str, str, str]: ...\r
+ def replace(self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...) -> _UserStringT: ...\r
+ def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
+ def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...\r
+ def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...\r
+ def rpartition(self, sep: str) -> Tuple[str, str, str]: ...\r
+ def rstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...\r
+ def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...\r
+ def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...\r
+ def splitlines(self, keepends: bool = ...) -> List[str]: ...\r
+ def startswith(self, prefix: Union[str, Tuple[str, ...]], start: int = ..., end: int = ...) -> bool: ...\r
+ def strip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...\r
+ def swapcase(self: _UserStringT) -> _UserStringT: ...\r
+ def title(self: _UserStringT) -> _UserStringT: ...\r
+ def translate(self: _UserStringT, *args: Any) -> _UserStringT: ...\r
+ def upper(self: _UserStringT) -> _UserStringT: ...\r
+ def zfill(self: _UserStringT, width: int) -> _UserStringT: ...\r
+\r
+\r
+# Technically, deque only derives from MutableSequence in 3.5 (before then, the insert and index\r
+# methods did not exist).\r
+# But in practice it's not worth losing sleep over.\r
+class deque(MutableSequence[_T], Generic[_T]):\r
+ @property\r
+ def maxlen(self) -> Optional[int]: ...\r
+ def __init__(self, iterable: Iterable[_T] = ...,\r
+ maxlen: int = ...) -> None: ...\r
+ def append(self, x: _T) -> None: ...\r
+ def appendleft(self, x: _T) -> None: ...\r
+ def clear(self) -> None: ...\r
+ if sys.version_info >= (3, 5):\r
+ def copy(self) -> deque[_T]: ...\r
+ def count(self, x: _T) -> int: ...\r
+ def extend(self, iterable: Iterable[_T]) -> None: ...\r
+ def extendleft(self, iterable: Iterable[_T]) -> None: ...\r
+ def insert(self, i: int, x: _T) -> None: ...\r
+ def index(self, x: _T, start: int = ..., stop: int = ...) -> int: ...\r
+ def pop(self, i: int = ...) -> _T: ...\r
+ def popleft(self) -> _T: ...\r
+ def remove(self, value: _T) -> None: ...\r
+ def reverse(self) -> None: ...\r
+ def rotate(self, n: int) -> None: ...\r
+\r
+ def __len__(self) -> int: ...\r
+ def __iter__(self) -> Iterator[_T]: ...\r
+ def __str__(self) -> str: ...\r
+ def __hash__(self) -> int: ...\r
+\r
+ # These methods of deque don't really take slices, but we need to\r
+ # define them as taking a slice to satisfy MutableSequence.\r
+ @overload\r
+ def __getitem__(self, index: int) -> _T: ...\r
+ @overload\r
+ def __getitem__(self, s: slice) -> Sequence[_T]:\r
+ raise TypeError\r
+ @overload\r
+ def __setitem__(self, i: int, x: _T) -> None: ...\r
+ @overload\r
+ def __setitem__(self, s: slice, o: Iterable[_T]) -> None:\r
+ raise TypeError\r
+ @overload\r
+ def __delitem__(self, i: int) -> None: ...\r
+ @overload\r
+ def __delitem__(self, s: slice) -> None:\r
+ raise TypeError\r
+\r
+ def __contains__(self, o: object) -> bool: ...\r
+ def __reversed__(self) -> Iterator[_T]: ...\r
+\r
+ if sys.version_info >= (3, 5):\r
+ def __add__(self, other: deque[_T]) -> deque[_T]: ...\r
+ def __mul__(self, other: int) -> deque[_T]: ...\r
+ def __imul__(self, other: int) -> None: ...\r
+\r
+_CounterT = TypeVar('_CounterT', bound=Counter)\r
+\r
+class Counter(Dict[_T, int], Generic[_T]):\r
+ @overload\r
+ def __init__(self, **kwargs: int) -> None: ...\r
+ @overload\r
+ def __init__(self, mapping: Mapping[_T, int]) -> None: ...\r
+ @overload\r
+ def __init__(self, iterable: Iterable[_T]) -> None: ...\r
+ def copy(self: _CounterT) -> _CounterT: ...\r
+ def elements(self) -> Iterator[_T]: ...\r
+\r
+ def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...\r
+\r
+ @overload\r
+ def subtract(self, __mapping: Mapping[_T, int]) -> None: ...\r
+ @overload\r
+ def subtract(self, iterable: Iterable[_T]) -> None: ...\r
+\r
+ # The Iterable[Tuple[...]] argument type is not actually desirable\r
+ # (the tuples will be added as keys, breaking type safety) but\r
+ # it's included so that the signature is compatible with\r
+ # Dict.update. Not sure if we should use '# type: ignore' instead\r
+ # and omit the type from the union.\r
+ @overload\r
+ def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ...\r
+ @overload\r
+ def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...\r
+ @overload\r
+ def update(self, **kwargs: int) -> None: ...\r
+\r
+ def __add__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __and__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __or__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __pos__(self) -> Counter[_T]: ...\r
+ def __neg__(self) -> Counter[_T]: ...\r
+ def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __isub__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+ def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...\r
+\r
+_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)\r
+\r
+class _OrderedDictKeysView(KeysView[_KT], Reversible[_KT]):\r
+ def __reversed__(self) -> Iterator[_KT]: ...\r
+class _OrderedDictItemsView(ItemsView[_KT, _VT], Reversible[Tuple[_KT, _VT]]):\r
+ def __reversed__(self) -> Iterator[Tuple[_KT, _VT]]: ...\r
+class _OrderedDictValuesView(ValuesView[_VT], Reversible[_VT]):\r
+ def __reversed__(self) -> Iterator[_VT]: ...\r
+\r
+class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):\r
+ def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...\r
+ def move_to_end(self, key: _KT, last: bool = ...) -> None: ...\r
+ def copy(self: _OrderedDictT) -> _OrderedDictT: ...\r
+ def __reversed__(self) -> Iterator[_KT]: ...\r
+ def keys(self) -> _OrderedDictKeysView[_KT]: ...\r
+ def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...\r
+ def values(self) -> _OrderedDictValuesView[_VT]: ...\r
+\r
+_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)\r
+\r
+class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):\r
+ default_factory = ... # type: Callable[[], _VT]\r
+\r
+ @overload\r
+ def __init__(self, **kwargs: _VT) -> None: ...\r
+ @overload\r
+ def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ...\r
+ @overload\r
+ def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ...\r
+ @overload\r
+ def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
+ map: Mapping[_KT, _VT]) -> None: ...\r
+ @overload\r
+ def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
+ map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...\r
+ @overload\r
+ def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
+ iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...\r
+ @overload\r
+ def __init__(self, default_factory: Optional[Callable[[], _VT]],\r
+ iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...\r
+ def __missing__(self, key: _KT) -> _VT: ...\r
+ # TODO __reversed__\r
+ def copy(self: _DefaultDictT) -> _DefaultDictT: ...\r
+\r
+class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):\r
+ def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...\r
+\r
+ @property\r
+ def maps(self) -> List[Mapping[_KT, _VT]]: ...\r
+\r
+ def new_child(self, m: Mapping[_KT, _VT] = ...) -> typing.ChainMap[_KT, _VT]: ...\r
+\r
+ @property\r
+ def parents(self) -> typing.ChainMap[_KT, _VT]: ...\r
+\r
+ def __setitem__(self, k: _KT, v: _VT) -> None: ...\r
+ def __delitem__(self, v: _KT) -> None: ...\r
+ def __getitem__(self, k: _KT) -> _VT: ...\r
+ def __iter__(self) -> Iterator[_KT]: ...\r
+ def __len__(self) -> int: ...\r