8000 Use dummy class to get TypeVar-like types · python/cpython@fdd8877 · GitHub
[go: up one dir, main page]

Skip to content

Commit fdd8877

Browse files
committed
Use dummy class to get TypeVar-like types
1 parent 423d2de commit fdd8877

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/typing.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,12 +1302,17 @@ def __typing_prepare_subst__(self, alias, args):
13021302

13031303
import builtins
13041304
if hasattr(builtins, "TypeVar"):
1305-
TypeVar = builtins.TypeVar
1306-
TypeVarTuple = builtins.TypeVarTuple
1307-
ParamSpec = builtins.ParamSpec
1305+
class _Dummy[T, *Ts, **P]:
1306+
type_params = (T, Ts, P)
1307+
1308+
TypeVar = type(_Dummy.type_params[0])
1309+
TypeVarTuple = type(_Dummy.type_params[1])
1310+
ParamSpec = type(_Dummy.type_params[2])
13081311
ParamSpecArgs = type(ParamSpec("P").args)
13091312
ParamSpecKwargs = type(ParamSpec("P").kwargs)
13101313

1314+
del _Dummy
1315+
13111316
import copyreg
13121317

13131318
def _pickle_psargs(psargs):

0 commit comments

Comments
 (0)
0