diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index e8fb0985c81a..45eb2e49d4c5 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -11,7 +11,6 @@ overload = object() Any = object() TypeVar = object() _promote = object() -no_type_check = object() class _SpecialForm(object): def __getitem__(self, typeargs: Any) -> object: ... @@ -36,6 +35,22 @@ class GenericMeta(type): ... # distinguish the None type from the None value. NoReturn = Union[None] +# These type variables are used by the container types. +_T = TypeVar('_T') +_S = TypeVar('_S') +_KT = TypeVar('_KT') # Key type. +_VT = TypeVar('_VT') # Value type. +_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers. +_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers. +_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers. +_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers. +_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant. +_TC = TypeVar('_TC', bound=Type[object]) +_C = TypeVar("_C", bound=Callable[..., Any]) + +no_type_check = object() +def no_type_check_decorator(decorator: _C) -> _C: ... + # Type aliases and type constructors class TypeAlias: @@ -58,19 +73,6 @@ AnyStr = TypeVar('AnyStr', str, unicode) # Abstract base classes. -# These type variables are used by the container types. -_T = TypeVar('_T') -_S = TypeVar('_S') -_KT = TypeVar('_KT') # Key type. -_VT = TypeVar('_VT') # Value type. -_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers. -_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers. -_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers. -_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers. -_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant. -_TC = TypeVar('_TC', bound=Type[object]) -_C = TypeVar("_C", bound=Callable[..., Any]) - def runtime_checkable(cls: _TC) -> _TC: ... @runtime_checkable diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 6e11f3621677..96eaeeccd1de 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -5,14 +5,13 @@ from abc import abstractmethod, ABCMeta from types import CodeType, FrameType, TracebackType import collections # Needed by aliases like DefaultDict, see mypy issue 2986 -# Definitions of special type checking related constructs. Their definition +# Definitions of special type checking related constructs. Their definitions # are not used, so their value does not matter. overload = object() Any = object() TypeVar = object() _promote = object() -no_type_check = object() class _SpecialForm: def __getitem__(self, typeargs: Any) -> Any: ... @@ -38,6 +37,22 @@ class GenericMeta(type): ... # distinguish the None type from the None value. NoReturn = Union[None] +# These type variables are used by the container types. +_T = TypeVar('_T') +_S = TypeVar('_S') +_KT = TypeVar('_KT') # Key type. +_VT = TypeVar('_VT') # Value type. +_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers. +_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers. +_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers. +_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers. +_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant. +_TC = TypeVar('_TC', bound=Type[object]) +_C = TypeVar("_C", bound=Callable[..., Any]) + +no_type_check = object() +def no_type_check_decorator(decorator: _C) -> _C: ... + # Type aliases and type constructors class TypeAlias: @@ -64,19 +79,6 @@ AnyStr = TypeVar('AnyStr', str, bytes) # Abstract base classes. -# These type variables are used by the container types. -_T = TypeVar('_T') -_S = TypeVar('_S') -_KT = TypeVar('_KT') # Key type. -_VT = TypeVar('_VT') # Value type. -_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers. -_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers. -_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers. -_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers. -_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant. -_TC = TypeVar('_TC', bound=Type[object]) -_C = TypeVar("_C", bound=Callable[..., Any]) - def runtime_checkable(cls: _TC) -> _TC: ... @runtime_checkable