diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index e134d1741..dfcac9519 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -5,7 +5,6 @@ from types import CodeType, FrameType, TracebackType # Definitions of special type checking related constructs. Their definitions # are not used, so their value does not matter. -overload = object() Any = object() class TypeVar: @@ -40,6 +39,7 @@ Final: _SpecialForm = ... _F = TypeVar("_F", bound=Callable[..., Any]) def final(f: _F) -> _F: ... +def overload(f: _F) -> _F: ... Literal: _SpecialForm = ... # TypedDict is a (non-subscriptable) special form. @@ -63,11 +63,9 @@ _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: ... +def no_type_check(f: _F) -> _F: ... +def no_type_check_decorator(decorator: _F) -> _F: ... # Type aliases and type constructors @@ -492,4 +490,4 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta): def NewType(name: str, tp: Type[_T]) -> Type[_T]: ... # This itself is only available during type checking -def type_check_only(func_or_cls: _C) -> _C: ... +def type_check_only(func_or_cls: _F) -> _F: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 03336ac6e..aafb1fbdf 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -12,7 +12,6 @@ if sys.version_info >= (3, 9): # Definitions of special type checking related constructs. Their definitions # are not used, so their value does not matter. -overload = object() Any = object() class TypeVar: @@ -35,6 +34,10 @@ _promote = object() class _SpecialForm: def __getitem__(self, typeargs: Any) -> object: ... +_F = TypeVar("_F", bound=Callable[..., Any]) + +def overload(func: _F) -> _F: ... + Union: _SpecialForm = ... Optional: _SpecialForm = ... Tuple: _SpecialForm = ... @@ -46,7 +49,6 @@ Type: _SpecialForm = ... ClassVar: _SpecialForm = ... if sys.version_info >= (3, 8): Final: _SpecialForm = ... - _F = TypeVar("_F", bound=Callable[..., Any]) def final(f: _F) -> _F: ... Literal: _SpecialForm = ... # TypedDict is a (non-subscriptable) special form. @@ -94,11 +96,9 @@ _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: ... +def no_type_check(arg: _F) -> _F: ... +def no_type_check_decorator(decorator: _F) -> _F: ... # Type aliases and type constructors @@ -681,7 +681,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta): def NewType(name: str, tp: Type[_T]) -> Type[_T]: ... # This itself is only available during type checking -def type_check_only(func_or_cls: _C) -> _C: ... +def type_check_only(func_or_cls: _F) -> _F: ... if sys.version_info >= (3, 7): from types import CodeType