We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ParamSpec
1 parent 3a81313 commit 22235b4Copy full SHA for 22235b4
Lib/test/test_typing.py
@@ -762,6 +762,16 @@ class A(Generic[T, P, U]): ...
762
self.assertEqual(A[float, [range]].__args__, (float, (range,), float))
763
self.assertEqual(A[float, [range], int].__args__, (float, (range,), int))
764
765
+ def test_paramspec_and_typevar_specialization_2(self):
766
+ T = TypeVar("T")
767
+ P = ParamSpec('P', default=...)
768
+ U = TypeVar("U", default=float)
769
+ self.assertEqual(P.__default__, ...)
770
+ class A(Generic[T, P, U]): ...
771
+ self.assertEqual(A[float].__args__, (float, ..., float))
772
+ self.assertEqual(A[float, [range]].__args__, (float, (range,), float))
773
+ self.assertEqual(A[float, [range], int].__args__, (float, (range,), int))
774
+
775
def test_typevartuple_none(self):
776
U = TypeVarTuple('U')
777
U_None = TypeVarTuple('U_None', default=None)
Lib/typing.py
@@ -1123,6 +1123,8 @@ def _paramspec_prepare_subst(self, alias, args):
1123
# Convert lists to tuples to help other libraries cache the results.
1124
elif isinstance(args[i], list):
1125
args = (*args[:i], tuple(args[i]), *args[i+1:])
1126
+ else:
1127
+ args = (*args[:i], args[i], *args[i + 1:])
1128
return args
1129
1130
0 commit comments