Skip to content

Adds support for NamedTuple subtyping - #11162

Merged
JukkaL merged 6 commits into
python:masterfrom
sobolevn:issue-11160
Nov 5, 2021
Merged

JukkaL merged 6 commits into
python:masterfrom
sobolevn:issue-11160

Conversation

@sobolevn

Copy link
Copy Markdown
Member

Closes #11160

Comment thread test-data/unit/check-namedtuple.test Outdated

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Member Author

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

@sobolevn

Copy link
Copy Markdown
Member Author

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

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread docs/source/kinds_of_types.rst
Comment thread test-data/unit/check-namedtuple.test
@sobolevn

sobolevn commented Nov 4, 2021

Copy link
Copy Markdown
Member Author

Done! Docs and tests are improved 👍

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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

sobolevn commented Nov 5, 2021

Copy link
Copy Markdown
Member Author

@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