Skip to content

Conversation

bzoracler
Copy link

@bzoracler bzoracler commented Sep 13, 2025

…when converting type argument list to tuple
@python-cla-bot
Copy link

python-cla-bot bot commented Sep 13, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Sep 13, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Lib/typing.py Outdated
@@ -1110,6 +1110,8 @@ def _paramspec_prepare_subst(self, alias, args):
# Convert lists to tuples to help other libraries cache the results.
elif isinstance(args[i], list):
args = (*args[:i], tuple(args[i]), *args[i+1:])
else:
args = (*args[:i], args[i], *args[i + 1:])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be simplified to args = tuple(args)

@@ -0,0 +1 @@
Fix failure during parameterization of generics when a non-type-list `ParamSpec` default is followed by another type variable default, and the `ParamSpec` is not provided as a type argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use rst, not md in NEWS, so please use double backticks.

Lib/typing.py Outdated
@@ -1110,6 +1110,8 @@ def _paramspec_prepare_subst(self, alias, args):
# Convert lists to tuples to help other libraries cache the results.
elif isinstance(args[i], list):
args = (*args[:i], tuple(args[i]), *args[i+1:])
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a tuple directly on line 1103 above instead?

@@ -0,0 +1 @@
Fix failure during parameterization of generics when a non-type-list ``ParamSpec`` default is followed by another type variable default, and the ``ParamSpec`` is not provided as a type argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what "non-type-list" is. I propose this wording:

Suggested change
Fix failure during parameterization of generics when a non-type-list ``ParamSpec`` default is followed by another type variable default, and the ``ParamSpec`` is not provided as a type argument.
Fixes a :exc:`TypeError` when substituting a :class:`ParamSpec` with a default
that is followed by another :class:`TypeVar` with a default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the original description was unclear. Unless there are other objections, I'll reduce it to

Fix generic type parameterization raising a :exc:TypeError when omitting a :class:ParamSpec that has a non-type-list default.


"Non-type-list default" refers to the bug occurring if the ParamSpec default isn't a list of types, such as ... or P (another ParamSpec in scope). The bug would not be encountered if the default was a list of types (like [int, str]).

I think the closest wording for this construct in the documentation is actually "list of types" (see e.g. ParamSpec Defaults), but I don't think "list of types" is necessarily better than "type list".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's say something like "default that is not a list of types". "type list" is definitely less clear to me than "list of types".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants