Skip to content

gh-92107: Add tests that subscription works on arbitrary named tuple …#92304

Merged
serhiy-storchaka merged 1 commit intopython:mainfrom
serhiy-storchaka:namedtuple-non-generic-subscript
May 4, 2022
Merged

gh-92107: Add tests that subscription works on arbitrary named tuple …#92304
serhiy-storchaka merged 1 commit intopython:mainfrom
serhiy-storchaka:namedtuple-non-generic-subscript

Conversation

@serhiy-storchaka
Copy link
Member

…types

#92107

@vrodou

This comment was marked as spam.

@serhiy-storchaka
Copy link
Member Author

I still think that we should disallow this in some future versions.

@AlexWaygood
Copy link
Member

AlexWaygood commented May 4, 2022

I still think that we should disallow this in some future versions.

I agree that the current behaviour doesn't make any kind of "sense". Personally, I would be happy to disallow this behaviour if:

  1. We're happy to start adding __class_getitem__ to stdlib collections.namedtuples if typeshed types them as generic typing.NamedTuples. (This is currently unnecessary, since they inherit __class_getitem__ from tuple, but it would be necessary if we made the change you suggest.)
  2. We're happy to start backporting PRs that add __class_getitem__ to stdlib classes. Historically we've treated these as enhancements, and haven't backported them. I understand the rationale for that policy. But it means that it generally takes years before users can stop doing ugly if TYPE_CHECKING blocks of code to work around discrepancies between the runtime and the stubs.

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

Labels

skip news tests Tests in the Lib/test dir topic-typing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants