@@ -2,12 +2,13 @@ import _typeshed
2
2
import abc
3
3
import collections
4
4
import sys
5
+ import typing
5
6
from _collections_abc import dict_items , dict_keys , dict_values
6
- from _typeshed import IdentityFunction
7
+ from _typeshed import IdentityFunction , Incomplete
7
8
from collections .abc import Iterable
8
9
from typing import ( # noqa: Y022,Y027,Y039
9
10
TYPE_CHECKING as TYPE_CHECKING ,
10
- Any ,
11
+ Any as Any ,
11
12
AsyncContextManager as AsyncContextManager ,
12
13
AsyncGenerator as AsyncGenerator ,
13
14
AsyncIterable as AsyncIterable ,
@@ -27,13 +28,13 @@ from typing import ( # noqa: Y022,Y027,Y039
27
28
Sequence ,
28
29
Text as Text ,
29
30
Type as Type ,
30
- TypeVar ,
31
31
_Alias ,
32
32
overload as overload ,
33
33
type_check_only ,
34
34
)
35
35
36
36
__all__ = [
37
+ "Any" ,
37
38
"ClassVar" ,
38
39
"Concatenate" ,
39
40
"Final" ,
@@ -43,6 +44,7 @@ __all__ = [
43
44
"ParamSpecKwargs" ,
44
45
"Self" ,
45
46
"Type" ,
47
+ "TypeVar" ,
46
48
"TypeVarTuple" ,
47
49
"Unpack" ,
48
50
"Awaitable" ,
@@ -70,6 +72,7 @@ __all__ = [
70
72
"Literal" ,
71
73
"NewType" ,
72
74
"overload" ,
75
+ "override" ,
73
76
"Protocol" ,
74
77
"reveal_type" ,
75
78
"runtime" ,
@@ -89,9 +92,9 @@ __all__ = [
89
92
"get_type_hints" ,
90
93
]
91
94
92
- _T = TypeVar ("_T" )
93
- _F = TypeVar ("_F" , bound = Callable [..., Any ])
94
- _TC = TypeVar ("_TC" , bound = Type [object ])
95
+ _T = typing . TypeVar ("_T" )
96
+ _F = typing . TypeVar ("_F" , bound = Callable [..., Any ])
97
+ _TC = typing . TypeVar ("_TC" , bound = Type [object ])
95
98
96
99
# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype
97
100
class _SpecialForm :
@@ -167,7 +170,6 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
167
170
if sys .version_info >= (3 , 10 ):
168
171
from typing import (
169
172
Concatenate as Concatenate ,
170
- ParamSpec as ParamSpec ,
171
173
ParamSpecArgs as ParamSpecArgs ,
172
174
ParamSpecKwargs as ParamSpecKwargs ,
173
175
TypeAlias as TypeAlias ,
@@ -183,18 +185,6 @@ else:
183
185
__origin__ : ParamSpec
184
186
def __init__ (self , origin : ParamSpec ) -> None : ...
185
187
186
- class ParamSpec :
187
- __name__ : str
188
- __bound__ : type [Any ] | None
189
- __covariant__ : bool
190
- __contravariant__ : bool
191
- def __init__ (
192
- self , name : str , * , bound : None | type [Any ] | str = ..., contravariant : bool = ..., covariant : bool = ...
193
- ) -> None : ...
194
- @property
195
- def args (self ) -> ParamSpecArgs : ...
196
- @property
197
- def kwargs (self ) -> ParamSpecKwargs : ...
198
188
Concatenate : _SpecialForm
199
189
TypeAlias : _SpecialForm
200
190
TypeGuard : _SpecialForm
@@ -210,7 +200,6 @@ if sys.version_info >= (3, 11):
210
200
NotRequired as NotRequired ,
211
201
Required as Required ,
212
202
Self as Self ,
213
- TypeVarTuple as TypeVarTuple ,
214
203
Unpack as Unpack ,
215
204
assert_never as assert_never ,
216
205
assert_type as assert_type ,
@@ -233,12 +222,6 @@ else:
233
222
LiteralString : _SpecialForm
234
223
Unpack : _SpecialForm
235
224
236
- @final
237
- class TypeVarTuple :
238
- __name__ : str
239
- def __init__ (self , name : str ) -> None : ...
240
- def __iter__ (self ) -> Any : ... # Unpack[Self]
241
-
242
225
def dataclass_transform (
243
226
* ,
244
227
eq_default : bool = ...,
@@ -268,3 +251,61 @@ else:
268
251
def _asdict (self ) -> collections .OrderedDict [str , Any ]: ...
269
252
270
253
def _replace (self : _typeshed .Self , ** kwargs : Any ) -> _typeshed .Self : ...
254
+
255
+ # New things in 3.xx
256
+ # The `default` parameter was added to TypeVar, ParamSpec, and TypeVarTuple (PEP 696)
257
+ # The `infer_variance` parameter was added to TypeVar (PEP 695)
258
+ # typing_extensions.override (PEP 698)
259
+ @final
260
+ class TypeVar :
261
+ __name__ : str
262
+ __bound__ : Any | None
263
+ __constraints__ : tuple [Any , ...]
264
+ __covariant__ : bool
265
+ __contravariant__ : bool
266
+ __default__ : Any | None
267
+ def __init__ (
268
+ self ,
269
+ name : str ,
270
+ * constraints : Any ,
271
+ bound : Any | None = ...,
272
+ covariant : bool = ...,
273
+ contravariant : bool = ...,
274
+ default : Any | None = ...,
275
+ infer_variance : bool = ...,
276
+ ) -> None : ...
277
+ if sys .version_info >= (3 , 10 ):
278
+ def __or__ (self , right : Any ) -> _SpecialForm : ...
279
+ def __ror__ (self , left : Any ) -> _SpecialForm : ...
280
+ if sys .version_info >= (3 , 11 ):
281
+ def __typing_subst__ (self , arg : Incomplete ) -> Incomplete : ...
282
+
283
+ @final
284
+ class ParamSpec :
285
+ __name__ : str
286
+ __bound__ : type [Any ] | None
287
+ __covariant__ : bool
288
+ __contravariant__ : bool
289
+ __default__ : type [Any ] | None
290
+ def __init__ (
291
+ self ,
292
+ name : str ,
293
+ * ,
294
+ bound : None | type [Any ] | str = ...,
295
+ contravariant : bool = ...,
296
+ covariant : bool = ...,
297
+ default : type [Any ] | str | None = ...,
298
+ ) -> None : ...
299
+ @property
300
+ def args (self ) -> ParamSpecArgs : ...
301
+ @property
302
+ def kwargs (self ) -> ParamSpecKwargs : ...
303
+
304
+ @final
305
+ class TypeVarTuple :
306
+ __name__ : str
307
+ __default__ : Any | None
308
+ def __init__ (self , name : str , * , default : Any | None = ...) -> None : ...
309
+ def __iter__ (self ) -> Any : ... # Unpack[Self]
310
+
311
+ def override (__arg : _F ) -> _F : ...
0 commit comments