Add @typing.type_check_only (#2679)

Cf. python/typing#597
This commit is contained in:
Sebastian Rittau
2019-04-13 00:32:22 +02:00
committed by Guido van Rossum
parent 4230e6f313
commit bd10d8aad4
2 changed files with 8 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ _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)
def runtime(cls: _TC) -> _TC: ...
@@ -462,3 +463,6 @@ class NamedTuple(tuple):
def _replace(self: _T, **kwargs: Any) -> _T: ...
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: ...

View File

@@ -65,6 +65,7 @@ _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)
def runtime(cls: _TC) -> _TC: ...
@@ -585,3 +586,6 @@ class NamedTuple(tuple):
def _replace(self: _T, **kwargs: Any) -> _T: ...
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: ...