Skip to content

Adds support for NamedTuple subtyping #11162

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

Merged
merged 6 commits into from
Nov 5, 2021
Merged

Adds support for NamedTuple subtyping #11162

merged 6 commits into from
Nov 5, 2021

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 🎉 🎉

tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
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