Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.1k
gh-85795: Raise a clear error whensuper() is used intyping.NamedTuple subclasses#130082
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
JelleZijlstra left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Reminder to change to TypeError
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
…amedTuple` subclasses
8def43c toab6131dCompareghost commentedMar 4, 2025 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
johnslavik commentedMar 4, 2025
(Force-pushed to update the author, I have a different e-mail now) |
…d in typed namedtuples
johnslavik commentedMar 4, 2025
Let's cast the spell! ✨ I have made the requested changes; please review again. |
Thanks for making the requested changes! @JelleZijlstra: please review the changes made to this pull request. |
24956ef toe5539beCompare
ZeroIntensity left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM as well, with one documentation nitpick.
Uh oh!
There was an error while loading.Please reload this page.
293fa34 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Follow-up to conclusions fromgh-129352,closesgh-85795.
In#129352 (comment),@rhettinger and I agreed that a clear error message is needed when a user attempts to use
super()intyping.NamedTuplesubclasses.I believe this PR should be backported.Since we no longer raise aRuntimeError, this cannot be backported.About the PR
Pure presence of
__classcell__is enough to confirm that__class__closure was created to enablesuper()calls.Tests for cases where
__classcell__are manually set in typed named tuples were intentionallynot added, as I don't see the value in considering these behaviors.Interestingly, I used a note admonition instead ofNo longer true, we raise.. versionchanged:: nextin the docs and it's completely backward-compatible: it applies to all relevant previous versions of Python. I considered making an "important" block instead, but I thinksuper()is not often enough to support that idea.TypeErrorinstead ofRuntimeErrorCC previous reviewers:@ZeroIntensity@AlexWaygood@JelleZijlstra@rhettinger
📚 Documentation preview 📚:https://cpython-previews--130082.org.readthedocs.build/