1 import collections # Needed by aliases like DefaultDict, see mypy issue 2986
3 from abc import ABCMeta, abstractmethod
4 from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
5 from typing_extensions import Literal as _Literal, ParamSpec as _ParamSpec, final as _final
7 if sys.version_info >= (3, 7):
8 from types import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType
10 if sys.version_info >= (3, 9):
11 from types import GenericAlias
13 # Definitions of special type checking related constructs. Their definitions
14 # are not used, so their value does not matter.
20 __bound__: Type[Any] | None
21 __constraints__: Tuple[Type[Any], ...]
23 __contravariant__: bool
27 *constraints: Type[Any],
28 bound: None | Type[Any] | str = ...,
29 covariant: bool = ...,
30 contravariant: bool = ...,
36 def __getitem__(self, typeargs: Any) -> object: ...
38 _F = TypeVar("_F", bound=Callable[..., Any])
42 def overload(func: _F) -> _F: ...
44 Union: _SpecialForm = ...
45 Optional: _SpecialForm = ...
46 Tuple: _SpecialForm = ...
47 Generic: _SpecialForm = ...
48 # Protocol is only present in 3.8 and later, but mypy needs it unconditionally
49 Protocol: _SpecialForm = ...
50 Callable: _SpecialForm = ...
51 Type: _SpecialForm = ...
52 ClassVar: _SpecialForm = ...
53 NoReturn: _SpecialForm = ...
54 if sys.version_info >= (3, 8):
55 Final: _SpecialForm = ...
56 def final(f: _T) -> _T: ...
57 Literal: _SpecialForm = ...
58 # TypedDict is a (non-subscriptable) special form.
61 if sys.version_info < (3, 7):
62 class GenericMeta(type): ...
64 if sys.version_info >= (3, 10):
67 def __init__(self, origin: ParamSpec) -> None: ...
68 class ParamSpecKwargs:
70 def __init__(self, origin: ParamSpec) -> None: ...
73 __bound__: Type[Any] | None
75 __contravariant__: bool
77 self, name: str, *, bound: None | Type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ...
80 def args(self) -> ParamSpecArgs: ...
82 def kwargs(self) -> ParamSpecKwargs: ...
83 Concatenate: _SpecialForm = ...
84 TypeAlias: _SpecialForm = ...
85 TypeGuard: _SpecialForm = ...
87 # These type variables are used by the container types.
89 _KT = TypeVar("_KT") # Key type.
90 _VT = TypeVar("_VT") # Value type.
91 _T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers.
92 _V_co = TypeVar("_V_co", covariant=True) # Any type covariant containers.
93 _KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
94 _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
95 _T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant.
96 _TC = TypeVar("_TC", bound=Type[object])
98 def no_type_check(arg: _F) -> _F: ...
99 def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore
101 # Type aliases and type constructors
104 # Class for defining generic aliases for library types.
105 def __getitem__(self, typeargs: Any) -> Any: ...
109 DefaultDict = _Alias()
116 if sys.version_info >= (3, 7):
117 OrderedDict = _Alias()
119 if sys.version_info >= (3, 9):
120 Annotated: _SpecialForm = ...
122 # Predefined type variables.
123 AnyStr = TypeVar("AnyStr", str, bytes)
125 # Abstract base classes.
127 def runtime_checkable(cls: _TC) -> _TC: ...
129 class SupportsInt(Protocol, metaclass=ABCMeta):
131 def __int__(self) -> int: ...
134 class SupportsFloat(Protocol, metaclass=ABCMeta):
136 def __float__(self) -> float: ...
139 class SupportsComplex(Protocol, metaclass=ABCMeta):
141 def __complex__(self) -> complex: ...
144 class SupportsBytes(Protocol, metaclass=ABCMeta):
146 def __bytes__(self) -> bytes: ...
148 if sys.version_info >= (3, 8):
150 class SupportsIndex(Protocol, metaclass=ABCMeta):
152 def __index__(self) -> int: ...
155 class SupportsAbs(Protocol[_T_co]):
157 def __abs__(self) -> _T_co: ...
160 class SupportsRound(Protocol[_T_co]):
163 def __round__(self) -> int: ...
166 def __round__(self, __ndigits: int) -> _T_co: ...
169 class Sized(Protocol, metaclass=ABCMeta):
171 def __len__(self) -> int: ...
174 class Hashable(Protocol, metaclass=ABCMeta):
175 # TODO: This is special, in that a subclass of a hashable class may not be hashable
176 # (for example, list vs. object). It's not obvious how to represent this. This class
177 # is currently mostly useless for static checking.
179 def __hash__(self) -> int: ...
182 class Iterable(Protocol[_T_co]):
184 def __iter__(self) -> Iterator[_T_co]: ...
187 class Iterator(Iterable[_T_co], Protocol[_T_co]):
189 def __next__(self) -> _T_co: ...
190 def __iter__(self) -> Iterator[_T_co]: ...
193 class Reversible(Iterable[_T_co], Protocol[_T_co]):
195 def __reversed__(self) -> Iterator[_T_co]: ...
197 class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
198 def __next__(self) -> _T_co: ...
200 def send(self, __value: _T_contra) -> _T_co: ...
204 self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
208 def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
209 def close(self) -> None: ...
210 def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ...
212 def gi_code(self) -> CodeType: ...
214 def gi_frame(self) -> FrameType: ...
216 def gi_running(self) -> bool: ...
218 def gi_yieldfrom(self) -> Generator[Any, Any, Any] | None: ...
221 class Awaitable(Protocol[_T_co]):
223 def __await__(self) -> Generator[Any, None, _T_co]: ...
225 class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
229 def cr_await(self) -> Any | None: ...
231 def cr_code(self) -> CodeType: ...
233 def cr_frame(self) -> FrameType: ...
235 def cr_running(self) -> bool: ...
237 def send(self, __value: _T_contra) -> _T_co: ...
241 self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
245 def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
247 def close(self) -> None: ...
249 # NOTE: This type does not exist in typing.py or PEP 484.
250 # The parameters correspond to Generator, but the 4th is the original type.
251 class AwaitableGenerator(
252 Awaitable[_V_co], Generator[_T_co, _T_contra, _V_co], Generic[_T_co, _T_contra, _V_co, _S], metaclass=ABCMeta
256 class AsyncIterable(Protocol[_T_co]):
258 def __aiter__(self) -> AsyncIterator[_T_co]: ...
261 class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]):
263 def __anext__(self) -> Awaitable[_T_co]: ...
264 def __aiter__(self) -> AsyncIterator[_T_co]: ...
266 class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):
268 def __anext__(self) -> Awaitable[_T_co]: ...
270 def asend(self, __value: _T_contra) -> Awaitable[_T_co]: ...
274 self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
275 ) -> Awaitable[_T_co]: ...
278 def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ...
280 def aclose(self) -> Awaitable[None]: ...
282 def __aiter__(self) -> AsyncGenerator[_T_co, _T_contra]: ...
284 def ag_await(self) -> Any: ...
286 def ag_code(self) -> CodeType: ...
288 def ag_frame(self) -> FrameType: ...
290 def ag_running(self) -> bool: ...
293 class Container(Protocol[_T_co]):
295 def __contains__(self, __x: object) -> bool: ...
298 class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
299 # Implement Sized (but don't have it as a base class).
301 def __len__(self) -> int: ...
303 class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
306 def __getitem__(self, i: int) -> _T_co: ...
309 def __getitem__(self, s: slice) -> Sequence[_T_co]: ...
311 def index(self, value: Any, start: int = ..., stop: int = ...) -> int: ...
312 def count(self, value: Any) -> int: ...
313 def __contains__(self, x: object) -> bool: ...
314 def __iter__(self) -> Iterator[_T_co]: ...
315 def __reversed__(self) -> Iterator[_T_co]: ...
317 class MutableSequence(Sequence[_T], Generic[_T]):
319 def insert(self, index: int, value: _T) -> None: ...
322 def __getitem__(self, i: int) -> _T: ...
325 def __getitem__(self, s: slice) -> MutableSequence[_T]: ...
328 def __setitem__(self, i: int, o: _T) -> None: ...
331 def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
334 def __delitem__(self, i: int) -> None: ...
337 def __delitem__(self, i: slice) -> None: ...
339 def append(self, value: _T) -> None: ...
340 def clear(self) -> None: ...
341 def extend(self, values: Iterable[_T]) -> None: ...
342 def reverse(self) -> None: ...
343 def pop(self, index: int = ...) -> _T: ...
344 def remove(self, value: _T) -> None: ...
345 def __iadd__(self, x: Iterable[_T]) -> MutableSequence[_T]: ...
347 class AbstractSet(Collection[_T_co], Generic[_T_co]):
349 def __contains__(self, x: object) -> bool: ...
351 def __le__(self, s: AbstractSet[Any]) -> bool: ...
352 def __lt__(self, s: AbstractSet[Any]) -> bool: ...
353 def __gt__(self, s: AbstractSet[Any]) -> bool: ...
354 def __ge__(self, s: AbstractSet[Any]) -> bool: ...
355 def __and__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
356 def __or__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
357 def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
358 def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
359 def isdisjoint(self, other: Iterable[Any]) -> bool: ...
361 class MutableSet(AbstractSet[_T], Generic[_T]):
363 def add(self, value: _T) -> None: ...
365 def discard(self, value: _T) -> None: ...
367 def clear(self) -> None: ...
368 def pop(self) -> _T: ...
369 def remove(self, value: _T) -> None: ...
370 def __ior__(self, s: AbstractSet[_S]) -> MutableSet[_T | _S]: ...
371 def __iand__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
372 def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[_T | _S]: ...
373 def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
375 class MappingView(Sized):
376 def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented
377 def __len__(self) -> int: ...
379 class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
380 def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
381 def __and__(self, o: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
382 def __rand__(self, o: Iterable[_T]) -> set[_T]: ...
383 def __contains__(self, o: object) -> bool: ...
384 def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
385 if sys.version_info >= (3, 8):
386 def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
387 def __or__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
388 def __ror__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
389 def __sub__(self, o: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
390 def __rsub__(self, o: Iterable[_T]) -> set[_T]: ...
391 def __xor__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
392 def __rxor__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
394 class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
395 def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented
396 def __and__(self, o: Iterable[Any]) -> set[_KT_co]: ...
397 def __rand__(self, o: Iterable[_T]) -> set[_T]: ...
398 def __contains__(self, o: object) -> bool: ...
399 def __iter__(self) -> Iterator[_KT_co]: ...
400 if sys.version_info >= (3, 8):
401 def __reversed__(self) -> Iterator[_KT_co]: ...
402 def __or__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
403 def __ror__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
404 def __sub__(self, o: Iterable[Any]) -> set[_KT_co]: ...
405 def __rsub__(self, o: Iterable[_T]) -> set[_T]: ...
406 def __xor__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
407 def __rxor__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
409 class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):
410 def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented
411 def __contains__(self, o: object) -> bool: ...
412 def __iter__(self) -> Iterator[_VT_co]: ...
413 if sys.version_info >= (3, 8):
414 def __reversed__(self) -> Iterator[_VT_co]: ...
417 class ContextManager(Protocol[_T_co]):
418 def __enter__(self) -> _T_co: ...
420 self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
421 ) -> bool | None: ...
424 class AsyncContextManager(Protocol[_T_co]):
425 def __aenter__(self) -> Awaitable[_T_co]: ...
427 self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
428 ) -> Awaitable[bool | None]: ...
430 class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
431 # TODO: We wish the key type could also be covariant, but that doesn't work,
432 # see discussion in https://github.com/python/typing/pull/273.
434 def __getitem__(self, __k: _KT) -> _VT_co: ...
437 def get(self, key: _KT) -> _VT_co | None: ...
439 def get(self, __key: _KT, __default: _VT_co | _T) -> _VT_co | _T: ...
440 def items(self) -> ItemsView[_KT, _VT_co]: ...
441 def keys(self) -> KeysView[_KT]: ...
442 def values(self) -> ValuesView[_VT_co]: ...
443 def __contains__(self, __o: object) -> bool: ...
445 class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
447 def __setitem__(self, __k: _KT, __v: _VT) -> None: ...
449 def __delitem__(self, __v: _KT) -> None: ...
450 def clear(self) -> None: ...
452 def pop(self, __key: _KT) -> _VT: ...
454 def pop(self, __key: _KT, __default: _VT | _T = ...) -> _VT | _T: ...
455 def popitem(self) -> tuple[_KT, _VT]: ...
456 def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ...
457 # 'update' used to take a Union, but using overloading is better.
458 # The second overloaded type here is a bit too general, because
459 # Mapping[Tuple[_KT, _VT], W] is a subclass of Iterable[Tuple[_KT, _VT]],
460 # but will always have the behavior of the first overloaded type
461 # at runtime, leading to keys of a mix of types _KT and Tuple[_KT, _VT].
462 # We don't currently have any way of forcing all Mappings to use
463 # the first overload, but by using overloading rather than a Union,
464 # mypy will commit to using the first overload when the argument is
465 # known to be a Mapping with unknown type parameters, which is closer
466 # to the behavior we want. See mypy issue #1430.
468 def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
470 def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
472 def update(self, **kwargs: _VT) -> None: ...
478 class IO(Iterator[AnyStr], Generic[AnyStr]):
479 # TODO use abstract properties
481 def mode(self) -> str: ...
483 def name(self) -> str: ...
485 def close(self) -> None: ...
487 def closed(self) -> bool: ...
489 def fileno(self) -> int: ...
491 def flush(self) -> None: ...
493 def isatty(self) -> bool: ...
495 def read(self, n: int = ...) -> AnyStr: ...
497 def readable(self) -> bool: ...
499 def readline(self, limit: int = ...) -> AnyStr: ...
501 def readlines(self, hint: int = ...) -> list[AnyStr]: ...
503 def seek(self, offset: int, whence: int = ...) -> int: ...
505 def seekable(self) -> bool: ...
507 def tell(self) -> int: ...
509 def truncate(self, size: int | None = ...) -> int: ...
511 def writable(self) -> bool: ...
513 def write(self, s: AnyStr) -> int: ...
515 def writelines(self, lines: Iterable[AnyStr]) -> None: ...
517 def __next__(self) -> AnyStr: ...
519 def __iter__(self) -> Iterator[AnyStr]: ...
521 def __enter__(self) -> IO[AnyStr]: ...
524 self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
525 ) -> bool | None: ...
527 class BinaryIO(IO[bytes]):
529 def __enter__(self) -> BinaryIO: ...
531 class TextIO(IO[str]):
532 # TODO use abstractproperty
534 def buffer(self) -> BinaryIO: ...
536 def encoding(self) -> str: ...
538 def errors(self) -> str | None: ...
540 def line_buffering(self) -> int: ... # int on PyPy, bool on CPython
542 def newlines(self) -> Any: ... # None, str or tuple
544 def __enter__(self) -> TextIO: ...
546 class ByteString(Sequence[int], metaclass=ABCMeta): ...
549 class Match(Generic[AnyStr]):
552 lastindex: int | None
553 lastgroup: AnyStr | None
556 # The regular expression object whose match() or search() method produced
557 # this match instance.
559 def expand(self, template: AnyStr) -> AnyStr: ...
560 # group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
562 def group(self, __group: _Literal[0] = ...) -> AnyStr: ...
564 def group(self, __group: str | int) -> AnyStr | Any: ...
566 def group(self, __group1: str | int, __group2: str | int, *groups: str | int) -> Tuple[AnyStr | Any, ...]: ...
567 # Each item of groups()'s return tuple is either "AnyStr" or
568 # "AnyStr | None", depending on the pattern.
570 def groups(self) -> Tuple[AnyStr | Any, ...]: ...
572 def groups(self, default: _T) -> Tuple[AnyStr | _T, ...]: ...
573 # Each value in groupdict()'s return dict is either "AnyStr" or
574 # "AnyStr | None", depending on the pattern.
576 def groupdict(self) -> dict[str, AnyStr | Any]: ...
578 def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ...
579 def start(self, __group: int | str = ...) -> int: ...
580 def end(self, __group: int | str = ...) -> int: ...
581 def span(self, __group: int | str = ...) -> tuple[int, int]: ...
583 def regs(self) -> Tuple[tuple[int, int], ...]: ... # undocumented
584 # __getitem__() returns "AnyStr" or "AnyStr | None", depending on the pattern.
586 def __getitem__(self, __key: _Literal[0]) -> AnyStr: ...
588 def __getitem__(self, __key: int | str) -> AnyStr | Any: ...
589 if sys.version_info >= (3, 9):
590 def __class_getitem__(cls, item: Any) -> GenericAlias: ...
593 class Pattern(Generic[AnyStr]):
595 groupindex: Mapping[str, int]
598 def search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
599 def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
600 def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
601 def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ...
602 def findall(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> list[Any]: ...
603 def finditer(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Iterator[Match[AnyStr]]: ...
605 def sub(self, repl: AnyStr, string: AnyStr, count: int = ...) -> AnyStr: ...
607 def sub(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> AnyStr: ...
609 def subn(self, repl: AnyStr, string: AnyStr, count: int = ...) -> tuple[AnyStr, int]: ...
611 def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> tuple[AnyStr, int]: ...
612 if sys.version_info >= (3, 9):
613 def __class_getitem__(cls, item: Any) -> GenericAlias: ...
617 if sys.version_info >= (3, 7):
618 _get_type_hints_obj_allowed_types = Union[
625 WrapperDescriptorType,
627 MethodDescriptorType,
630 _get_type_hints_obj_allowed_types = Union[
631 object, Callable[..., Any], FunctionType, BuiltinFunctionType, MethodType, ModuleType,
634 if sys.version_info >= (3, 9):
636 obj: _get_type_hints_obj_allowed_types,
637 globalns: dict[str, Any] | None = ...,
638 localns: dict[str, Any] | None = ...,
639 include_extras: bool = ...,
640 ) -> dict[str, Any]: ...
644 obj: _get_type_hints_obj_allowed_types, globalns: dict[str, Any] | None = ..., localns: dict[str, Any] | None = ...
645 ) -> dict[str, Any]: ...
647 if sys.version_info >= (3, 8):
648 def get_origin(tp: Any) -> Any | None: ...
649 def get_args(tp: Any) -> Tuple[Any, ...]: ...
652 def cast(typ: Type[_T], val: Any) -> _T: ...
654 def cast(typ: str, val: Any) -> Any: ...
656 def cast(typ: object, val: Any) -> Any: ...
660 # NamedTuple is special-cased in the type checker
661 class NamedTuple(Tuple[Any, ...]):
662 _field_types: collections.OrderedDict[str, Type[Any]]
663 _field_defaults: dict[str, Any]
664 _fields: Tuple[str, ...]
667 def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ...
669 def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ...
671 def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
672 if sys.version_info >= (3, 8):
673 def _asdict(self) -> dict[str, Any]: ...
675 def _asdict(self) -> collections.OrderedDict[str, Any]: ...
676 def _replace(self: _T, **kwargs: Any) -> _T: ...
678 # Internal mypy fallback type for all typed dicts (does not exist at runtime)
679 class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
680 def copy(self: _T) -> _T: ...
681 # Using NoReturn so that only calls using mypy plugin hook that specialize the signature
683 def setdefault(self, k: NoReturn, default: object) -> object: ...
684 # Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
685 def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore
686 def update(self: _T, __m: _T) -> None: ...
687 def __delitem__(self, k: NoReturn) -> None: ...
688 def items(self) -> ItemsView[str, object]: ...
689 def keys(self) -> KeysView[str]: ...
690 def values(self) -> ValuesView[object]: ...
691 def __or__(self: _T, __value: _T) -> _T: ...
692 def __ior__(self: _T, __value: _T) -> _T: ...
694 def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
696 # This itself is only available during type checking
697 def type_check_only(func_or_cls: _F) -> _F: ...
699 if sys.version_info >= (3, 7):
702 __forward_code__: CodeType
703 __forward_evaluated__: bool
704 __forward_value__: Any | None
705 __forward_is_argument__: bool
706 if sys.version_info >= (3, 9):
707 # The module argument was added in Python 3.9.7.
708 def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ...) -> None: ...
710 def __init__(self, arg: str, is_argument: bool = ...) -> None: ...
711 def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ...
712 def __eq__(self, other: Any) -> bool: ...
713 def __hash__(self) -> int: ...
714 def __repr__(self) -> str: ...
716 if sys.version_info >= (3, 10):
717 def is_typeddict(tp: Any) -> bool: ...