Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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