Clarify that tuple should not be prohibited as an argument to type#2146
Clarify that tuple should not be prohibited as an argument to type#2146fangyi-zhou wants to merge 2 commits intopython:mainfrom
tuple should not be prohibited as an argument to type#2146Conversation
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`.
erictraut
left a comment
There was a problem hiding this comment.
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.
tuple should be accepted as an argument to typetuple should not be prohibited as an argument to type
|
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? |
Yes |
rchen152
left a comment
There was a problem hiding this comment.
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.
carljm
left a comment
There was a problem hiding this comment.
Agreed that is is already an improvement, even if we should also make a more comprehensive fix.
Closes #2145
This spec change reconciles the typing spec and the conformance testsuite.
tupleis an object of thetypeclass, so it should be accepted as a value oftype.