Skip to content

Clarify that tuple should not be prohibited as an argument to type#2146

Merged
carljm merged 2 commits intopython:mainfrom
fangyi-zhou:type-allows-tuple
Feb 13, 2026
Merged

Clarify that tuple should not be prohibited as an argument to type#2146
carljm merged 2 commits intopython:mainfrom
fangyi-zhou:type-allows-tuple

Conversation

@fangyi-zhou
Copy link
Contributor

Closes #2145

This spec change reconciles the typing spec and the conformance testsuite. tuple is an object of the type class, so it should be accepted as a value of type.

Closes python#2145

This spec change reconciles the typing spec and the conformance
testsuite. `tuple` is an object of the `type` class, so it should be
accepted as a value of `type`.
@srittau srittau added Typing Council decision Needs to be approved by the Typing Council. Do not merge until approved. topic: typing spec For improving the typing spec labels Jan 7, 2026
Copy link
Collaborator

@erictraut erictraut left a comment

Choose a reason for hiding this comment

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

I don't think the new wording should mention tuple at all. It's not a special form. It's simply a class.

The problem here is the phrase special constructs, which is not defined anywhere in the spec and is therefore ambiguous. I think we should change this to special form, which is defined in the glossary.

@fangyi-zhou fangyi-zhou changed the title Clarify that tuple should be accepted as an argument to type Clarify that tuple should not be prohibited as an argument to type Jan 7, 2026
Copy link
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Updated wording here LGTM.

@encukou
Copy link
Member

encukou commented Jan 8, 2026

Maybe add an extra sentence now?

Tuples, for example ``type[A, B]``, are also not allowed.

@erictraut
Copy link
Collaborator

Maybe add an extra sentence now?

No, this is already covered elsewhere in the spec. We try to avoid redundancies because they create confusion and potential inconsistencies.

@fangyi-zhou
Copy link
Contributor Author

Maybe add an extra sentence now?

No, this is already covered elsewhere in the spec. We try to avoid redundancies because they create confusion and potential inconsistencies.

@erictraut Do you mean this is covered in the grammar in https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions?

@erictraut
Copy link
Collaborator

Do you mean this is covered in the grammar

Yes

Copy link
Collaborator

@rchen152 rchen152 left a comment

Choose a reason for hiding this comment

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

I agree with Jelle and Eric's points at https://discuss.python.org/t/spec-change-clarify-that-tuple-should-not-be-prohibited-as-an-argument-to-type/105590 that this section is in need of a broader fix, but this change as-is is already an improvement (removes the obviously incorrect statement that type[tuple] is not allowed and the ambiguous term "special constructs"), so I'm in favor of accepting it.

Copy link
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Agreed that is is already an improvement, even if we should also make a more comprehensive fix.

@fangyi-zhou
Copy link
Contributor Author

Are we happy to merge the current change as is? Or we would want to take this opportunity to improve upon it more?

@carljm
Copy link
Member

carljm commented Feb 13, 2026

I am happy to merge this as-is and consider broader improvements separately, but I would like more than two typing council members to approve before I merge it.

@erictraut
Copy link
Collaborator

I'm good with this change.

@carljm carljm merged commit 6112382 into python:main Feb 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: typing spec For improving the typing spec Typing Council decision Needs to be approved by the Typing Council. Do not merge until approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is tuple allowed as an argument to type?

6 participants