KEMBAR78
Adds support for `NamedTuple` subtyping by sobolevn · Pull Request #11162 · python/mypy · GitHub
Skip to content

Conversation

sobolevn
Copy link
Member

Closes #11160

Copy link
Collaborator

@JukkaL JukkaL 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 that this is a bit questionable, since NamedTuple is not a real type, but I guess it could be useful in some cases. We can mark this as an experimental feature and see what users think about it.

Can you add a test case to pythoneval.test that uses the full stdlib stubs? Try accessing various attributes that might be useful in the test case. The new behavior depends on how NamedTuple is defined in typeshed.

Also, this would have to be documented since this is a non-standard extension.

@sobolevn
Copy link
Member Author

@JukkaL I've added both pythoneval test and docs. Thanks a lot for the review! 👍

@sobolevn
Copy link
Member Author

I need this change in my new semantic analyzer for namedtuples #11047 😞

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Sorry for the late review! A few more minor comments.

@sobolevn
Copy link
Member Author

sobolevn commented Nov 4, 2021

Done! Docs and tests are improved 👍

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks, looks good now!

@JukkaL JukkaL merged commit fbf2188 into python:master Nov 5, 2021
@sobolevn
Copy link
Member Author

sobolevn commented Nov 5, 2021

@JukkaL thank you 🎉 🎉

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arg-type error when inheriting from NamedTuple

3 participants