diff --git a/third_party/2and3/mypy_extensions.pyi b/third_party/2and3/mypy_extensions.pyi index 05400c8c7..1c5b46b9c 100644 --- a/third_party/2and3/mypy_extensions.pyi +++ b/third_party/2and3/mypy_extensions.pyi @@ -1,8 +1,28 @@ -from typing import Dict, Type, TypeVar, Optional, Union, Any, Generic +import abc +import sys +from typing import ( + Dict, Type, TypeVar, Optional, Union, Any, Generic, Mapping, ItemsView, KeysView, ValuesView +) _T = TypeVar('_T') _U = TypeVar('_U') +# 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) -> bool: ... + def viewitems(self) -> ItemsView[str, object]: ... + def viewkeys(self) -> KeysView[str]: ... + def viewvalues(self) -> ValuesView[object]: ... + def __delitem__(self, k: NoReturn) -> None: ... + def TypedDict(typename: str, fields: Dict[str, Type[_T]], total: bool = ...) -> Type[dict]: ... def Arg(type: _T = ..., name: Optional[str] = ...) -> _T: ...