@@ -5,14 +5,13 @@ from abc import abstractmethod, ABCMeta
5
5
from types import CodeType , FrameType , TracebackType
6
6
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
7
7
8
- # Definitions of special type checking related constructs. Their definition
8
+ # Definitions of special type checking related constructs. Their definitions
9
9
# are not used, so their value does not matter.
10
10
11
11
overload = object ()
12
12
Any = object ()
13
13
TypeVar = object ()
14
14
_promote = object ()
15
- no_type_check = object ()
16
15
17
16
class _SpecialForm :
18
17
def __getitem__ (self , typeargs : Any ) -> Any : ...
@@ -38,6 +37,22 @@ class GenericMeta(type): ...
38
37
# distinguish the None type from the None value.
39
38
NoReturn = Union [None ]
40
39
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
+
41
56
# Type aliases and type constructors
42
57
43
58
class TypeAlias :
@@ -64,19 +79,6 @@ AnyStr = TypeVar('AnyStr', str, bytes)
64
79
65
80
# Abstract base classes.
66
81
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
-
80
82
def runtime_checkable (cls : _TC ) -> _TC : ...
81
83
82
84
@runtime_checkable
0 commit comments