Skip to content

Commit 693678b

Browse files
lunixbochsJelleZijlstra
authored andcommitted
add no_type_check_decorator stub for #2884 (#3460)
1 parent e2cf7c1 commit 693678b

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

stdlib/2/typing.pyi

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ overload = object()
1111
Any = object()
1212
TypeVar = object()
1313
_promote = object()
14-
no_type_check = object()
1514

1615
class _SpecialForm(object):
1716
def __getitem__(self, typeargs: Any) -> object: ...
@@ -36,6 +35,22 @@ class GenericMeta(type): ...
3635
# distinguish the None type from the None value.
3736
NoReturn = Union[None]
3837

38+
# These type variables are used by the container types.
39+
_T = TypeVar('_T')
40+
_S = TypeVar('_S')
41+
_KT = TypeVar('_KT') # Key type.
42+
_VT = TypeVar('_VT') # Value type.
43+
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
44+
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
45+
_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
46+
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
47+
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
48+
_TC = TypeVar('_TC', bound=Type[object])
49+
_C = TypeVar("_C", bound=Callable[..., Any])
50+
51+
no_type_check = object()
52+
def no_type_check_decorator(decorator: _C) -> _C: ...
53+
3954
# Type aliases and type constructors
4055

4156
class TypeAlias:
@@ -58,19 +73,6 @@ AnyStr = TypeVar('AnyStr', str, unicode)
5873

5974
# Abstract base classes.
6075

61-
# These type variables are used by the container types.
62-
_T = TypeVar('_T')
63-
_S = TypeVar('_S')
64-
_KT = TypeVar('_KT') # Key type.
65-
_VT = TypeVar('_VT') # Value type.
66-
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
67-
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
68-
_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
69-
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
70-
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
71-
_TC = TypeVar('_TC', bound=Type[object])
72-
_C = TypeVar("_C", bound=Callable[..., Any])
73-
7476
def runtime_checkable(cls: _TC) -> _TC: ...
7577

7678
@runtime_checkable

stdlib/3/typing.pyi

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ from abc import abstractmethod, ABCMeta
55
from types import CodeType, FrameType, TracebackType
66
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
77

8-
# Definitions of special type checking related constructs. Their definition
8+
# Definitions of special type checking related constructs. Their definitions
99
# are not used, so their value does not matter.
1010

1111
overload = object()
1212
Any = object()
1313
TypeVar = object()
1414
_promote = object()
15-
no_type_check = object()
1615

1716
class _SpecialForm:
1817
def __getitem__(self, typeargs: Any) -> Any: ...
@@ -38,6 +37,22 @@ class GenericMeta(type): ...
3837
# distinguish the None type from the None value.
3938
NoReturn = Union[None]
4039

40+
# These type variables are used by the container types.
41+
_T = TypeVar('_T')
42+
_S = TypeVar('_S')
43+
_KT = TypeVar('_KT') # Key type.
44+
_VT = TypeVar('_VT') # Value type.
45+
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
46+
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
47+
_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
48+
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
49+
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
50+
_TC = TypeVar('_TC', bound=Type[object])
51+
_C = TypeVar("_C", bound=Callable[..., Any])
52+
53+
no_type_check = object()
54+
def no_type_check_decorator(decorator: _C) -> _C: ...
55+
4156
# Type aliases and type constructors
4257

4358
class TypeAlias:
@@ -64,19 +79,6 @@ AnyStr = TypeVar('AnyStr', str, bytes)
6479

6580
# Abstract base classes.
6681

67-
# These type variables are used by the container types.
68-
_T = TypeVar('_T')
69-
_S = TypeVar('_S')
70-
_KT = TypeVar('_KT') # Key type.
71-
_VT = TypeVar('_VT') # Value type.
72-
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
73-
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
74-
_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
75-
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
76-
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
77-
_TC = TypeVar('_TC', bound=Type[object])
78-
_C = TypeVar("_C", bound=Callable[..., Any])
79-
8082
def runtime_checkable(cls: _TC) -> _TC: ...
8183

8284
@runtime_checkable

0 commit comments

Comments
 (0)