1# This file should eventually track typeshed a lot more closely, to
2# minimise the diffs we have to maintain here.
3
4
5from typing import (
6    AbstractSet, Any, AsyncGenerator, Awaitable, BinaryIO, Callable, Coroutine,
7    Dict, FrozenSet, Generator, Generic, Hashable, IO, ItemsView, Iterable,
8    Iterator, KeysView, List, Literal, Mapping, MutableSequence, Optional,
9    overload, Protocol, Reversible, Sequence, Set, Sized, SupportsAbs,
10    SupportsBytes, SupportsComplex, SupportsFloat, SupportsInt, TextIO, Tuple,
11    Type, Union, ValuesView)
12
13if sys.version_info >= (3, 8):
14    from typing import SupportsIndex
15
16# "_T", "_K", and "_V" are hardcoded in abstract.py
17_T = TypeVar('_T')
18_T2 = TypeVar('_T2')
19_T3 = TypeVar('_T3')
20_T4 = TypeVar('_T4')
21_K = TypeVar('_K')
22_V = TypeVar('_V')
23_K2 = TypeVar('_K2')
24_V2 = TypeVar('_V2')
25_NUMBER = TypeVar('_NUMBER', bound=complex)
26# See b/142884093. We redefine AnyStr rather than importing it to avoid pytype
27# mistakenly treating it as a public builtin.
28_AnyStr = TypeVar('_AnyStr', bytes, str)
29
30# isinstance() and issubclass() can take a type or an arbitrarily nested
31# tuple of types. This adds support for a few levels; in theory we want
32# TypeTuple = type or tuple[TypeTuple]
33TypeTuple = Union[type, tuple[Union[type, tuple[type, ...]], ...]]
34
35def __import__(name: Union[str, bytes, bytearray], *args, **kwargs) -> module: ...
36def abs(x) -> Any: ...
37def all(iterable) -> bool: ...
38def any(iterable) -> bool: ...
39def ascii(__obj: object) -> str: ...
40def apply(object: Callable, *args, **kwargs) -> NoneType: ...
41def assert_type(*args): ...
42def bin(number: Union[int, float]) -> str: ...
43if sys.version_info >= (3, 7):
44    def breakpoint(*args, **kwargs) -> NoneType: ...
45def callable(obj) -> bool: ...
46def chr(i: int) -> str: ...
47def cmp(x, y) -> int: ...
48def coerce(x: int, y: int) -> tuple[int, int]: ...
49def coerce(x: Union[int, float], y: float) -> tuple[float, float]: ...
50def coerce(x: Union[int, float, complex], y: complex) -> tuple[complex, complex]: ...
51def coerce(x: float, y: int) -> tuple[float, float]: ...
52def coerce(x, y) -> tuple[object, object]: ...
53def coerce(x: list[_T], y: list[_T]) -> tuple[list[_T], list[_T]]: ...
54def coerce(x: tuple[_T, ...], y: tuple[_T, ...]) -> tuple[tuple[_T, ...], tuple[_T, ...]]: ...
55def coerce(x: complex, y: Union[int, float]) -> tuple[complex, complex]: ...
56def coerce(x: Callable, y: Callable) -> tuple[Callable, Callable]: ...
57def coerce(x: type, y: type) -> tuple[type, type]: ...
58def coerce(x: _T, y: _T) -> tuple[_T, _T]: ...  # E.g. coerce([], [1]) -> ([], [1])
59def compile(source, filename: str, mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> code: ...
60def delattr(object, name: Union[str, bytes, bytearray]) -> None: ...
61def dir(*args, **kwargs) -> list[str]: ...
62def divmod(x: int, y: int) -> tuple[int, int]: ...
63def divmod(x: Union[int, float], y: Union[int, float]) -> tuple[float, float]: ...
64def divmod(x: Union[int, float, complex], y: Union[int, float, complex]) -> tuple[complex, complex]: ...
65def eval(src, *args, **kwargs) -> Any: ...  # Can't say *anything* about the result -- different from "-> object"
66def exec(src, *args, **kwargs) -> NoneType: ...
67def execfile(filename: str, *args, **kwargs) -> NoneType: ...
68def exit(code: Any = ...) -> NoneType:
69    raise SystemExit()
70def filter(function: None, iterable: Iterable[Optional[_T]]) -> Iterator[_T]: ...
71def filter(function: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ...
72def format(value, *args, **kwargs) -> str: ...
73def getattr(value, attr: str, *args, **kwargs) -> Any: ...
74def globals() -> dict[str, Any]: ...
75def hasattr(object, name: str) -> bool: ...
76def hash(obj) -> int: ...
77def hex(number: int) -> str: ...
78def id(obj) -> int: ...
79def input(prompt: str = ...) -> str: ...
80def intern(string: Union[str, bytearray]) -> str: ...
81def isinstance(object, class_or_type_or_tuple: TypeTuple) -> bool: ...
82def issubclass(cls: type, class_or_type_or_tuple: TypeTuple) -> bool: ...
83def iter(collection: bytearray) -> bytearray_iterator: ...
84def iter(collection: str) -> Iterator[str]: ...
85def iter(collection: list[_T]) -> listiterator[_T]: ...
86def iter(collection: tuple[_T, ...]) -> tupleiterator[_T]: ...
87def iter(collection: set[_T]) -> setiterator[_T]: ...
88def iter(collection: dict[_T, _T2]) -> Iterator[_T]: ...
89def iter(collection: Generator[_T]) -> Generator[_T]: ...
90def iter(collection: Iterable[_T]) -> Iterator[_T]: ...
91def iter(func: typing.Callable[[], Union[_T, _T2]], sentinel: _T) -> Iterator[_T2]: ...
92def len(obj: Sized) -> int: ...
93def locals() -> dict[str, object]: ...
94def map(function, *sequences: Iterable[nothing]) -> Iterator[nothing]: ...
95def map(function: Callable[..., _T], *sequences: Iterable) -> Iterator[_T]: ...
96def max(iterable: Iterable[_T], key: Callable = ..., default: Any = ...) -> _T: ...
97def max(arg1: _T, arg2: _T2, *, key: Callable = ...) -> Union[_T, _T2]: ...
98def max(arg1: _T, arg2: _T2, arg3: _T3, *, key: Callable = ...) -> Union[_T, _T2, _T3]: ...
99def max(arg1: _T, arg2: _T2, arg3: _T3, arg4: _T4, *, key: Callable = ...) -> Union[_T, _T2, _T3, _T4]: ...
100def max(arg1: _T, arg2: _T, arg3: _T, arg4: _T, arg5: _T, *args: _T, key: Callable = ...) -> _T: ...
101def min(iterable: Iterable[_T], key: Callable = ..., default: Any = ...) -> _T: ...
102def min(arg1: _T, arg2: _T2, *, key: Callable = ...) -> Union[_T, _T2]: ...
103def min(arg1: _T, arg2: _T2, arg3: _T3, *, key: Callable = ...) -> Union[_T, _T2, _T3]: ...
104def min(arg1: _T, arg2: _T2, arg3: _T3, arg4: _T4, *, key: Callable = ...) -> Union[_T, _T2, _T3, _T4]: ...
105def min(arg1: _T, arg2: _T, arg3: _T, arg4: _T, arg5: _T, *args: _T, key: Callable = ...) -> _T: ...
106def next(iterator: Iterator[_T], default: _T2 = ...) -> Union[_T, _T2]: ...
107def oct(number: int) -> str: ...
108def ord(c: Union[str, bytes]) -> int: ...
109def pow(x: int, y: int, *args, **kwargs) -> Union[float, int]: ...
110def pow(x: Union[int, float, complex], y: complex, *args, **kwargs) -> complex: ...
111def pow(x: Union[int, float], y: float, *args, **kwargs) -> float: ...
112def pow(x: float, y: int, *args, **kwargs) -> float: ...
113def pow(x: complex, y: Union[int, float], *args, **kwargs) -> complex: ...
114def print(*args, **kwargs) -> NoneType: ...
115def quit() -> NoneType:
116    raise SystemExit()
117def reduce(function: Callable[..., _T], iterable: Iterable[_T2]) -> Union[_T, _T2]: ...
118def reduce(function: Callable, iterable: Iterable[nothing], initial: _T) -> _T: ...
119def reduce(function: Callable[..., _T], iterable: Iterable, initial) -> _T: ...
120# No reload() in Python3
121def reload(mod: module) -> module: ...
122def repr(x) -> str: ...
123def round(number: Union[int, float, typing.SupportsRound]) -> int: ...
124def round(number: Union[int, float, typing.SupportsRound], *args, **kwargs) -> float: ...
125def setattr(object, name: str, value) -> NoneType: ...
126def sorted(iterable: Iterable[_T], *args, **kwargs) -> list[_T]: ...
127def sum(iterable: Iterable[_NUMBER]) -> _NUMBER: ...
128def sum(iterable: Iterable[_T], start: _T) -> _T: ...
129def vars(*args, **kwargs) -> dict[str, Any]: ...
130def zip() -> Iterator[nothing]: ...
131def zip(seq1: Iterable[nothing]) -> Iterator[nothing]: ...
132def zip(seq1: Iterable[_T]) -> Iterator[Tuple[_T]]: ...
133def zip(seq1: Iterable[nothing], seq2: Iterable) -> Iterator[nothing]: ...
134def zip(seq1: Iterable, seq2: Iterable[nothing]) -> Iterator[nothing]: ...
135def zip(seq1: Iterable[_T], seq2: Iterable[_T2]) -> Iterator[Tuple[_T, _T2]]: ...
136def zip(seq1, seq2, seq3, *seqs: Iterable) -> Iterator[tuple]: ...
137
138# Keyword constants cannot be assigned here; they are defined in the parser.
139# False: bool = ...
140# True: bool = ...
141# None: NoneType = ...
142# __debug__: bool = ...
143
144NotImplemented = ...  # type: NotImplementedType
145Ellipsis = ...  # type: ellipsis
146
147class object():
148    __slots__ = []  # if used as base class
149    __bases__ = ...  # type: Tuple[Any, ...]
150    __dict__ = ...  # type: Dict[str, Any]
151    __doc__ = ...  # type: str
152    __mro__ = ...  # type: list[Any]
153    __name__ = ...  # type: str
154    __subclasses__ = ...  # type: Any
155    __subclasshook__ = ...  # type: Any
156    # InterpreterClass will contain this, too:
157    __module__ = ...  # type: str
158    def __init__(self) -> NoneType: ...
159    # Used by special_builtins.Object to handle super.__init__.
160    def __init__extra_args(self, *args, **kwargs) -> NoneType: ...
161    def __sizeof__(self) -> int: ...
162    def __str__(self) -> str: ...
163    def __repr__(self) -> str: ...
164    def __cmp__(self, y) -> bool: ...
165    def __delattr__(self, name: str) -> None: ...
166    def __eq__(self, other) -> bool: ...
167    def __ne__(self, other) -> bool: ...
168    def __ge__(self, other) -> bool: ...
169    def __gt__(self, other) -> bool: ...
170    def __le__(self, other) -> bool: ...
171    def __lt__(self, other) -> bool: ...
172    def __hash__(self) -> int: ...
173    def __setattr__(self, name, value) -> None: ...
174    def __getattribute__(self, name) -> Any: ...
175    def __new__(cls: Type[_T]) -> _T: ...
176    # Used by special_builtins.Object to handler super.__new__.
177    @staticmethod
178    def __new__extra_args(cls: Type[_T], *args, **kwargs) -> _T: ...
179    if sys.version_info >= (3, 6):
180        @classmethod
181        def __init_subclass__(cls) -> None: ...
182
183# old style class. classobj is in fact a subclass of object in Python.
184class classobj(object):
185    __slots__ = []
186    __bases__ = ...  # type: Tuple[Any, ...]
187    __dict__ = ...  # type: Dict[str, Any]
188    __doc__ = ...  # type: str
189    __name__ = ...  # type: str
190    def __init__(self) -> NoneType: ...
191    def __repr__(self) -> str: ...
192    def __cmp__(self, y) -> bool: ...
193
194# Not actually a builtin
195class NotImplementedType(bool):
196    pass
197
198class NoneType(object):
199    # Note that we don't do __slots__ = [] here. (I.e., we ignore STORE_ATTR
200    # errors on NoneType). This is symmetric with LOAD_ATTR.
201    pass
202
203class ellipsis(object):
204    __slots__ = []
205
206class property(object):
207    def __init__(self, fget=..., fset=..., fdel=..., doc=...) -> NoneType: ...
208    def __get__(self, *args, **kwargs) -> Any: ...
209    def __set__(self, *args, **kwargs) -> Any: ...
210    def __delete__(self, *args, **kwargs) -> Any: ...
211
212# staticmethod and classmethod are handled in special_builtins.py.
213class staticmethod(typing.Callable):
214    __slots__ = []
215    def __init__(self, func) -> NoneType: ...
216    def __get__(self, *args, **kwargs) -> Any: ...
217
218class classmethod(typing.Callable):
219    __slots__ = []
220    def __init__(self, func) -> NoneType: ...
221    def __get__(self, *args, **kwargs) -> Any: ...
222
223_T_str = TypeVar('_T_str', bound=str)
224class str(Sequence[str], Hashable):
225    __slots__ = []
226    def __new__(cls: Type[_T_str], object = ..., encoding: str = ..., errors: str = ...) -> _T_str: ...
227    def __init__(self, object) -> NoneType: ...
228    def __init__(self, bytes: bytes, encoding: str = ..., errors: str = ...) -> NoneType: ...
229    def __init__(self) -> NoneType: ...
230    def __iter__(self) -> Iterator[str]: ...
231    def __add__(self, y: str) -> str: ...
232    def __contains__(self, y) -> bool: ...
233    def __getitem__(self, index: Union[int, slice]) -> str: ...
234    def __getslice__(self, i: Optional[int], j: Optional[int]) -> str: ...
235    def __len__(self) -> int: ...
236    def __mod__(self, y) -> str: ...
237    def __mul__(self, n: int) -> str: ...
238    def __rmul__(self, n: int) -> str: ...
239    def __hash__(self) -> int: ...
240    def capitalize(self) -> str: ...
241    def casefold(self) -> str: ...  # see section 3.13 of the Unicode standard
242    def center(self, width: int, fillchar: str = ...) -> str: ...
243    def count(self, sub: str, *args, **kwargs) -> int: ...
244    def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
245    def endswith(self, suffix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
246    def expandtabs(self, tabsize: int = ...) -> str: ...
247    def find(self, sub: str, *args, **kwargs) -> int: ...
248    def format(self, *args, **kwargs) -> str: ...
249    def format_map(self, *args, **kwargs) -> str: ...
250    def index(self, sub: str, *args, **kwargs) -> int: ...
251    def isalnum(self) -> bool: ...
252    def isalpha(self) -> bool: ...
253    if sys.version_info >= (3, 7):
254        def isascii(self) -> bool: ...
255    def isdecimal(self) -> bool: ...
256    def isdigit(self) -> bool: ...
257    def isidentifier(self) -> bool: ...
258    def islower(self) -> bool: ...
259    def isnumeric(self) -> bool: ...
260    def isprintable(self) -> bool: ...
261    def isspace(self) -> bool: ...
262    def istitle(self) -> bool: ...
263    def isupper(self) -> bool: ...
264    def join(self, iterable: Union[str, Iterable[str]]) -> str: ...
265    def join(self, iterable: Iterable[nothing]) -> str: ...
266    def ljust(self, width: int, fillchar: str = ...) -> str: ...
267    def lower(self) -> str: ...
268    def lstrip(self, chars: Optional[str] = ...) -> str: ...
269    def partition(self, sep: str) -> Tuple[str, str, str]: ...
270    def replace(self, old: str, new: str, *args, **kwargs) -> str: ...
271    def rfind(self, sub: str, *args, **kwargs) -> int: ...
272    def rindex(self, sub: str, *args, **kwargs) -> int: ...
273    def rjust(self, width: int, *args, **kwargs) -> str: ...
274    def rpartition(self, sep: str) -> tuple[str, str, str]: ...
275    def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
276    def rstrip(self, chars: Optional[str] = ...) -> str: ...
277    def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
278    def splitlines(self, keepends: bool = ...) -> List[str]: ...
279    def startswith(self, prefix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
280    def strip(self, chars: Optional[str] = ...) -> str: ...
281    def swapcase(self) -> str: ...
282    def title(self) -> str: ...
283    def translate(self, table: Union[Mapping, Sequence]) -> str: ...
284    def upper(self) -> str: ...
285    def zfill(self, width: int) -> str: ...
286    @staticmethod
287    def maketrans(*args, **kwargs) -> dict: ...
288
289class bytes(Sequence[int]):
290    def __init__(self, ints: Iterable[int]) -> NoneType: ...
291    def __init__(self, bytes: SupportsBytes) -> NoneType: ...
292    def __init__(self, string: str, encoding: str, errors: str = ...) -> NoneType: ...
293    def __init__(self, length: int) -> NoneType: ...
294    def __init__(self) -> NoneType: ...
295
296    def __add__(self, s: bytes) -> bytes: ...
297    def __contains__(self, o) -> bool: ...
298    def __float__(self) -> float: ...
299    def __getitem__(self, i: int) -> int: ...
300    def __getitem__(self, s: slice) -> bytes: ...
301    def __int__(self) -> int: ...
302    def __iter__(self) -> Iterator[int]: ...
303    def __len__(self) -> int: ...
304    def __mod__(self, value) -> bytes: ...
305    def __mul__(self, n: int) -> bytes: ...
306    def __rmul__(self, n: int) -> bytes: ...
307
308    def capitalize(self) -> bytes: ...
309    def center(self, width: int, fillchar: bytes = ...) -> bytes: ...
310    def count(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
311    def decode(self, encoding: str = ..., errors: str = ...) -> str: ...
312    def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
313    def expandtabs(self, tabsize: int = ...) -> bytes: ...
314    def find(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
315    def hex(self) -> str: ...
316    def index(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
317    def isalnum(self) -> bool: ...
318    def isalpha(self) -> bool: ...
319    if sys.version_info >= (3, 7):
320        def isascii(self) -> bool: ...
321    def isdigit(self) -> bool: ...
322    def islower(self) -> bool: ...
323    def isspace(self) -> bool: ...
324    def istitle(self) -> bool: ...
325    def isupper(self) -> bool: ...
326    def join(self, iterable: Iterable[bytes]) -> bytes: ...
327    def ljust(self, width: int, fillchar: bytes = ...) -> bytes: ...
328    def lower(self) -> bytes: ...
329    def lstrip(self, chars: Optional[bytes] = ...) -> bytes: ...
330    def partition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ...
331    def replace(self, old: bytes, new: bytes, count: int = ...) -> bytes: ...
332    def rfind(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
333    def rindex(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
334    def rjust(self, width: int, fillchar: bytes = ...) -> bytes: ...
335    def rpartition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ...
336    def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ...
337    def rstrip(self, chars: Optional[bytes] = ...) -> bytes: ...
338    def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ...
339    def splitlines(self, keepends: bool = ...) -> List[bytes]: ...
340    def startswith(self, prefix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
341    def strip(self, chars: Optional[bytes] = ...) -> bytes: ...
342    def swapcase(self) -> bytes: ...
343    def title(self) -> bytes: ...
344    def translate(self, table: Optional[bytes], delete: bytes = ...) -> bytes: ...
345    def upper(self) -> bytes: ...
346    def zfill(self, width: int) -> bytes: ...
347
348    @classmethod
349    def fromhex(cls, s: str) -> bytes: ...
350    @classmethod
351    def maketrans(cls, frm: bytes, to: bytes) -> bytes: ...
352
353class bytearray(MutableSequence[int]):
354    __slots__ = []
355    def __init__(self, iterable_of_ints) -> NoneType: ...
356    def __init__(self) -> NoneType: ...
357    def __init__(self, source: str, encoding: str, errors: str = ...) -> NoneType: ...
358    def __add__(self, y: Union[str, bytearray]) -> bytearray: ...
359    def __alloc__(self) -> int: ...
360    def __contains__(self, y: Union[str, int, bytearray, bytes]) -> bool: ...
361    def __delitem__(self, y: Union[int, slice]) -> NoneType: ...
362    def __getitem__(self, index: int) -> int: ...
363    def __getitem__(self, index: slice) -> bytearray: ...
364    def __iter__(self) -> bytearray_iterator: ...
365    def __len__(self) -> int: ...
366    def __mul__(self, n: int) -> bytearray: ...
367    def __setitem__(self, index: int, y: int) -> None: ...
368    def __setitem__(self, index: slice, y: Iterable[Union[int, bytes]]) -> None: ...
369    def append(self, int: int) -> NoneType: ...
370    def capitalize(self) -> bytearray: ...
371    def center(self, width: int, *args, **kwargs) -> bytearray: ...
372    def clear(self) -> None: ...
373    def copy(self) -> bytearray: ...
374    def count(self, sub: bytearray, *args, **kwargs) -> int: ...
375    def decode(self, *args, **kwargs) -> str: ...
376    def endswith(self, suffix: Union[bytes, bytearray, tuple[Union[bytes, bytearray], ...]], *args, **kwargs) -> bool: ...
377    def expandtabs(self, *args, **kwargs) -> bytearray: ...
378    def extend(self, iterable_int) -> NoneType: ...
379    def find(self, sub: Union[bytes, bytearray], *args, **kwargs) -> int: ...
380    def index(self, sub: Union[bytes, bytearray], *args, **kwargs) -> int: ...
381    def insert(self, index: int, int: Union[bytes, int]) -> NoneType: ...
382    def isalnum(self) -> bool: ...
383    def isalpha(self) -> bool: ...
384    if sys.version_info >= (3, 7):
385        def isascii(self) -> bool: ...
386    def isdigit(self) -> bool: ...
387    def islower(self) -> bool: ...
388    def isspace(self) -> bool: ...
389    def istitle(self) -> bool: ...
390    def isupper(self) -> bool: ...
391    def join(self, iterable: Iterable[Union[nothing, bytes, bytearray]]) -> bytearray: ...
392    def ljust(self, width: int, *args, **kwargs) -> bytearray: ...
393    def lower(self) -> bytearray: ...
394    def lstrip(self, *args, **kwargs) -> bytearray: ...
395    def partition(self, sep: Union[bytes, int, bytearray, Iterator]) -> tuple[bytearray, bytearray, bytearray]: ...
396    def pop(self, *args, **kwargs) -> int: ...
397    def remove(self, int: Union[bytes, int]) -> NoneType: ...
398    def replace(self, old: Union[bytes, bytearray], new: Union[bytes, bytearray], *args, **kwargs) -> bytearray: ...
399    def reverse(self) -> NoneType: ...
400    def rfind(self, sub: Union[bytes, bytearray], *args, **kwargs) -> int: ...
401    def rindex(self, sub: Union[bytes, bytearray], *args, **kwargs) -> int: ...
402    def rjust(self, width: int, *args, **kwargs) -> bytearray: ...
403    def rpartition(self, sep: Union[bytes, int, bytearray, Iterator]) -> tuple[bytearray, bytearray, bytearray]: ...
404    def rsplit(self, sep: Union[bytes, bytearray], *args, **kwargs) -> list[bytearray]: ...
405    def rsplit(self) -> list[bytearray]: ...
406    def rstrip(self, *args, **kwargs) -> bytearray: ...
407    def split(self, *args, **kwargs) -> list[bytearray]: ...
408    def splitlines(self, *args, **kwargs) -> list[bytearray]: ...
409    def startswith(self, prefix: Union[bytes, bytearray, tuple[Union[bytes, bytearray], ...]], *args, **kwargs) -> bool: ...
410    def strip(self, *args, **kwargs) -> bytearray: ...
411    def swapcase(self) -> bytearray: ...
412    def title(self) -> bytearray: ...
413    def upper(self) -> bytearray: ...
414    def zfill(self, width: int) -> bytearray: ...
415
416    @classmethod
417    def fromhex(cls, string: str) -> bytearray: ...
418
419class bytearray_iterator(Iterator[int]):
420    __slots__ = []
421    def __iter__(self) -> bytearray_iterator: ...
422    def __next__(self) -> int: ...
423
424class dict_keys(KeysView[_T]):
425    __slots__ = []
426    def __contains__(self, y) -> bool: ...
427    def __iter__(self) -> Iterator[_T]: ...
428    def __len__(self) -> int: ...
429    def __and__(self, y: Iterable) -> set[_T]: ...
430    def __sub__(self, y: Iterable) -> set[_T]: ...
431    def __or__(self, y: Iterable[_T2]) -> set[Union[_T, _T2]]: ...
432    def __xor__(self, y: Iterable[_T2]) -> set[Union[_T, _T2]]: ...
433
434class dict_values(ValuesView[_T]):
435    __slots__ = []
436    def __iter__(self) -> Iterator[_T]: ...
437    def __len__(self) -> int: ...
438
439class dict_items(ItemsView[_K, _V], object):
440    __slots__ = []
441    def __and__(self, y: Union[set, dict_items]) -> set[tuple[_K, _V]]: ...
442    def __or__(self, y: Union[set, dict_items[_K2, _V2]]) -> set[tuple[Union[_K, _K2], Union[_V, _V2]]]: ...
443    def __xor__(self, y: Union[set, dict_items[_K2, _V2]]) -> set[tuple[Union[_K, _K2], Union[_V, _V2]]]: ...
444    def __sub__(self, y: Union[set, dict_items[_K2, _V2]]) -> set[tuple[_K, _V]]: ...
445    def __contains__(self, y) -> bool: ...
446    def __iter__(self) -> Iterator[Tuple[_K,_V]]: ...
447    def __len__(self) -> int: ...
448
449class dict(Dict[_K, _V]):
450    __slots__ = []
451    def __init__(self) -> NoneType:
452        self = dict[nothing, nothing]
453    def __init__(self, list: list[nothing]) -> NoneType:
454        self = dict[nothing, nothing]
455    def __init__(self, mapping: Mapping[_K2, _V2]) -> NoneType:
456        self = dict[_K2, _V2]
457    def __init__(self, iterable: Iterable[tuple[_K2, _V2]]) -> NoneType:
458        self = dict[_K2, _V2]
459    def __init__(self, *args, **kwargs) -> NoneType:
460        self = dict[Any, Any]
461    def __delitem__(self, y: _K) -> NoneType: ...
462    def __iter__(self) -> Iterator[_K]: ...
463    def __setitem__(self, i: _K2, y: _V2) -> NoneType:
464      self = dict[Union[_K, _K2], Union[_V, _V2]]
465    def clear(self) -> NoneType:
466        self = dict[nothing, nothing]
467    def copy(self: _T) -> _T: ...
468    @staticmethod
469    def fromkeys(keys: Iterable[_K]) -> Dict[_K, NoneType]: ...
470    @staticmethod
471    def fromkeys(keys: Iterable[_K], value: _V) -> Dict[_K, _V]: ...
472    def items(self) -> dict_items[_K, _V]: ...
473    def keys(self) -> dict_keys[_K]: ...
474    def pop(self, k) -> _V: ...
475    def pop(self, k, d: _V2) -> Union[_V, _V2]: ...
476    def setdefault(self, k: _K2) -> Union[_V, NoneType]:
477        self = dict[Union[_K, _K2], Union[_V, NoneType]]
478    def setdefault(self, k: _K2, v: _V2) -> Union[_V, _V2]:
479        self = dict[Union[_K, _K2], Union[_V, _V2]]
480    def update(self) -> None: ...
481    def update(self, other: dict[_K2, _V2]) -> None:
482        self = dict[Union[_K, _K2], Union[_V, _V2]]
483    def update(self, **kwargs: _V2) -> None:
484        self = dict[Union[_K, str], Union[_V, _V2]]
485    def update(self, E, *args, **kwargs) -> None:
486        self = dict[Any, Any]
487    def values(self) -> dict_values[_V]: ...
488
489class listiterator(Iterator[_T]):
490    __slots__ = []
491    def __iter__(self) -> listiterator[_T]: ...
492    def __next__(self) -> _T: ...
493
494class enumerate(Iterator[tuple[int, _T]]):
495    __slots__ = []
496    def __init__(self, iterable: Iterable[_T2], start: int = ...) -> NoneType:
497      self = enumerate[_T2]
498    def __iter__(self) -> enumerate[_T]: ...  # enumerate.__iter__() returns itself
499    def __next__(self) -> tuple[int, _T]: ...
500
501class listreverseiterator(Iterator[_T]):
502    __slots__ = []
503    def __iter__(self) -> listreverseiterator[_T]: ...
504    def __next__(self) -> _T: ...
505
506class list(List[_T]):
507    __slots__ = []
508    def __init__(self) -> NoneType:
509        self = list[nothing]
510    def __init__(self, iterable: Iterable[_T2]) -> NoneType:
511        self = list[_T2]
512    def __add__(self, y: list[_T2]) -> list[Union[_T, _T2]]: ...
513    def __contains__(self, y) -> bool: ...
514    def __delitem__(self, y: Union[int, slice]) -> NoneType: ...
515    def __delslice__(self, i: int, j: int) -> NoneType: ...
516    def __getitem__(self, index: int) -> _T: ...
517    def __getitem__(self, index: slice) -> list[_T]: ...
518    def __getslice__(self, i: Optional[int], j: Optional[int]) -> list[_T]: ...
519    def __iadd__(self, y: Iterable[_T2]) -> list[Union[_T, _T2]]:
520      self = list[Union[_T, _T2]]
521    def __iter__(self) -> listiterator[_T]: ...
522    def __mul__(self, n: int) -> list[_T]: ...
523    def __reversed__(self) -> listreverseiterator[_T]: ...
524    def __setitem__(self, i: int, y: _T2) -> NoneType:
525      self = list[Union[_T, _T2]]
526    def __setitem__(self, i: slice, y) -> NoneType:
527      self = list[Any]
528    def __setslice__(self, i: int, j: int, y) -> NoneType: ...
529    def append(self, object: _T2) -> NoneType:
530      self = list[Union[_T, _T2]]
531    def extend(self, i: Iterable[_T2]) -> NoneType:
532      self = list[Union[_T, _T2]]
533    def clear(self) -> NoneType:
534      self = list[nothing]
535    def copy(self) -> list[_T]: ...
536    def count(self, value: _T) -> int: ...
537    def index(self, value, *args, **kwargs) -> int: ...
538    def insert(self, index: int, object: _T2) -> NoneType:
539      self = list[Union[_T, _T2]]
540    def pop(self) -> _T: ...
541    def pop(self, i: int) -> _T: ...
542    def remove(self, value: _T) -> NoneType: ...
543    def reverse(self) -> NoneType: ...
544    def sort(self, *args, **kwargs) -> NoneType: ...
545
546# "reversed" is a type, see PyReversed_Type in Objects/enumobject.c
547class reversed(Iterator[_T]):
548    __slots__ = []
549    def __init__(self, sequence: Reversible[_T2]) -> NoneType:
550      self = reversed[_T2]
551    def __iter__(self) -> reversed[_T]: ...
552    def __next__(self) -> _T: ...
553
554class tuple(Tuple[_T]):
555    __slots__ = []
556    def __init__(self) -> NoneType:
557      self = Tuple[()]
558    def __init__(self, p0: Iterable[_T2]) -> NoneType:
559      self = tuple[_T2, ...]
560    def __add__(self, y: tuple[_T2, ...]) -> tuple[Union[_T, _T2], ...]: ...
561    def __contains__(self, y) -> bool: ...
562    def __getitem__(self, index: int) -> _T: ...
563    def __getitem__(self, index: slice) -> tuple[_T, ...]: ...
564    def __getslice__(self, i: Optional[int], j: Optional[int]) -> tuple[_T, ...]: ...
565    def __iter__(self) -> tupleiterator[_T]: ...
566    def __mul__(self, n: int) -> tuple[_T, ...]: ...
567    def count(self, value: _T) -> int: ...
568    def index(self, value, *args, **kwargs) -> int: ...
569
570class tupleiterator(Iterator[_T]):
571    __slots__ = []
572    def __iter__(self) -> tupleiterator[_T]: ...
573    def __next__(self) -> _T: ...
574
575class set(Set[_T]):
576    __slots__ = []
577    def __init__(self) -> NoneType:
578        self = set[nothing]
579    def __init__(self, iterable: Iterable[_T2]) -> NoneType:
580        self = set[_T2]
581    def __and__(self, y: Iterable) -> set[_T]: ...
582    def __contains__(self, y) -> bool: ...
583    def __iter__(self) -> setiterator[_T]: ...
584    def __or__(self, y: Iterable[_T2]) -> set[Union[_T, _T2]]: ...
585    def __sub__(self, y: Iterable) -> set[_T]: ...
586    def __xor__(self, y: Iterable[_T2]) -> set[Union[_T, _T2]]: ...
587    def clear(self) -> NoneType:
588        self = set[nothing]
589    def copy(self) -> set[_T]: ...
590    def discard(self, y) -> NoneType: ...
591    def difference_update(self, *args, **kwargs) -> NoneType: ...
592    def symmetric_difference_update(self, *args, **kwargs) -> NoneType: ...
593    def intersection_update(self, *args, **kwargs) -> NoneType: ...
594    def isdisjoint(self, y: Iterable) -> bool: ...
595    def issubset(self, y: Iterable) -> bool: ...
596    def issuperset(self, y: Iterable) -> bool: ...
597    def pop(self) -> _T: ...
598    def remove(self, x) -> None: ...
599    @overload
600    def update(self, other: Iterable[_T2]) -> None:
601      self = set[Union[_T, _T2]]
602    @overload
603    def update(self, *args, **kwargs) -> None:
604        self = set[Any]
605    def add(self, y: _T2) -> NoneType:
606        self = set[Union[_T, _T2]]
607    # Even though these look like instance methods (i.e., you can call
608    # {1}.union(x)), they're actually static methods. (Which will accept a
609    # variable number of arguments, the first of which can e.g. be self.)
610    @staticmethod
611    def union(*args, **kwargs) -> set[Any]: ...
612    @staticmethod
613    def intersection(*args, **kwargs) -> set[Any]: ...
614    @staticmethod
615    def difference(*args, **kwargs) -> set[Any]: ...
616    @staticmethod
617    def symmetric_difference(Iterable) -> set[Any]: ...
618
619class frozenset(FrozenSet[_T]):
620    __slots__ = []
621    def __init__(self) -> NoneType:
622        self = frozenset[nothing]
623    def __init__(self, x: Iterable[_T2]) -> NoneType:
624        self = frozenset[_T2]
625    def __and__(self, y: AbstractSet) -> frozenset[_T]: ...
626    def __contains__(self, y) -> bool: ...
627    def __iter__(self) -> setiterator[_T]: ...
628    def __or__(self, y: AbstractSet[_T2]) -> frozenset[Union[_T, _T2]]: ...
629    def __sub__(self, y: AbstractSet[_T2]) -> frozenset[_T]: ...
630    def __xor__(self, y: AbstractSet[_T2]) -> frozenset[Union[_T, _T2]]: ...
631    def copy(self, *args, **kwargs) -> frozenset[_T]: ...
632    def isdisjoint(self, y: Iterable) -> bool: ...
633    def issubset(self, y: Iterable) -> bool: ...
634    def issuperset(self, y: Iterable) -> bool: ...
635    @staticmethod
636    def union(*args, **kwargs) -> frozenset[Any]: ...
637    @staticmethod
638    def intersection(*args, **kwargs) -> frozenset[Any]: ...
639    @staticmethod
640    def difference(*args, **kwargs) -> frozenset[Any]: ...
641    @staticmethod
642    def symmetric_difference(Iterable) -> frozenset[Any]: ...
643
644class setiterator(Iterator[_T]):
645    __slots__ = []
646    def __iter__(self) -> setiterator[_T]: ...
647    def __next__(self) -> _T: ...
648
649class bool(int, SupportsInt, SupportsFloat):
650    __slots__ = []
651    def __init__(self, x) -> NoneType: ...
652    def __init__(self) -> NoneType: ...
653    def __and__(self, y: bool) -> bool: ...
654    def __and__(self, y: int) -> int: ...
655    def __or__(self, y: bool) -> bool: ...
656    def __or__(self, y: int) -> int: ...
657    def __xor__(self, y: bool) -> bool: ...
658    def __xor__(self, y: int) -> int: ...
659    def __coerce__(self, y: int) -> Tuple[bool, int]: ...
660    def __coerce__(self, y: bool) -> Tuple[bool, bool]: ...
661
662# This class does not exist at runtime; it is here to help describe the types
663# int accepts.
664class _SupportsTrunc(Protocol):
665  def __trunc__(self) -> int: ...
666
667class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
668    __slots__ = []
669    denominator = ...  # type: int
670    numerator = ... # type: int
671    real = ... # type: int
672    imag = ... # type: int
673    def __init__(self) -> NoneType: ...
674    if sys.version_info >= (3, 8):
675        def __init__(self, x: Union[int, float, str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]) -> NoneType: ...
676    else:
677        def __init__(self, x: Union[int, float, str, bytes, SupportsInt, _SupportsTrunc]) -> NoneType: ...
678    def __init__(self, x: Union[str, bytes], base: int) -> NoneType: ...
679    def __add__(self, y: int) -> int: ...
680    def __add__(self, y: float) -> float: ...
681    def __add__(self, y: complex) -> complex: ...
682    def __and__(self, y: int) -> int: ...
683    def __and__(self, y: float) -> float: ...
684    def __and__(self, y: complex) -> complex: ...
685    def __div__(self, y: int) -> int: ...
686    def __div__(self, y: float) -> float: ...
687    def __div__(self, y: complex) -> complex: ...
688    def __divmod__(self, y: int) -> Tuple[int, int]: ...
689    def __divmod__(self, y: float) -> Tuple[float, float]: ...
690    def __divmod__(self, y: complex) -> Tuple[complex, complex]: ...
691    def __floordiv__(self, y: int) -> int: ...
692    def __floordiv__(self, y: float) -> float: ...
693    def __floordiv__(self, y: complex) -> complex: ...
694    def __mod__(self, y: int) -> int: ...
695    def __mod__(self, y: float) -> float: ...
696    def __mod__(self, y: complex) -> complex: ...
697    def __mul__(self, y: int) -> int: ...
698    def __mul__(self, y: float) -> float: ...
699    def __mul__(self, y: complex) -> complex: ...
700    def __mul__(self, n: str) -> str: ...
701    def __mul__(self, n: list[_T]) -> list[_T]: ...
702    def __mul__(self, n: tuple[_T, ...]) -> tuple[_T, ...]: ...
703    def __mul__(self, n: bytearray) -> bytearray: ...
704    def __pow__(self, y: bool) -> int: ...
705    def __pow__(self, y: int, modulo: int) -> int: ...
706    def __pow__(self, y: int) -> Union[int, float]: ...  # 2 ** -1 == 0.5
707    def __pow__(self, y: float) -> float: ...
708    def __pow__(self, y: complex) -> complex: ...
709    def __rshift__(self, y: int) -> int: ...
710    def __sub__(self, y: int) -> int: ...
711    def __sub__(self, y: float) -> float: ...
712    def __sub__(self, y: complex) -> complex: ...
713    def __truediv__(self, y: Union[int, float]) -> float: ...
714    def __truediv__(self, y: complex) -> complex: ...
715    def __coerce__(self, y: int) -> Tuple[int, int]: ...
716    def __float__(self) -> float: ...
717    def __hex__(self) -> str: ...
718    def __index__(self) -> int: ...
719    def __int__(self) -> int: ...
720    def __invert__(self) -> int: ...
721    def __long__(self) -> int: ...
722    def __lshift__(self, y: int) -> int: ...
723    def __neg__(self) -> int: ...
724    def __nonzero__(self) -> bool: ...
725    def __oct__(self) -> str: ...
726    def __or__(self, y: int) -> int: ...
727    def __pos__(self) -> int: ...
728    def __trunc__(self, *args, **kwargs) -> int: ...
729    def __xor__(self, y: int) -> int: ...
730    def bit_length(self) -> int: ...
731    def conjugate(self) -> int: ...
732    def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ...
733    @classmethod
734    def from_bytes(cls, bytes: Sequence[int], byteorder: str, *, signed: bool = ...) -> int: ...
735
736class float(SupportsInt, SupportsFloat, SupportsAbs):
737    __slots__ = []
738    real = ... # type: float
739    imag = ... # type: float
740    def __init__(self, x: Union[int, float, str, bytes, SupportsFloat]) -> NoneType: ...
741    def __init__(self) -> NoneType: ...
742    def __abs__(self) -> float: ...
743    def __add__(self, y: Union[int, float]) -> float: ...
744    def __add__(self, y: complex) -> complex: ...
745    def __coerce__(self, y: Union[int, float]) -> Tuple[float, Union[float, int]]: ...
746    def __div__(self, y: Union[int, float]) -> float: ...
747    def __div__(self, y: complex) -> complex: ...
748    def __divmod__(self, y: Union[int, float]) -> Tuple[float, float]: ...
749    def __divmod__(self, y: complex) -> Tuple[complex, complex]: ...
750    def __float__(self) -> float: ...
751    def __floordiv__(self, y: Union[int, float]) -> float: ...
752    def __floordiv__(self, y: complex) -> complex: ...
753    def __hex__(self) -> str: ...
754    def __index__(self) -> int: ...
755    def __int__(self) -> int: ...
756    def __invert__(self) -> int: ...
757    def __long__(self) -> int: ...
758    def __mod__(self, y: Union[int, float]) -> float: ...
759    def __mod__(self, y: complex) -> complex: ...
760    def __mul__(self, y: Union[int, float]) -> float: ...
761    def __mul__(self, y: complex) -> complex: ...
762    def __neg__(self) -> float: ...
763    def __nonzero__(self) -> bool: ...
764    def __oct__(self) -> str: ...
765    def __pos__(self) -> float: ...
766    def __pow__(self, y: Union[int, float]) -> float: ...
767    def __pow__(self, y: complex) -> complex: ...
768    def __sub__(self, y: Union[int, float]) -> float: ...
769    def __sub__(self, y: complex) -> complex: ...
770    def __truediv__(self, y: Union[int, float]) -> float: ...
771    def __truediv__(self, y: complex) -> complex: ...
772    def __trunc__(self, *args, **kwargs) -> int: ...
773    def conjugate(self) -> float: ...
774    def as_integer_ratio(self) -> tuple[int, int]: ...
775    def hex(self) -> str: ...
776    def is_integer(self) -> bool: ...
777
778    @classmethod
779    def fromhex(cls, string: str) -> float: ...
780
781class complex(SupportsAbs, SupportsInt, SupportsFloat, SupportsComplex):
782    __slots__ = []
783    real = ... # type: float
784    imag = ... # type: float
785    def __init__(self, real: Union[int, float, complex, str, bytes, typing.SupportsComplex], *args, **kwargs) -> NoneType: ...
786    def __init__(self) -> NoneType: ...
787    def __abs__(self) -> float: ...
788    def __add__(self, y: Union[int, float, complex]) -> complex: ...
789    def __coerce__(self, y: Union[int, float, complex]) -> Tuple[complex, complex]: ...
790    def __div__(self, y: Union[int, float, complex]) -> complex: ...
791    def __divmod__(self, y: Union[int, float, complex]) -> Tuple[complex, complex]: ...
792    def __floordiv__(self, y: Union[int, float, complex]) -> complex: ...
793    def __mod__(self, y: Union[int, float, complex]) -> complex: ...
794    def __mul__(self, y: Union[int, float, complex]) -> complex: ...
795    def __neg__(self) -> complex: ...
796    def __nonzero__(self) -> bool: ...
797    def __pos__(self) -> complex: ...
798    def __pow__(self, y: Union[int, float, complex]) -> complex: ...
799    def __sub__(self, y: Union[int, float, complex]) -> complex: ...
800    def __truediv__(self, y: Union[int, float, complex]) -> complex: ...
801    def conjugate(self) -> complex: ...
802
803class generator(Generator[_T, _T2, _V]):
804    __slots__ = []
805    def __iter__(self) -> generator[_T, _T2, _V]: ...
806    def __next__(self) -> _T: ...
807    def send(self, value: _T2) -> _T: ...
808    def close(self) -> NoneType: ...
809
810if sys.version_info >= (3, 5):
811    class coroutine(Coroutine[_T, _T2, _V]):
812        __slots__ = []
813        def close(self) -> NoneType: ...
814        def send(self, value: _T2) -> _T: ...
815
816if sys.version_info >= (3, 6):
817    class asyncgenerator(AsyncGenerator[_T, _T2]):
818        __slots__ = []
819        def __aiter__(self) -> asyncgenerator[_T, _T2]: ...
820        def __anext__(self) -> Awaitable[_T]: ...
821        def asend(self, value: _T2) -> Awaitable[_T]: ...
822        def aclose(self) -> Awaitable[_T]: ...
823
824class instancemethod(object):
825    __slots__ = []
826    def __init__(self, function: Union[Callable, instancemethod], instance, cls) -> NoneType: ...
827    def __get__(self, obj, *args, **kwargs) -> instancemethod: ...
828
829__path__ = ...  # type: List[str]  # only sometimes present
830
831class module(object):
832    __doc__ = ...  # type: str
833    __file__ = ...  # type: str
834    __name__ = ...  # type: str
835    __package__ = ...  # type: Optional[str]
836    __path__ = ...  # type: Iterable[str]  # only sometimes present
837    def __init__(self, name: Union[str, bytearray], doc = ...) -> NoneType: ...
838    def __getattr__(self, name) -> Any: ...  # modules can contain anything
839
840class slice(object):
841    __slots__ = []  # slices are readonly
842    start = ...  # type: Optional[int]
843    stop = ...  # type: Optional[int]
844    step = ...  # type: Optional[int]
845    def __init__(self, stop, *args, **kwargs) -> NoneType: ...
846    def indices(self, len: int) -> tuple[int, int, int]: ...
847
848class memoryview(object):
849    __slots__ = []
850    format = ...  # type: str
851    itemsize = ...  # type: int
852    shape = ...  # type: Optional[Tuple[int, ...]]
853    strides = ...  # type: Optional[Tuple[int, ...]]
854    suboffsets = ...  # type: Optional[Tuple[int, ...]]
855    readonly = ...  # type: bool
856    ndim = ...  # type: int
857    def __init__(self, object: bytes) -> NoneType: ...
858    def __getitem__(self, index: int) -> int: ...
859    def __getitem__(self, index: slice) -> memoryview: ...
860    def __len__(self) -> int: ...
861    def __setitem__(self, index: int, o: int) -> None: ...
862    def __setitem__(self, index: slice, o: bytes) -> None: ...
863    def tobytes(self, *args, **kwargs) -> bytes: ...
864    def tolist(self) -> list[int]: ...
865    if sys.version_info >= (3, 2):
866        def __enter__(self) -> memoryview: ...
867        def __exit__(self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[Any]) -> Optional[bool]: ...
868    if sys.version_info >= (3, 5):
869        def hex(self) -> str: ...
870
871class type(Callable, Type[_T]):
872    __name__ = ...  # type: str
873    __module__ = ...  # type: str
874    __bases__ = ...  # type: Tuple[type, ...]
875    __base__ = ...  # type: Optional[type]
876    __dictoffset__ = ...  # type: int
877    __itemsize__ = ...  # type: int
878    def __new__(cls: Type[type], object: _T) -> Type[_T]: ...
879    # The return type in the below two definitions is used only when abstract.py
880    # isn't able to build a class from the arguments.
881    def __new__(cls: Type[type], name: str, bases: tuple[type, ...], dict: Dict[str, Any]) -> type: ...
882    def __init__(self, object) -> None: ...
883    def __init__(self, name, bases, dict) -> None: ...
884    def __subclasses__(self) -> List[type]: ...
885    def __instancecheck__(self, object) -> bool: ...
886    def __subclasscheck__(self, cls) -> bool: ...
887    def mro(self) -> List[type]: ...
888
889# Usually the class argument to super() already inherits from object. So to
890# avoid confusion, super() inherits from nothing.
891class super(nothing):
892    __slots__ = []
893    def __init__(self, *args, **kwargs) -> NoneType: ...
894    def __get__(self, obj, *args, **kwargs) -> super: ...
895    def __set__(self, obj, value) -> super: ...
896    def __new__(cls: Type[super], *args, **kwargs) -> super: ...
897
898class range(Sequence[int]):
899    __slots__ = []
900    start: int
901    stop: int
902    step: int
903    def __init__(self, stop: int, *args, **kwargs) -> NoneType: ...
904    @overload
905    def __getitem__(self, index: int) -> int: ...
906    @overload
907    def __getitem__(self, index: slice) -> range: ...
908    def __iter__(self) -> Iterator[int]: ...
909    def __len__(self) -> int: ...
910    def __reversed__(self, *args, **kwargs) -> Iterator[int]: ...
911
912# From Python/objects/capsule.c. Used e.g. by datetime.datetime_CAPI
913class PyCapsule(object):
914    pass
915
916# types.CodeType, a.k.a., [type 'code']
917class code(object):
918    pass
919
920class ArithmeticError(StandardError):
921    pass
922
923class AssertionError(StandardError):
924    pass
925
926class AttributeError(StandardError):
927    pass
928
929# TODO(rechen): __traceback__ and with_traceback should use types.TracebackType,
930# but builtins can't depend on other modules.
931_TBE = TypeVar("_TBE", bound="BaseException")
932
933class BaseException(object):
934    args: Tuple[Any, ...]
935    __cause__: Optional[BaseException]
936    __context__: Optional[BaseException]
937    __suppress_context__: bool
938    __traceback__: Optional[Any]
939    def __init__(self, *args, **kwargs) -> NoneType: ...
940    def with_traceback(self: _TBE, tb: Optional[Any]) -> _TBE: ...
941
942class BufferError(StandardError):
943    pass
944
945class BytesWarning(Warning):
946    pass
947
948class DeprecationWarning(Warning):
949    pass
950
951class EOFError(StandardError):
952    pass
953
954EnvironmentError = OSError
955
956class Exception(BaseException):
957    pass
958
959class FloatingPointError(ArithmeticError):
960    pass
961
962class FutureWarning(Warning):
963    pass
964
965class GeneratorExit(BaseException):
966    pass
967
968IOError = OSError
969
970class ImportError(StandardError):
971    if sys.version_info >= (3, 3):
972        name = ...  # type: str
973        path = ...  # type: str
974
975class ImportWarning(Warning):
976    pass
977
978class IndentationError(SyntaxError):
979    pass
980
981class IndexError(LookupError):
982    pass
983
984class KeyError(LookupError):
985    pass
986
987class KeyboardInterrupt(BaseException):
988    pass
989
990class LookupError(StandardError):
991    pass
992
993class MemoryError(StandardError):
994    pass
995
996class NameError(StandardError):
997    pass
998
999class NotImplementedError(RuntimeError):
1000    pass
1001
1002class OSError(Exception):
1003    errno: int
1004    filename: str
1005    filename2: str
1006    strerror: str
1007
1008class OverflowError(ArithmeticError):
1009    pass
1010
1011class PendingDeprecationWarning(Warning):
1012    pass
1013
1014class ReferenceError(StandardError):
1015    pass
1016
1017class RuntimeError(StandardError):
1018    pass
1019
1020class RuntimeWarning(Warning):
1021    pass
1022
1023class StandardError(Exception):
1024    pass
1025
1026class StopIteration(Exception):
1027    pass
1028
1029class SyntaxError(StandardError):
1030    filename = ...  # type: str
1031    lineno = ...  # type: int
1032    msg = ...  # type: str
1033    offset = ...  # type: int
1034    print_file_and_line = ...  # type: Optional[str]
1035    text = ...  # type: str
1036
1037class SyntaxWarning(Warning):
1038    pass
1039
1040class SystemError(StandardError):
1041    pass
1042
1043class SystemExit(BaseException):
1044    code = ...  # type: int
1045
1046class TabError(IndentationError):
1047    pass
1048
1049class TypeError(StandardError):
1050    pass
1051
1052class UnboundLocalError(NameError):
1053    pass
1054
1055class UnicodeError(ValueError):
1056    pass
1057
1058class UnicodeDecodeError(UnicodeError):
1059    encoding = ...  # type: str
1060    object = ...  # type: str
1061    start = ...  # type: int
1062    end = ...  # type: int
1063    reason = ...  # type: str
1064    def __init__(self, encoding: str, object: bytes, start: int, end: int, reason: str) -> None: ...
1065
1066class UnicodeEncodeError(UnicodeError):
1067    encoding = ...  # type: str
1068    object = ...  # type: str
1069    start = ...  # type: int
1070    end = ...  # type: int
1071    reason = ...  # type: str
1072    def __init__(self, encoding: str, object: str, start: int, end: int, reason: str) -> None: ...
1073
1074class UnicodeTranslateError(UnicodeError):
1075    encoding = ...  # type: str
1076    object = ...  # type: str
1077    start = ...  # type: int
1078    end = ...  # type: int
1079    reason = ...  # type: str
1080    def __init__(self, object: str, start: int, end: int, reason: str) -> None: ...
1081
1082class UnicodeWarning(Warning):
1083    pass
1084
1085class UserWarning(Warning):
1086    pass
1087
1088class ValueError(StandardError):
1089    pass
1090
1091class Warning(Exception):
1092    pass
1093
1094class ZeroDivisionError(ArithmeticError):
1095    pass
1096
1097# -------------------------------------------------------------------
1098# Everything below this is new in python3
1099
1100class BlockingIOError(OSError):
1101    characters_written = ...  # type: int
1102class ChildProcessError(OSError): ...
1103class FileExistsError(OSError): ...
1104class FileNotFoundError(OSError): ...
1105class InterruptedError(OSError): ...
1106class IsADirectoryError(OSError): ...
1107class NotADirectoryError(OSError): ...
1108class PermissionError(OSError): ...
1109class ProcessLookupError(OSError): ...
1110class TimeoutError(OSError): ...
1111
1112class ResourceWarning(Warning): ...
1113
1114# Connection errors
1115class ConnectionError(OSError): ...
1116class BrokenPipeError(ConnectionError): ...
1117class ConnectionAbortedError(ConnectionError): ...
1118class ConnectionRefusedError(ConnectionError): ...
1119class ConnectionResetError(ConnectionError): ...
1120
1121if sys.version_info >= (3, 5):
1122    class StopAsyncIteration(Exception):
1123        value = ...  # type: Any
1124    class RecursionError(RuntimeError): ...
1125
1126if sys.version_info >= (3, 6):
1127    class ModuleNotFoundError(ImportError): ...
1128
1129if sys.version_info >= (3, 6):
1130    # This class is to be exported as PathLike from os,
1131    # but we define it here as _PathLike to avoid import cycle issues.
1132    # See https://github.com/python/typeshed/pull/991#issuecomment-288160993
1133    class _PathLike(Generic[_AnyStr], Protocol):
1134        def __fspath__(self) -> _AnyStr: ...
1135    _FileType = Union[str, bytes, int, _PathLike]
1136else:
1137    _FileType = Union[str, bytes, int]
1138
1139@overload
1140def open(
1141    file: _FileType,
1142    mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b", "rb+", "wb+", "ab+", "xb+"],
1143    buffering: int = ...,
1144    encoding: Optional[str] = ...,
1145    errors: Optional[str] = ...,
1146    newline: Optional[str] = ...,
1147    closefd: bool = ...,
1148) -> BinaryIO: ...
1149@overload
1150def open(
1151    file: _FileType,
1152    mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t", "rt+", "wt+", "at+", "xt+"] = ...,
1153    buffering: int = ...,
1154    encoding: Optional[str] = ...,
1155    errors: Optional[str] = ...,
1156    newline: Optional[str] = ...,
1157    closefd: bool = ...,
1158) -> TextIO: ...
1159@overload
1160def open(
1161    file: _FileType,
1162    mode: str,
1163    buffering: int = ...,
1164    encoding: Optional[str] = ...,
1165    errors: Optional[str] = ...,
1166    newline: Optional[str] = ...,
1167    closefd: bool = ...,
1168) -> IO: ...
1169