4 from _collections_abc import dict_items, dict_keys, dict_values
5 from _typeshed import (
8 OpenBinaryModeUpdating,
18 SupportsKeysAndGetItem,
19 SupportsLenAndGetItem,
27 from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
28 from types import CodeType, TracebackType
62 from typing_extensions import Literal, SupportsIndex, TypeGuard, final
64 if sys.version_info >= (3, 9):
65 from types import GenericAlias
68 _T_co = TypeVar("_T_co", covariant=True)
69 _T_contra = TypeVar("_T_contra", contravariant=True)
78 _TT = TypeVar("_TT", bound="type")
79 _TBE = TypeVar("_TBE", bound="BaseException")
80 _R = TypeVar("_R") # Return-type TypeVar
84 __dict__: dict[str, Any]
85 __slots__: str | Iterable[str]
87 __annotations__: dict[str, Any]
89 def __class__(self: _T) -> Type[_T]: ...
90 # Ignore errors about type mismatch between property getter and setter
92 def __class__(self, __type: Type[object]) -> None: ... # type: ignore # noqa: F811
93 def __init__(self) -> None: ...
94 def __new__(cls: Type[_T]) -> _T: ...
95 def __setattr__(self, __name: str, __value: Any) -> None: ...
96 def __eq__(self, __o: object) -> bool: ...
97 def __ne__(self, __o: object) -> bool: ...
98 def __str__(self) -> str: ...
99 def __repr__(self) -> str: ...
100 def __hash__(self) -> int: ...
101 def __format__(self, __format_spec: str) -> str: ...
102 def __getattribute__(self, __name: str) -> Any: ...
103 def __delattr__(self, __name: str) -> None: ...
104 def __sizeof__(self) -> int: ...
105 def __reduce__(self) -> str | Tuple[object, ...]: ...
106 if sys.version_info >= (3, 8):
107 def __reduce_ex__(self, __protocol: SupportsIndex) -> str | Tuple[object, ...]: ...
109 def __reduce_ex__(self, __protocol: int) -> str | Tuple[object, ...]: ...
110 def __dir__(self) -> Iterable[str]: ...
111 def __init_subclass__(cls) -> None: ...
113 class staticmethod(Generic[_R]): # Special, only valid as a decorator.
114 __func__: Callable[..., _R]
115 __isabstractmethod__: bool
116 def __init__(self: staticmethod[_R], __f: Callable[..., _R]) -> None: ...
117 def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
118 def __get__(self, __obj: _T, __type: Type[_T] | None = ...) -> Callable[..., _R]: ...
119 if sys.version_info >= (3, 10):
122 __wrapped__: Callable[..., _R]
123 def __call__(self, *args: Any, **kwargs: Any) -> _R: ...
125 class classmethod(Generic[_R]): # Special, only valid as a decorator.
126 __func__: Callable[..., _R]
127 __isabstractmethod__: bool
128 def __init__(self: classmethod[_R], __f: Callable[..., _R]) -> None: ...
129 def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
130 def __get__(self, __obj: _T, __type: Type[_T] | None = ...) -> Callable[..., _R]: ...
131 if sys.version_info >= (3, 10):
134 __wrapped__: Callable[..., _R]
138 __bases__: Tuple[type, ...]
140 __dict__: dict[str, Any]
145 __mro__: Tuple[type, ...]
148 __text_signature__: str | None
149 __weakrefoffset__: int
151 def __init__(self, __o: object) -> None: ...
153 def __init__(self, __name: str, __bases: Tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ...
155 def __new__(cls, __o: object) -> type: ...
157 def __new__(cls: Type[_TT], __name: str, __bases: Tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ...
158 def __call__(self, *args: Any, **kwds: Any) -> Any: ...
159 def __subclasses__(self: _TT) -> list[_TT]: ...
160 # Note: the documentation doesn't specify what the return type is, the standard
161 # implementation seems to be returning a list.
162 def mro(self) -> list[type]: ...
163 def __instancecheck__(self, __instance: Any) -> bool: ...
164 def __subclasscheck__(self, __subclass: type) -> bool: ...
166 def __prepare__(metacls, __name: str, __bases: Tuple[type, ...], **kwds: Any) -> Mapping[str, object]: ...
167 if sys.version_info >= (3, 10):
168 def __or__(self, __t: Any) -> types.UnionType: ...
169 def __ror__(self, __t: Any) -> types.UnionType: ...
173 def __init__(self, __t: Any, __obj: Any) -> None: ...
175 def __init__(self, __t: Any) -> None: ...
177 def __init__(self) -> None: ...
179 _PositiveInteger = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
180 _NegativeInteger = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]
184 def __new__(cls: Type[_T], __x: str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> _T: ...
186 def __new__(cls: Type[_T], __x: str | bytes | bytearray, base: SupportsIndex) -> _T: ...
187 if sys.version_info >= (3, 8):
188 def as_integer_ratio(self) -> tuple[int, Literal[1]]: ...
190 def real(self) -> int: ...
192 def imag(self) -> int: ...
194 def numerator(self) -> int: ...
196 def denominator(self) -> int: ...
197 def conjugate(self) -> int: ...
198 def bit_length(self) -> int: ...
199 if sys.version_info >= (3, 10):
200 def bit_count(self) -> int: ...
201 def to_bytes(self, length: SupportsIndex, byteorder: Literal["little", "big"], *, signed: bool = ...) -> bytes: ...
204 cls, bytes: Iterable[SupportsIndex] | SupportsBytes, byteorder: Literal["little", "big"], *, signed: bool = ...
205 ) -> int: ... # TODO buffer object argument
206 def __add__(self, __x: int) -> int: ...
207 def __sub__(self, __x: int) -> int: ...
208 def __mul__(self, __x: int) -> int: ...
209 def __floordiv__(self, __x: int) -> int: ...
210 def __truediv__(self, __x: int) -> float: ...
211 def __mod__(self, __x: int) -> int: ...
212 def __divmod__(self, __x: int) -> tuple[int, int]: ...
213 def __radd__(self, __x: int) -> int: ...
214 def __rsub__(self, __x: int) -> int: ...
215 def __rmul__(self, __x: int) -> int: ...
216 def __rfloordiv__(self, __x: int) -> int: ...
217 def __rtruediv__(self, __x: int) -> float: ...
218 def __rmod__(self, __x: int) -> int: ...
219 def __rdivmod__(self, __x: int) -> tuple[int, int]: ...
221 def __pow__(self, __x: int, __modulo: Literal[0]) -> NoReturn: ...
223 def __pow__(self, __x: int, __modulo: int) -> int: ...
225 def __pow__(self, __x: _PositiveInteger, __modulo: None = ...) -> int: ...
227 def __pow__(self, __x: _NegativeInteger, __modulo: None = ...) -> float: ...
228 # positive x -> int; negative x -> float
229 # return type must be Any as `int | float` causes too many false-positive errors
231 def __pow__(self, __x: int, __modulo: None = ...) -> Any: ...
232 def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ...
233 def __and__(self, __n: int) -> int: ...
234 def __or__(self, __n: int) -> int: ...
235 def __xor__(self, __n: int) -> int: ...
236 def __lshift__(self, __n: int) -> int: ...
237 def __rshift__(self, __n: int) -> int: ...
238 def __rand__(self, __n: int) -> int: ...
239 def __ror__(self, __n: int) -> int: ...
240 def __rxor__(self, __n: int) -> int: ...
241 def __rlshift__(self, __n: int) -> int: ...
242 def __rrshift__(self, __n: int) -> int: ...
243 def __neg__(self) -> int: ...
244 def __pos__(self) -> int: ...
245 def __invert__(self) -> int: ...
246 def __trunc__(self) -> int: ...
247 def __ceil__(self) -> int: ...
248 def __floor__(self) -> int: ...
249 def __round__(self, __ndigits: SupportsIndex = ...) -> int: ...
250 def __getnewargs__(self) -> tuple[int]: ...
251 def __eq__(self, __x: object) -> bool: ...
252 def __ne__(self, __x: object) -> bool: ...
253 def __lt__(self, __x: int) -> bool: ...
254 def __le__(self, __x: int) -> bool: ...
255 def __gt__(self, __x: int) -> bool: ...
256 def __ge__(self, __x: int) -> bool: ...
257 def __str__(self) -> str: ...
258 def __float__(self) -> float: ...
259 def __int__(self) -> int: ...
260 def __abs__(self) -> int: ...
261 def __hash__(self) -> int: ...
262 def __bool__(self) -> bool: ...
263 def __index__(self) -> int: ...
266 def __new__(cls: Type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ...
267 def as_integer_ratio(self) -> tuple[int, int]: ...
268 def hex(self) -> str: ...
269 def is_integer(self) -> bool: ...
271 def fromhex(cls, __s: str) -> float: ...
273 def real(self) -> float: ...
275 def imag(self) -> float: ...
276 def conjugate(self) -> float: ...
277 def __add__(self, __x: float) -> float: ...
278 def __sub__(self, __x: float) -> float: ...
279 def __mul__(self, __x: float) -> float: ...
280 def __floordiv__(self, __x: float) -> float: ...
281 def __truediv__(self, __x: float) -> float: ...
282 def __mod__(self, __x: float) -> float: ...
283 def __divmod__(self, __x: float) -> tuple[float, float]: ...
285 def __pow__(self, __x: int, __mod: None = ...) -> float: ...
286 # positive x -> float; negative x -> complex
287 # return type must be Any as `float | complex` causes too many false-positive errors
289 def __pow__(self, __x: float, __mod: None = ...) -> Any: ...
290 def __radd__(self, __x: float) -> float: ...
291 def __rsub__(self, __x: float) -> float: ...
292 def __rmul__(self, __x: float) -> float: ...
293 def __rfloordiv__(self, __x: float) -> float: ...
294 def __rtruediv__(self, __x: float) -> float: ...
295 def __rmod__(self, __x: float) -> float: ...
296 def __rdivmod__(self, __x: float) -> tuple[float, float]: ...
297 def __rpow__(self, __x: float, __mod: None = ...) -> float: ...
298 def __getnewargs__(self) -> tuple[float]: ...
299 def __trunc__(self) -> int: ...
300 if sys.version_info >= (3, 9):
301 def __ceil__(self) -> int: ...
302 def __floor__(self) -> int: ...
304 def __round__(self, __ndigits: None = ...) -> int: ...
306 def __round__(self, __ndigits: SupportsIndex) -> float: ...
307 def __eq__(self, __x: object) -> bool: ...
308 def __ne__(self, __x: object) -> bool: ...
309 def __lt__(self, __x: float) -> bool: ...
310 def __le__(self, __x: float) -> bool: ...
311 def __gt__(self, __x: float) -> bool: ...
312 def __ge__(self, __x: float) -> bool: ...
313 def __neg__(self) -> float: ...
314 def __pos__(self) -> float: ...
315 def __str__(self) -> str: ...
316 def __int__(self) -> int: ...
317 def __float__(self) -> float: ...
318 def __abs__(self) -> float: ...
319 def __hash__(self) -> int: ...
320 def __bool__(self) -> bool: ...
324 def __new__(cls: Type[_T], real: float = ..., imag: float = ...) -> _T: ...
326 def __new__(cls: Type[_T], real: str | SupportsComplex | SupportsIndex | complex) -> _T: ...
328 def real(self) -> float: ...
330 def imag(self) -> float: ...
331 def conjugate(self) -> complex: ...
332 def __add__(self, __x: complex) -> complex: ...
333 def __sub__(self, __x: complex) -> complex: ...
334 def __mul__(self, __x: complex) -> complex: ...
335 def __pow__(self, __x: complex, mod: None = ...) -> complex: ...
336 def __truediv__(self, __x: complex) -> complex: ...
337 def __radd__(self, __x: complex) -> complex: ...
338 def __rsub__(self, __x: complex) -> complex: ...
339 def __rmul__(self, __x: complex) -> complex: ...
340 def __rpow__(self, __x: complex, __mod: None = ...) -> complex: ...
341 def __rtruediv__(self, __x: complex) -> complex: ...
342 def __eq__(self, __x: object) -> bool: ...
343 def __ne__(self, __x: object) -> bool: ...
344 def __neg__(self) -> complex: ...
345 def __pos__(self) -> complex: ...
346 def __str__(self) -> str: ...
347 def __abs__(self) -> float: ...
348 def __hash__(self) -> int: ...
349 def __bool__(self) -> bool: ...
350 if sys.version_info >= (3, 11):
351 def __complex__(self) -> complex: ...
353 class _FormatMapMapping(Protocol):
354 def __getitem__(self, __key: str) -> Any: ...
356 class str(Sequence[str]):
358 def __new__(cls: Type[_T], object: object = ...) -> _T: ...
360 def __new__(cls: Type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ...
361 def capitalize(self) -> str: ...
362 def casefold(self) -> str: ...
363 def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
364 def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
365 def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
367 self, __suffix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
369 if sys.version_info >= (3, 8):
370 def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ...
372 def expandtabs(self, tabsize: int = ...) -> str: ...
373 def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
374 def format(self, *args: object, **kwargs: object) -> str: ...
375 def format_map(self, map: _FormatMapMapping) -> str: ...
376 def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
377 def isalnum(self) -> bool: ...
378 def isalpha(self) -> bool: ...
379 if sys.version_info >= (3, 7):
380 def isascii(self) -> bool: ...
381 def isdecimal(self) -> bool: ...
382 def isdigit(self) -> bool: ...
383 def isidentifier(self) -> bool: ...
384 def islower(self) -> bool: ...
385 def isnumeric(self) -> bool: ...
386 def isprintable(self) -> bool: ...
387 def isspace(self) -> bool: ...
388 def istitle(self) -> bool: ...
389 def isupper(self) -> bool: ...
390 def join(self, __iterable: Iterable[str]) -> str: ...
391 def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
392 def lower(self) -> str: ...
393 def lstrip(self, __chars: str | None = ...) -> str: ...
394 def partition(self, __sep: str) -> tuple[str, str, str]: ...
395 def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ...
396 if sys.version_info >= (3, 9):
397 def removeprefix(self, __prefix: str) -> str: ...
398 def removesuffix(self, __suffix: str) -> str: ...
399 def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
400 def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
401 def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
402 def rpartition(self, __sep: str) -> tuple[str, str, str]: ...
403 def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
404 def rstrip(self, __chars: str | None = ...) -> str: ...
405 def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
406 def splitlines(self, keepends: bool = ...) -> list[str]: ...
408 self, __prefix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
410 def strip(self, __chars: str | None = ...) -> str: ...
411 def swapcase(self) -> str: ...
412 def title(self) -> str: ...
413 def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ...
414 def upper(self) -> str: ...
415 def zfill(self, __width: SupportsIndex) -> str: ...
418 def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
421 def maketrans(__x: str, __y: str, __z: str | None = ...) -> dict[int, int | None]: ...
422 def __add__(self, __s: str) -> str: ...
423 # Incompatible with Sequence.__contains__
424 def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
425 def __eq__(self, __x: object) -> bool: ...
426 def __ge__(self, __x: str) -> bool: ...
427 def __getitem__(self, __i: int | slice) -> str: ...
428 def __gt__(self, __x: str) -> bool: ...
429 def __hash__(self) -> int: ...
430 def __iter__(self) -> Iterator[str]: ...
431 def __le__(self, __x: str) -> bool: ...
432 def __len__(self) -> int: ...
433 def __lt__(self, __x: str) -> bool: ...
434 def __mod__(self, __x: Any) -> str: ...
435 def __mul__(self, __n: SupportsIndex) -> str: ...
436 def __ne__(self, __x: object) -> bool: ...
437 def __repr__(self) -> str: ...
438 def __rmul__(self, n: SupportsIndex) -> str: ...
439 def __str__(self) -> str: ...
440 def __getnewargs__(self) -> tuple[str]: ...
442 class bytes(ByteString):
444 def __new__(cls: Type[_T], __ints: Iterable[SupportsIndex]) -> _T: ...
446 def __new__(cls: Type[_T], __string: str, encoding: str, errors: str = ...) -> _T: ...
448 def __new__(cls: Type[_T], __length: SupportsIndex) -> _T: ...
450 def __new__(cls: Type[_T]) -> _T: ...
452 def __new__(cls: Type[_T], __o: SupportsBytes) -> _T: ...
453 def capitalize(self) -> bytes: ...
454 def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ...
456 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
458 def decode(self, encoding: str = ..., errors: str = ...) -> str: ...
460 self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
462 if sys.version_info >= (3, 8):
463 def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ...
465 def expandtabs(self, tabsize: int = ...) -> bytes: ...
467 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
469 if sys.version_info >= (3, 8):
470 def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
472 def hex(self) -> str: ...
474 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
476 def isalnum(self) -> bool: ...
477 def isalpha(self) -> bool: ...
478 if sys.version_info >= (3, 7):
479 def isascii(self) -> bool: ...
480 def isdigit(self) -> bool: ...
481 def islower(self) -> bool: ...
482 def isspace(self) -> bool: ...
483 def istitle(self) -> bool: ...
484 def isupper(self) -> bool: ...
485 def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytes: ...
486 def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ...
487 def lower(self) -> bytes: ...
488 def lstrip(self, __bytes: bytes | None = ...) -> bytes: ...
489 def partition(self, __sep: bytes) -> tuple[bytes, bytes, bytes]: ...
490 def replace(self, __old: bytes, __new: bytes, __count: SupportsIndex = ...) -> bytes: ...
491 if sys.version_info >= (3, 9):
492 def removeprefix(self, __prefix: bytes) -> bytes: ...
493 def removesuffix(self, __suffix: bytes) -> bytes: ...
495 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
498 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
500 def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ...
501 def rpartition(self, __sep: bytes) -> tuple[bytes, bytes, bytes]: ...
502 def rsplit(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ...
503 def rstrip(self, __bytes: bytes | None = ...) -> bytes: ...
504 def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ...
505 def splitlines(self, keepends: bool = ...) -> list[bytes]: ...
507 self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
509 def strip(self, __bytes: bytes | None = ...) -> bytes: ...
510 def swapcase(self) -> bytes: ...
511 def title(self) -> bytes: ...
512 def translate(self, __table: bytes | None, delete: bytes = ...) -> bytes: ...
513 def upper(self) -> bytes: ...
514 def zfill(self, __width: SupportsIndex) -> bytes: ...
516 def fromhex(cls: Type[_T], __s: str) -> _T: ...
518 def maketrans(__frm: bytes, __to: bytes) -> bytes: ...
519 def __len__(self) -> int: ...
520 def __iter__(self) -> Iterator[int]: ...
521 def __str__(self) -> str: ...
522 def __repr__(self) -> str: ...
523 def __hash__(self) -> int: ...
525 def __getitem__(self, __i: SupportsIndex) -> int: ...
527 def __getitem__(self, __s: slice) -> bytes: ...
528 def __add__(self, __s: bytes) -> bytes: ...
529 def __mul__(self, __n: SupportsIndex) -> bytes: ...
530 def __rmul__(self, __n: SupportsIndex) -> bytes: ...
531 def __mod__(self, __value: Any) -> bytes: ...
532 # Incompatible with Sequence.__contains__
533 def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override]
534 def __eq__(self, __x: object) -> bool: ...
535 def __ne__(self, __x: object) -> bool: ...
536 def __lt__(self, __x: bytes) -> bool: ...
537 def __le__(self, __x: bytes) -> bool: ...
538 def __gt__(self, __x: bytes) -> bool: ...
539 def __ge__(self, __x: bytes) -> bool: ...
540 def __getnewargs__(self) -> tuple[bytes]: ...
541 if sys.version_info >= (3, 11):
542 def __bytes__(self) -> bytes: ...
544 class bytearray(MutableSequence[int], ByteString):
546 def __init__(self) -> None: ...
548 def __init__(self, __ints: Iterable[SupportsIndex]) -> None: ...
550 def __init__(self, __string: str, encoding: str, errors: str = ...) -> None: ...
552 def __init__(self, __length: SupportsIndex) -> None: ...
553 def append(self, __item: SupportsIndex) -> None: ...
554 def capitalize(self) -> bytearray: ...
555 def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ...
557 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
559 def copy(self) -> bytearray: ...
560 def decode(self, encoding: str = ..., errors: str = ...) -> str: ...
562 self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
564 if sys.version_info >= (3, 8):
565 def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ...
567 def expandtabs(self, tabsize: int = ...) -> bytearray: ...
568 def extend(self, __iterable_of_ints: Iterable[SupportsIndex]) -> None: ...
570 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
572 if sys.version_info >= (3, 8):
573 def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
575 def hex(self) -> str: ...
577 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
579 def insert(self, __index: SupportsIndex, __item: SupportsIndex) -> None: ...
580 def isalnum(self) -> bool: ...
581 def isalpha(self) -> bool: ...
582 if sys.version_info >= (3, 7):
583 def isascii(self) -> bool: ...
584 def isdigit(self) -> bool: ...
585 def islower(self) -> bool: ...
586 def isspace(self) -> bool: ...
587 def istitle(self) -> bool: ...
588 def isupper(self) -> bool: ...
589 def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytearray: ...
590 def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ...
591 def lower(self) -> bytearray: ...
592 def lstrip(self, __bytes: bytes | None = ...) -> bytearray: ...
593 def partition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ...
594 if sys.version_info >= (3, 9):
595 def removeprefix(self, __prefix: bytes) -> bytearray: ...
596 def removesuffix(self, __suffix: bytes) -> bytearray: ...
597 def replace(self, __old: bytes, __new: bytes, __count: SupportsIndex = ...) -> bytearray: ...
599 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
602 self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
604 def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ...
605 def rpartition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ...
606 def rsplit(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ...
607 def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ...
608 def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ...
609 def splitlines(self, keepends: bool = ...) -> list[bytearray]: ...
611 self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
613 def strip(self, __bytes: bytes | None = ...) -> bytearray: ...
614 def swapcase(self) -> bytearray: ...
615 def title(self) -> bytearray: ...
616 def translate(self, __table: bytes | None, delete: bytes = ...) -> bytearray: ...
617 def upper(self) -> bytearray: ...
618 def zfill(self, __width: SupportsIndex) -> bytearray: ...
620 def fromhex(cls, __string: str) -> bytearray: ...
622 def maketrans(__frm: bytes, __to: bytes) -> bytes: ...
623 def __len__(self) -> int: ...
624 def __iter__(self) -> Iterator[int]: ...
625 def __str__(self) -> str: ...
626 def __repr__(self) -> str: ...
627 __hash__: None # type: ignore[assignment]
629 def __getitem__(self, __i: SupportsIndex) -> int: ...
631 def __getitem__(self, __s: slice) -> bytearray: ...
633 def __setitem__(self, __i: SupportsIndex, x: SupportsIndex) -> None: ...
635 def __setitem__(self, __s: slice, __x: Iterable[SupportsIndex] | bytes) -> None: ...
636 def __delitem__(self, __i: SupportsIndex | slice) -> None: ...
637 def __add__(self, __s: bytes) -> bytearray: ...
638 def __iadd__(self, __s: Iterable[int]) -> bytearray: ...
639 def __mul__(self, __n: SupportsIndex) -> bytearray: ...
640 def __rmul__(self, __n: SupportsIndex) -> bytearray: ...
641 def __imul__(self, __n: SupportsIndex) -> bytearray: ...
642 def __mod__(self, __value: Any) -> bytes: ...
643 # Incompatible with Sequence.__contains__
644 def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override]
645 def __eq__(self, __x: object) -> bool: ...
646 def __ne__(self, __x: object) -> bool: ...
647 def __lt__(self, __x: bytes) -> bool: ...
648 def __le__(self, __x: bytes) -> bool: ...
649 def __gt__(self, __x: bytes) -> bool: ...
650 def __ge__(self, __x: bytes) -> bool: ...
653 class memoryview(Sized, Sequence[int]):
656 shape: Tuple[int, ...] | None
657 strides: Tuple[int, ...] | None
658 suboffsets: Tuple[int, ...] | None
662 obj: bytes | bytearray
667 def __init__(self, obj: ReadableBuffer) -> None: ...
668 def __enter__(self: Self) -> Self: ...
670 self, __exc_type: Type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None
672 def cast(self, format: str, shape: list[int] | Tuple[int, ...] = ...) -> memoryview: ...
674 def __getitem__(self, __i: SupportsIndex) -> int: ...
676 def __getitem__(self, __s: slice) -> memoryview: ...
677 def __contains__(self, __x: object) -> bool: ...
678 def __iter__(self) -> Iterator[int]: ...
679 def __len__(self) -> int: ...
681 def __setitem__(self, __s: slice, __o: bytes) -> None: ...
683 def __setitem__(self, __i: SupportsIndex, __o: SupportsIndex) -> None: ...
684 if sys.version_info >= (3, 8):
685 def tobytes(self, order: Literal["C", "F", "A"] | None = ...) -> bytes: ...
687 def tobytes(self) -> bytes: ...
688 def tolist(self) -> list[int]: ...
689 if sys.version_info >= (3, 8):
690 def toreadonly(self) -> memoryview: ...
691 def release(self) -> None: ...
692 if sys.version_info >= (3, 8):
693 def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
695 def hex(self) -> str: ...
699 def __new__(cls: Type[_T], __o: object = ...) -> _T: ...
701 def __and__(self, __x: bool) -> bool: ...
703 def __and__(self, __x: int) -> int: ...
705 def __or__(self, __x: bool) -> bool: ...
707 def __or__(self, __x: int) -> int: ...
709 def __xor__(self, __x: bool) -> bool: ...
711 def __xor__(self, __x: int) -> int: ...
713 def __rand__(self, __x: bool) -> bool: ...
715 def __rand__(self, __x: int) -> int: ...
717 def __ror__(self, __x: bool) -> bool: ...
719 def __ror__(self, __x: int) -> int: ...
721 def __rxor__(self, __x: bool) -> bool: ...
723 def __rxor__(self, __x: int) -> int: ...
724 def __getnewargs__(self) -> tuple[int]: ...
732 def __init__(self, __stop: Any) -> None: ...
734 def __init__(self, __start: Any, __stop: Any, __step: Any = ...) -> None: ...
735 __hash__: None # type: ignore[assignment]
736 def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...
738 class tuple(Sequence[_T_co], Generic[_T_co]):
739 def __new__(cls: Type[_T], __iterable: Iterable[_T_co] = ...) -> _T: ...
740 def __len__(self) -> int: ...
741 def __contains__(self, __x: object) -> bool: ...
743 def __getitem__(self, __x: int) -> _T_co: ...
745 def __getitem__(self, __x: slice) -> Tuple[_T_co, ...]: ...
746 def __iter__(self) -> Iterator[_T_co]: ...
747 def __lt__(self, __x: Tuple[_T_co, ...]) -> bool: ...
748 def __le__(self, __x: Tuple[_T_co, ...]) -> bool: ...
749 def __gt__(self, __x: Tuple[_T_co, ...]) -> bool: ...
750 def __ge__(self, __x: Tuple[_T_co, ...]) -> bool: ...
752 def __add__(self, __x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ...
754 def __add__(self, __x: Tuple[_T, ...]) -> Tuple[_T_co | _T, ...]: ...
755 def __mul__(self, __n: SupportsIndex) -> Tuple[_T_co, ...]: ...
756 def __rmul__(self, __n: SupportsIndex) -> Tuple[_T_co, ...]: ...
757 def count(self, __value: Any) -> int: ...
758 def index(self, __value: Any, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
759 if sys.version_info >= (3, 9):
760 def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
763 # TODO not defined in builtins!
768 __annotations__: dict[str, Any]
770 class list(MutableSequence[_T], Generic[_T]):
772 def __init__(self) -> None: ...
774 def __init__(self, __iterable: Iterable[_T]) -> None: ...
775 def clear(self) -> None: ...
776 def copy(self) -> list[_T]: ...
777 def append(self, __object: _T) -> None: ...
778 def extend(self, __iterable: Iterable[_T]) -> None: ...
779 def pop(self, __index: SupportsIndex = ...) -> _T: ...
780 def index(self, __value: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
781 def count(self, __value: _T) -> int: ...
782 def insert(self, __index: SupportsIndex, __object: _T) -> None: ...
783 def remove(self, __value: _T) -> None: ...
784 def reverse(self) -> None: ...
786 def sort(self: list[SupportsLessThanT], *, key: None = ..., reverse: bool = ...) -> None: ...
788 def sort(self, *, key: Callable[[_T], SupportsLessThan], reverse: bool = ...) -> None: ...
789 def __len__(self) -> int: ...
790 def __iter__(self) -> Iterator[_T]: ...
791 def __str__(self) -> str: ...
792 __hash__: None # type: ignore[assignment]
794 def __getitem__(self, __i: SupportsIndex) -> _T: ...
796 def __getitem__(self, __s: slice) -> list[_T]: ...
798 def __setitem__(self, __i: SupportsIndex, __o: _T) -> None: ...
800 def __setitem__(self, __s: slice, __o: Iterable[_T]) -> None: ...
801 def __delitem__(self, __i: SupportsIndex | slice) -> None: ...
802 def __add__(self, __x: list[_T]) -> list[_T]: ...
803 def __iadd__(self: _S, __x: Iterable[_T]) -> _S: ...
804 def __mul__(self, __n: SupportsIndex) -> list[_T]: ...
805 def __rmul__(self, __n: SupportsIndex) -> list[_T]: ...
806 def __imul__(self: _S, __n: SupportsIndex) -> _S: ...
807 def __contains__(self, __o: object) -> bool: ...
808 def __reversed__(self) -> Iterator[_T]: ...
809 def __gt__(self, __x: list[_T]) -> bool: ...
810 def __ge__(self, __x: list[_T]) -> bool: ...
811 def __lt__(self, __x: list[_T]) -> bool: ...
812 def __le__(self, __x: list[_T]) -> bool: ...
813 if sys.version_info >= (3, 9):
814 def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
816 class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
818 def __init__(self: dict[_KT, _VT]) -> None: ...
820 def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ...
822 def __init__(self, __map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ...
824 def __init__(self, __iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
825 # Next overload is for dict(string.split(sep) for string in iterable)
826 # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error
828 def __init__(self: dict[str, str], __iterable: Iterable[list[str]]) -> None: ...
829 def __new__(cls: Type[_T1], *args: Any, **kwargs: Any) -> _T1: ...
830 def clear(self) -> None: ...
831 def copy(self) -> dict[_KT, _VT]: ...
832 def popitem(self) -> tuple[_KT, _VT]: ...
833 def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ...
835 def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
837 def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
839 def update(self, **kwargs: _VT) -> None: ...
840 def keys(self) -> dict_keys[_KT, _VT]: ...
841 def values(self) -> dict_values[_KT, _VT]: ...
842 def items(self) -> dict_items[_KT, _VT]: ...
845 def fromkeys(cls, __iterable: Iterable[_T], __value: None = ...) -> dict[_T, Any | None]: ...
848 def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> dict[_T, _S]: ...
849 def __len__(self) -> int: ...
850 def __getitem__(self, __k: _KT) -> _VT: ...
851 def __setitem__(self, __k: _KT, v: _VT) -> None: ...
852 def __delitem__(self, __v: _KT) -> None: ...
853 def __iter__(self) -> Iterator[_KT]: ...
854 if sys.version_info >= (3, 8):
855 def __reversed__(self) -> Iterator[_KT]: ...
856 def __str__(self) -> str: ...
857 __hash__: None # type: ignore[assignment]
858 if sys.version_info >= (3, 9):
859 def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
860 def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
861 def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
862 def __ior__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ... # type: ignore[misc]
864 class set(MutableSet[_T], Generic[_T]):
865 def __init__(self, __iterable: Iterable[_T] = ...) -> None: ...
866 def add(self, __element: _T) -> None: ...
867 def clear(self) -> None: ...
868 def copy(self) -> set[_T]: ...
869 def difference(self, *s: Iterable[Any]) -> set[_T]: ...
870 def difference_update(self, *s: Iterable[Any]) -> None: ...
871 def discard(self, __element: _T) -> None: ...
872 def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
873 def intersection_update(self, *s: Iterable[Any]) -> None: ...
874 def isdisjoint(self, __s: Iterable[Any]) -> bool: ...
875 def issubset(self, __s: Iterable[Any]) -> bool: ...
876 def issuperset(self, __s: Iterable[Any]) -> bool: ...
877 def pop(self) -> _T: ...
878 def remove(self, __element: _T) -> None: ...
879 def symmetric_difference(self, __s: Iterable[_T]) -> set[_T]: ...
880 def symmetric_difference_update(self, __s: Iterable[_T]) -> None: ...
881 def union(self, *s: Iterable[_S]) -> set[_T | _S]: ...
882 def update(self, *s: Iterable[_T]) -> None: ...
883 def __len__(self) -> int: ...
884 def __contains__(self, __o: object) -> bool: ...
885 def __iter__(self) -> Iterator[_T]: ...
886 def __str__(self) -> str: ...
887 def __and__(self, __s: AbstractSet[object]) -> set[_T]: ...
888 def __iand__(self, __s: AbstractSet[object]) -> set[_T]: ...
889 def __or__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
890 def __ior__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
891 def __sub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ...
892 def __isub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ...
893 def __xor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
894 def __ixor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
895 def __le__(self, __s: AbstractSet[object]) -> bool: ...
896 def __lt__(self, __s: AbstractSet[object]) -> bool: ...
897 def __ge__(self, __s: AbstractSet[object]) -> bool: ...
898 def __gt__(self, __s: AbstractSet[object]) -> bool: ...
899 __hash__: None # type: ignore[assignment]
900 if sys.version_info >= (3, 9):
901 def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
903 class frozenset(AbstractSet[_T_co], Generic[_T_co]):
904 def __init__(self, __iterable: Iterable[_T_co] = ...) -> None: ...
905 def copy(self) -> frozenset[_T_co]: ...
906 def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
907 def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
908 def isdisjoint(self, __s: Iterable[_T_co]) -> bool: ...
909 def issubset(self, __s: Iterable[object]) -> bool: ...
910 def issuperset(self, __s: Iterable[object]) -> bool: ...
911 def symmetric_difference(self, __s: Iterable[_T_co]) -> frozenset[_T_co]: ...
912 def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ...
913 def __len__(self) -> int: ...
914 def __contains__(self, __o: object) -> bool: ...
915 def __iter__(self) -> Iterator[_T_co]: ...
916 def __str__(self) -> str: ...
917 def __and__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ...
918 def __or__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ...
919 def __sub__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ...
920 def __xor__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ...
921 def __le__(self, __s: AbstractSet[object]) -> bool: ...
922 def __lt__(self, __s: AbstractSet[object]) -> bool: ...
923 def __ge__(self, __s: AbstractSet[object]) -> bool: ...
924 def __gt__(self, __s: AbstractSet[object]) -> bool: ...
925 if sys.version_info >= (3, 9):
926 def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
928 class enumerate(Iterator[Tuple[int, _T]], Generic[_T]):
929 def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ...
930 def __iter__(self) -> Iterator[tuple[int, _T]]: ...
931 def __next__(self) -> tuple[int, _T]: ...
932 if sys.version_info >= (3, 9):
933 def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
936 class range(Sequence[int]):
941 def __init__(self, __stop: SupportsIndex) -> None: ...
943 def __init__(self, __start: SupportsIndex, __stop: SupportsIndex, __step: SupportsIndex = ...) -> None: ...
944 def count(self, __value: int) -> int: ...
945 def index(self, __value: int) -> int: ... # type: ignore[override]
946 def __len__(self) -> int: ...
947 def __contains__(self, __o: object) -> bool: ...
948 def __iter__(self) -> Iterator[int]: ...
950 def __getitem__(self, __i: SupportsIndex) -> int: ...
952 def __getitem__(self, __s: slice) -> range: ...
953 def __repr__(self) -> str: ...
954 def __reversed__(self) -> Iterator[int]: ...
956 class property(object):
957 fget: Callable[[Any], Any] | None
958 fset: Callable[[Any, Any], None] | None
959 fdel: Callable[[Any], None] | None
962 fget: Callable[[Any], Any] | None = ...,
963 fset: Callable[[Any, Any], None] | None = ...,
964 fdel: Callable[[Any], None] | None = ...,
965 doc: str | None = ...,
967 def getter(self, __fget: Callable[[Any], Any]) -> property: ...
968 def setter(self, __fset: Callable[[Any, Any], None]) -> property: ...
969 def deleter(self, __fdel: Callable[[Any], None]) -> property: ...
970 def __get__(self, __obj: Any, __type: type | None = ...) -> Any: ...
971 def __set__(self, __obj: Any, __value: Any) -> None: ...
972 def __delete__(self, __obj: Any) -> None: ...
975 class _NotImplementedType(Any): # type: ignore[misc]
976 # A little weird, but typing the __call__ as NotImplemented makes the error message
977 # for NotImplemented() much better
978 __call__: NotImplemented # type: ignore[valid-type]
980 NotImplemented: _NotImplementedType
982 def abs(__x: SupportsAbs[_T]) -> _T: ...
983 def all(__iterable: Iterable[object]) -> bool: ...
984 def any(__iterable: Iterable[object]) -> bool: ...
985 def ascii(__obj: object) -> str: ...
986 def bin(__number: int | SupportsIndex) -> str: ...
988 if sys.version_info >= (3, 7):
989 def breakpoint(*args: Any, **kws: Any) -> None: ...
991 def callable(__obj: object) -> TypeGuard[Callable[..., object]]: ...
992 def chr(__i: int) -> str: ...
994 # We define this here instead of using os.PathLike to avoid import cycle issues.
995 # See https://github.com/python/typeshed/pull/991#issuecomment-288160993
996 _AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True)
998 class _PathLike(Protocol[_AnyStr_co]):
999 def __fspath__(self) -> _AnyStr_co: ...
1001 if sys.version_info >= (3, 10):
1002 def aiter(__iterable: AsyncIterable[_T]) -> AsyncIterator[_T]: ...
1004 async def anext(__i: SupportsAnext[_T]) -> _T: ...
1006 async def anext(__i: SupportsAnext[_T], default: _VT) -> _T | _VT: ...
1008 # TODO: `compile` has a more precise return type in reality; work on a way of expressing that?
1009 if sys.version_info >= (3, 8):
1011 source: str | bytes | AST,
1012 filename: str | bytes | _PathLike[Any],
1015 dont_inherit: int = ...,
1016 optimize: int = ...,
1018 _feature_version: int = ...,
1023 source: str | bytes | AST,
1024 filename: str | bytes | _PathLike[Any],
1027 dont_inherit: int = ...,
1028 optimize: int = ...,
1031 def copyright() -> None: ...
1032 def credits() -> None: ...
1033 def delattr(__obj: object, __name: str) -> None: ...
1034 def dir(__o: object = ...) -> list[str]: ...
1036 def divmod(__x: SupportsDivMod[_T_contra, _T_co], __y: _T_contra) -> _T_co: ...
1038 def divmod(__x: _T_contra, __y: SupportsRDivMod[_T_contra, _T_co]) -> _T_co: ...
1040 # The `globals` argument to `eval` has to be `dict[str, Any]` rather than `dict[str, object]` due to invariance.
1041 # (The `globals` argument has to be a "real dict", rather than any old mapping, unlike the `locals` argument.)
1043 __source: str | bytes | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, object] | None = ...
1046 # Comment above regarding `eval` applies to `exec` as well
1048 __source: str | bytes | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, object] | None = ...
1050 def exit(code: object = ...) -> NoReturn: ...
1052 class filter(Iterator[_T], Generic[_T]):
1054 def __init__(self, __function: None, __iterable: Iterable[_T | None]) -> None: ...
1056 def __init__(self, __function: Callable[[_T], Any], __iterable: Iterable[_T]) -> None: ...
1057 def __iter__(self) -> Iterator[_T]: ...
1058 def __next__(self) -> _T: ...
1060 def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode
1062 def getattr(__o: object, __name: str) -> Any: ...
1064 # While technically covered by the last overload, spelling out the types for None, bool
1065 # and basic containers help mypy out in some tricky situations involving type context
1066 # (aka bidirectional inference)
1068 def getattr(__o: object, __name: str, __default: None) -> Any | None: ...
1070 def getattr(__o: object, __name: str, __default: bool) -> Any | bool: ...
1072 def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ...
1074 def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ...
1076 def getattr(__o: object, __name: str, __default: _T) -> Any | _T: ...
1077 def globals() -> dict[str, Any]: ...
1078 def hasattr(__obj: object, __name: str) -> bool: ...
1079 def hash(__obj: object) -> int: ...
1080 def help(*args: Any, **kwds: Any) -> None: ...
1081 def hex(__number: int | SupportsIndex) -> str: ...
1082 def id(__obj: object) -> int: ...
1083 def input(__prompt: object = ...) -> str: ...
1085 def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ...
1087 def iter(__function: Callable[[], _T | None], __sentinel: None) -> Iterator[_T]: ...
1089 def iter(__function: Callable[[], _T], __sentinel: object) -> Iterator[_T]: ...
1091 # We need recursive types to express the type of the second argument to `isinstance` properly, hence the use of `Any`
1092 if sys.version_info >= (3, 10):
1094 __obj: object, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...]
1097 __cls: type, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...]
1101 def isinstance(__obj: object, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ...
1102 def issubclass(__cls: type, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ...
1104 def len(__obj: Sized) -> int: ...
1105 def license() -> None: ...
1106 def locals() -> dict[str, Any]: ...
1108 class map(Iterator[_S], Generic[_S]):
1110 def __init__(self, __func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> None: ...
1112 def __init__(self, __func: Callable[[_T1, _T2], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> None: ...
1115 self, __func: Callable[[_T1, _T2, _T3], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]
1120 __func: Callable[[_T1, _T2, _T3, _T4], _S],
1121 __iter1: Iterable[_T1],
1122 __iter2: Iterable[_T2],
1123 __iter3: Iterable[_T3],
1124 __iter4: Iterable[_T4],
1129 __func: Callable[[_T1, _T2, _T3, _T4, _T5], _S],
1130 __iter1: Iterable[_T1],
1131 __iter2: Iterable[_T2],
1132 __iter3: Iterable[_T3],
1133 __iter4: Iterable[_T4],
1134 __iter5: Iterable[_T5],
1139 __func: Callable[..., _S],
1140 __iter1: Iterable[Any],
1141 __iter2: Iterable[Any],
1142 __iter3: Iterable[Any],
1143 __iter4: Iterable[Any],
1144 __iter5: Iterable[Any],
1145 __iter6: Iterable[Any],
1146 *iterables: Iterable[Any],
1148 def __iter__(self) -> Iterator[_S]: ...
1149 def __next__(self) -> _S: ...
1153 __arg1: SupportsGreaterThanT, __arg2: SupportsGreaterThanT, *_args: SupportsGreaterThanT, key: None = ...
1154 ) -> SupportsGreaterThanT: ...
1156 def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsGreaterThan]) -> _T: ...
1158 def max(__iterable: Iterable[SupportsGreaterThanT], *, key: None = ...) -> SupportsGreaterThanT: ...
1160 def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsGreaterThan]) -> _T: ...
1162 def max(__iterable: Iterable[SupportsGreaterThanT], *, key: None = ..., default: _T) -> SupportsGreaterThanT | _T: ...
1164 def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsGreaterThan], default: _T2) -> _T1 | _T2: ...
1167 __arg1: SupportsLessThanT, __arg2: SupportsLessThanT, *_args: SupportsLessThanT, key: None = ...
1168 ) -> SupportsLessThanT: ...
1170 def min(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsLessThan]) -> _T: ...
1172 def min(__iterable: Iterable[SupportsLessThanT], *, key: None = ...) -> SupportsLessThanT: ...
1174 def min(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan]) -> _T: ...
1176 def min(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., default: _T) -> SupportsLessThanT | _T: ...
1178 def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], default: _T2) -> _T1 | _T2: ...
1180 def next(__i: SupportsNext[_T]) -> _T: ...
1182 def next(__i: SupportsNext[_T], __default: _VT) -> _T | _VT: ...
1183 def oct(__number: int | SupportsIndex) -> str: ...
1185 _OpenFile = Union[StrOrBytesPath, int]
1186 _Opener = Callable[[str, int], int]
1188 # Text mode: always returns a TextIOWrapper
1192 mode: OpenTextMode = ...,
1193 buffering: int = ...,
1194 encoding: str | None = ...,
1195 errors: str | None = ...,
1196 newline: str | None = ...,
1197 closefd: bool = ...,
1198 opener: _Opener | None = ...,
1199 ) -> TextIOWrapper: ...
1201 # Unbuffered binary mode: returns a FileIO
1205 mode: OpenBinaryMode,
1206 buffering: Literal[0],
1207 encoding: None = ...,
1209 newline: None = ...,
1210 closefd: bool = ...,
1211 opener: _Opener | None = ...,
1214 # Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter
1218 mode: OpenBinaryModeUpdating,
1219 buffering: Literal[-1, 1] = ...,
1220 encoding: None = ...,
1222 newline: None = ...,
1223 closefd: bool = ...,
1224 opener: _Opener | None = ...,
1225 ) -> BufferedRandom: ...
1229 mode: OpenBinaryModeWriting,
1230 buffering: Literal[-1, 1] = ...,
1231 encoding: None = ...,
1233 newline: None = ...,
1234 closefd: bool = ...,
1235 opener: _Opener | None = ...,
1236 ) -> BufferedWriter: ...
1240 mode: OpenBinaryModeReading,
1241 buffering: Literal[-1, 1] = ...,
1242 encoding: None = ...,
1244 newline: None = ...,
1245 closefd: bool = ...,
1246 opener: _Opener | None = ...,
1247 ) -> BufferedReader: ...
1249 # Buffering cannot be determined: fall back to BinaryIO
1253 mode: OpenBinaryMode,
1255 encoding: None = ...,
1257 newline: None = ...,
1258 closefd: bool = ...,
1259 opener: _Opener | None = ...,
1262 # Fallback if mode is not specified
1267 buffering: int = ...,
1268 encoding: str | None = ...,
1269 errors: str | None = ...,
1270 newline: str | None = ...,
1271 closefd: bool = ...,
1272 opener: _Opener | None = ...,
1274 def ord(__c: str | bytes) -> int: ...
1276 class _SupportsWriteAndFlush(SupportsWrite[_T_contra], Protocol[_T_contra]):
1277 def flush(self) -> None: ...
1282 sep: str | None = ...,
1283 end: str | None = ...,
1284 file: SupportsWrite[str] | None = ...,
1285 flush: Literal[False] = ...,
1289 *values: object, sep: str | None = ..., end: str | None = ..., file: _SupportsWriteAndFlush[str] | None = ..., flush: bool
1292 _E = TypeVar("_E", contravariant=True)
1293 _M = TypeVar("_M", contravariant=True)
1295 class _SupportsPow2(Protocol[_E, _T_co]):
1296 def __pow__(self, __other: _E) -> _T_co: ...
1298 class _SupportsPow3NoneOnly(Protocol[_E, _T_co]):
1299 def __pow__(self, __other: _E, __modulo: None = ...) -> _T_co: ...
1301 class _SupportsPow3(Protocol[_E, _M, _T_co]):
1302 def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ...
1304 _SupportsSomeKindOfPow = Union[_SupportsPow2[Any, Any], _SupportsPow3NoneOnly[Any, Any], _SupportsPow3[Any, Any, Any]]
1306 if sys.version_info >= (3, 8):
1308 def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ...
1310 def pow(base: int, exp: int, mod: int) -> int: ...
1312 def pow(base: int, exp: _PositiveInteger, mod: None = ...) -> int: ... # type: ignore[misc]
1314 def pow(base: int, exp: _NegativeInteger, mod: None = ...) -> float: ... # type: ignore[misc]
1315 # int base & positive-int exp -> int; int base & negative-int exp -> float
1316 # return type must be Any as `int | float` causes too many false-positive errors
1318 def pow(base: int, exp: int, mod: None = ...) -> Any: ...
1320 def pow(base: float, exp: int, mod: None = ...) -> float: ...
1321 # float base & float exp could return float or complex
1322 # return type must be Any (same as complex base, complex exp),
1323 # as `float | complex` causes too many false-positive errors
1325 def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = ...) -> Any: ...
1327 def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = ...) -> complex: ...
1329 def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = ...) -> _T_co: ...
1331 def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = ...) -> _T_co: ...
1333 def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M = ...) -> _T_co: ...
1335 def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = ...) -> Any: ...
1337 def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = ...) -> complex: ...
1341 def pow(__base: int, __exp: int, __mod: Literal[0]) -> NoReturn: ...
1343 def pow(__base: int, __exp: int, __mod: int) -> int: ...
1345 def pow(__base: int, __exp: _PositiveInteger, __mod: None = ...) -> int: ... # type: ignore[misc]
1347 def pow(__base: int, __exp: _NegativeInteger, __mod: None = ...) -> float: ... # type: ignore[misc]
1349 def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ...
1351 def pow(__base: float, __exp: int, __mod: None = ...) -> float: ...
1353 def pow(__base: float, __exp: complex | _SupportsSomeKindOfPow, __mod: None = ...) -> Any: ...
1355 def pow(__base: complex, __exp: complex | _SupportsSomeKindOfPow, __mod: None = ...) -> complex: ...
1357 def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E, __mod: None = ...) -> _T_co: ...
1359 def pow(__base: _SupportsPow3NoneOnly[_E, _T_co], __exp: _E, __mod: None = ...) -> _T_co: ...
1361 def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M = ...) -> _T_co: ...
1363 def pow(__base: _SupportsSomeKindOfPow, __exp: float, __mod: None = ...) -> Any: ...
1365 def pow(__base: _SupportsSomeKindOfPow, __exp: complex, __mod: None = ...) -> complex: ...
1367 def quit(code: object = ...) -> NoReturn: ...
1369 class reversed(Iterator[_T], Generic[_T]):
1371 def __init__(self, __sequence: Reversible[_T]) -> None: ...
1373 def __init__(self, __sequence: SupportsLenAndGetItem[_T]) -> None: ...
1374 def __iter__(self) -> Iterator[_T]: ...
1375 def __next__(self) -> _T: ...
1377 def repr(__obj: object) -> str: ...
1379 def round(number: SupportsRound[Any]) -> int: ...
1381 def round(number: SupportsRound[Any], ndigits: None) -> int: ...
1383 def round(number: SupportsRound[_T], ndigits: SupportsIndex) -> _T: ...
1385 # See https://github.com/python/typeshed/pull/6292#discussion_r748875189
1386 # for why arg 3 of `setattr` should be annotated with `Any` and not `object`
1387 def setattr(__obj: object, __name: str, __value: Any) -> None: ...
1389 def sorted(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., reverse: bool = ...) -> list[SupportsLessThanT]: ...
1391 def sorted(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan], reverse: bool = ...) -> list[_T]: ...
1393 if sys.version_info >= (3, 8):
1395 def sum(__iterable: Iterable[_T]) -> _T | int: ...
1397 def sum(__iterable: Iterable[_T], start: _S) -> _T | _S: ...
1401 def sum(__iterable: Iterable[_T]) -> _T | int: ...
1403 def sum(__iterable: Iterable[_T], __start: _S) -> _T | _S: ...
1405 # The argument to `vars()` has to have a `__dict__` attribute, so can't be annotated with `object`
1406 # (A "SupportsDunderDict" protocol doesn't work)
1407 def vars(__object: Any = ...) -> dict[str, Any]: ...
1409 class zip(Iterator[_T_co], Generic[_T_co]):
1410 if sys.version_info >= (3, 10):
1412 def __new__(cls, __iter1: Iterable[_T1], *, strict: bool = ...) -> zip[tuple[_T1]]: ...
1414 def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], *, strict: bool = ...) -> zip[tuple[_T1, _T2]]: ...
1417 cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], *, strict: bool = ...
1418 ) -> zip[tuple[_T1, _T2, _T3]]: ...
1422 __iter1: Iterable[_T1],
1423 __iter2: Iterable[_T2],
1424 __iter3: Iterable[_T3],
1425 __iter4: Iterable[_T4],
1428 ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ...
1432 __iter1: Iterable[_T1],
1433 __iter2: Iterable[_T2],
1434 __iter3: Iterable[_T3],
1435 __iter4: Iterable[_T4],
1436 __iter5: Iterable[_T5],
1439 ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
1443 __iter1: Iterable[Any],
1444 __iter2: Iterable[Any],
1445 __iter3: Iterable[Any],
1446 __iter4: Iterable[Any],
1447 __iter5: Iterable[Any],
1448 __iter6: Iterable[Any],
1449 *iterables: Iterable[Any],
1451 ) -> zip[Tuple[Any, ...]]: ...
1454 def __new__(cls, __iter1: Iterable[_T1]) -> zip[tuple[_T1]]: ...
1456 def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> zip[tuple[_T1, _T2]]: ...
1458 def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> zip[tuple[_T1, _T2, _T3]]: ...
1461 cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4]
1462 ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ...
1466 __iter1: Iterable[_T1],
1467 __iter2: Iterable[_T2],
1468 __iter3: Iterable[_T3],
1469 __iter4: Iterable[_T4],
1470 __iter5: Iterable[_T5],
1471 ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
1475 __iter1: Iterable[Any],
1476 __iter2: Iterable[Any],
1477 __iter3: Iterable[Any],
1478 __iter4: Iterable[Any],
1479 __iter5: Iterable[Any],
1480 __iter6: Iterable[Any],
1481 *iterables: Iterable[Any],
1482 ) -> zip[Tuple[Any, ...]]: ...
1483 def __iter__(self) -> Iterator[_T_co]: ...
1484 def __next__(self) -> _T_co: ...
1486 # Signature of `builtins.__import__` should be kept identical to `importlib.__import__`
1487 # Return type of `__import__` should be kept the same as return type of `importlib.import_module`
1490 globals: Mapping[str, object] | None = ...,
1491 locals: Mapping[str, object] | None = ...,
1492 fromlist: Sequence[str] = ...,
1494 ) -> types.ModuleType: ...
1496 # Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
1497 # not exposed anywhere under that name, we make it private here.
1503 class BaseException(object):
1504 args: Tuple[Any, ...]
1505 __cause__: BaseException | None
1506 __context__: BaseException | None
1507 __suppress_context__: bool
1508 __traceback__: TracebackType | None
1509 def __init__(self, *args: object) -> None: ...
1510 def __str__(self) -> str: ...
1511 def __repr__(self) -> str: ...
1512 def with_traceback(self: _TBE, __tb: TracebackType | None) -> _TBE: ...
1514 class GeneratorExit(BaseException): ...
1515 class KeyboardInterrupt(BaseException): ...
1517 class SystemExit(BaseException):
1520 class Exception(BaseException): ...
1522 class StopIteration(Exception):
1525 _StandardError = Exception
1527 class OSError(Exception):
1530 # filename, filename2 are actually str | bytes | None
1533 if sys.platform == "win32":
1536 EnvironmentError = OSError
1538 if sys.platform == "win32":
1539 WindowsError = OSError
1541 class ArithmeticError(_StandardError): ...
1542 class AssertionError(_StandardError): ...
1544 class AttributeError(_StandardError):
1545 if sys.version_info >= (3, 10):
1549 class BufferError(_StandardError): ...
1550 class EOFError(_StandardError): ...
1552 class ImportError(_StandardError):
1553 def __init__(self, *args: object, name: str | None = ..., path: str | None = ...) -> None: ...
1556 msg: str # undocumented
1558 class LookupError(_StandardError): ...
1559 class MemoryError(_StandardError): ...
1561 class NameError(_StandardError):
1562 if sys.version_info >= (3, 10):
1565 class ReferenceError(_StandardError): ...
1566 class RuntimeError(_StandardError): ...
1568 class StopAsyncIteration(Exception):
1571 class SyntaxError(_StandardError):
1576 filename: str | None
1577 if sys.version_info >= (3, 10):
1578 end_lineno: int | None
1579 end_offset: int | None
1581 class SystemError(_StandardError): ...
1582 class TypeError(_StandardError): ...
1583 class ValueError(_StandardError): ...
1584 class FloatingPointError(ArithmeticError): ...
1585 class OverflowError(ArithmeticError): ...
1586 class ZeroDivisionError(ArithmeticError): ...
1587 class ModuleNotFoundError(ImportError): ...
1588 class IndexError(LookupError): ...
1589 class KeyError(LookupError): ...
1590 class UnboundLocalError(NameError): ...
1592 class BlockingIOError(OSError):
1593 characters_written: int
1595 class ChildProcessError(OSError): ...
1596 class ConnectionError(OSError): ...
1597 class BrokenPipeError(ConnectionError): ...
1598 class ConnectionAbortedError(ConnectionError): ...
1599 class ConnectionRefusedError(ConnectionError): ...
1600 class ConnectionResetError(ConnectionError): ...
1601 class FileExistsError(OSError): ...
1602 class FileNotFoundError(OSError): ...
1603 class InterruptedError(OSError): ...
1604 class IsADirectoryError(OSError): ...
1605 class NotADirectoryError(OSError): ...
1606 class PermissionError(OSError): ...
1607 class ProcessLookupError(OSError): ...
1608 class TimeoutError(OSError): ...
1609 class NotImplementedError(RuntimeError): ...
1610 class RecursionError(RuntimeError): ...
1611 class IndentationError(SyntaxError): ...
1612 class TabError(IndentationError): ...
1613 class UnicodeError(ValueError): ...
1615 class UnicodeDecodeError(UnicodeError):
1621 def __init__(self, __encoding: str, __object: bytes, __start: int, __end: int, __reason: str) -> None: ...
1623 class UnicodeEncodeError(UnicodeError):
1629 def __init__(self, __encoding: str, __object: str, __start: int, __end: int, __reason: str) -> None: ...
1631 class UnicodeTranslateError(UnicodeError): ...
1632 class Warning(Exception): ...
1633 class UserWarning(Warning): ...
1634 class DeprecationWarning(Warning): ...
1635 class SyntaxWarning(Warning): ...
1636 class RuntimeWarning(Warning): ...
1637 class FutureWarning(Warning): ...
1638 class PendingDeprecationWarning(Warning): ...
1639 class ImportWarning(Warning): ...
1640 class UnicodeWarning(Warning): ...
1641 class BytesWarning(Warning): ...
1642 class ResourceWarning(Warning): ...
1644 if sys.version_info >= (3, 10):
1645 class EncodingWarning(Warning): ...