Skip to content

Commit bd10d8a

Browse files
srittaugvanrossum
authored andcommitted
Add @typing.type_check_only (#2679)
Cf. python/typing#597
1 parent 4230e6f commit bd10d8a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

stdlib/2/typing.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ _KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
6363
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
6464
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
6565
_TC = TypeVar('_TC', bound=Type[object])
66+
_C = TypeVar("_C", bound=Callable)
6667

6768
def runtime(cls: _TC) -> _TC: ...
6869

@@ -462,3 +463,6 @@ class NamedTuple(tuple):
462463
def _replace(self: _T, **kwargs: Any) -> _T: ...
463464

464465
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
466+
467+
# This itself is only available during type checking
468+
def type_check_only(func_or_cls: _C) -> _C: ...

stdlib/3/typing.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ _KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
6565
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
6666
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
6767
_TC = TypeVar('_TC', bound=Type[object])
68+
_C = TypeVar("_C", bound=Callable)
6869

6970
def runtime(cls: _TC) -> _TC: ...
7071

@@ -585,3 +586,6 @@ class NamedTuple(tuple):
585586
def _replace(self: _T, **kwargs: Any) -> _T: ...
586587

587588
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
589+
590+
# This itself is only available during type checking
591+
def type_check_only(func_or_cls: _C) -> _C: ...

0 commit comments

Comments
 (0)