mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-07 18:30:57 +08:00
Add TypedDict to typing_extensions (#2940)
Since there is a PEP for `TypedDict` (PEP 589), it is being added to `typing_extension`, see https://github.com/python/typing/pull/628. This PR essentially copies the definition from `mypy_extensions`. Corresponding mypy PR https://github.com/python/mypy/pull/6744 can be merged independently of this PR.
This commit is contained in:
23
third_party/2and3/typing_extensions.pyi
vendored
23
third_party/2and3/typing_extensions.pyi
vendored
@@ -1,3 +1,4 @@
|
||||
import abc
|
||||
import sys
|
||||
from typing import Callable
|
||||
from typing import ClassVar as ClassVar
|
||||
@@ -11,8 +12,9 @@ from typing import overload as overload
|
||||
from typing import Text as Text
|
||||
from typing import Type as Type
|
||||
from typing import TYPE_CHECKING as TYPE_CHECKING
|
||||
from typing import TypeVar, Any
|
||||
from typing import TypeVar, Any, Mapping, ItemsView, KeysView, ValuesView, Dict, Type
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_F = TypeVar('_F', bound=Callable[..., Any])
|
||||
_TC = TypeVar('_TC', bound=Type[object])
|
||||
class _SpecialForm:
|
||||
@@ -23,6 +25,25 @@ Final: _SpecialForm = ...
|
||||
def final(f: _F) -> _F: ...
|
||||
Literal: _SpecialForm = ...
|
||||
|
||||
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
|
||||
class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
def copy(self: _T) -> _T: ...
|
||||
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
|
||||
# can go through.
|
||||
def setdefault(self, k: NoReturn, default: object) -> object: ...
|
||||
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
|
||||
def pop(self, k: NoReturn, default: _T = ...) -> object: ...
|
||||
def update(self: _T, __m: _T) -> None: ...
|
||||
if sys.version_info < (3, 0):
|
||||
def has_key(self, k: str) -> bool: ...
|
||||
def viewitems(self) -> ItemsView[str, object]: ...
|
||||
def viewkeys(self) -> KeysView[str]: ...
|
||||
def viewvalues(self) -> ValuesView[object]: ...
|
||||
def __delitem__(self, k: NoReturn) -> None: ...
|
||||
|
||||
# TypedDict is a (non-subscriptable) special form.
|
||||
TypedDict: object = ...
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
from typing import ChainMap as ChainMap
|
||||
|
||||
|
||||
Reference in New Issue
Block a user