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 5a31024 commit 379fd02Copy full SHA for 379fd02
3 files changed
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
@@ -1113,7 +1113,7 @@ def _paramspec_prepare_subst(self, alias, args):
1113
params = alias.__parameters__
1114
i = params.index(self)
1115
if i == len(args) and self.has_default():
1116
- args = [*args, self.__default__]
+ args = (*args, self.__default__)
1117
if i >= len(args):
1118
raise TypeError(f"Too few arguments for {alias}")
1119
# Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612.
Misc/NEWS.d/next/Library/2025-09-13-12-19-17.gh-issue-138859.PxjIoN.rst
@@ -0,0 +1 @@
1
+Fix generic type parameterization raising a :exc:`TypeError` when omitting a :class:`ParamSpec` that has a default which is not a list of types.
0 commit comments