Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-85795: Raise a clear error whensuper() is used intyping.NamedTuple subclasses#130082

Merged
JelleZijlstra merged 3 commits intopython:mainfrom
johnslavik:eligible-classcell-error-message
Mar 6, 2025
Merged

gh-85795: Raise a clear error whensuper() is used intyping.NamedTuple subclasses#130082
JelleZijlstra merged 3 commits intopython:mainfrom
johnslavik:eligible-classcell-error-message

Conversation

@johnslavik
Copy link
Member

@johnslavikjohnslavik commentedFeb 13, 2025
edited
Loading

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 usesuper() intyping.NamedTuple subclasses.

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 of.. versionchanged:: next in 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. No longer true, we raiseTypeError instead ofRuntimeError

CC previous reviewers:@ZeroIntensity@AlexWaygood@JelleZijlstra@rhettinger


📚 Documentation preview 📚:https://cpython-previews--130082.org.readthedocs.build/

Copy link
Member

@JelleZijlstraJelleZijlstra left a 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

johnslavik reacted with thumbs up emoji
@bedevere-app
Copy link

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 phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@johnslavikjohnslavikforce-pushed theeligible-classcell-error-message branch from8def43c toab6131dCompareMarch 4, 2025 07:01
@ghost
Copy link

ghost commentedMar 4, 2025
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@johnslavik
Copy link
MemberAuthor

(Force-pushed to update the author, I have a different e-mail now)

@johnslavik
Copy link
MemberAuthor

Let's cast the spell! ✨

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@JelleZijlstra: please review the changes made to this pull request.

@johnslavikjohnslavikforce-pushed theeligible-classcell-error-message branch from24956ef toe5539beCompareMarch 4, 2025 07:14
Copy link
Member

@ZeroIntensityZeroIntensity left a 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.

@JelleZijlstraJelleZijlstra merged commit293fa34 intopython:mainMar 6, 2025
43 of 46 checks passed
@johnslavikjohnslavik deleted the eligible-classcell-error-message branchApril 28, 2025 20:38
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

@ZeroIntensityZeroIntensityZeroIntensity approved these changes

@AlexWaygoodAlexWaygoodAwaiting requested review from AlexWaygoodAlexWaygood is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

__class__ not set in typing.NamedTuple

3 participants

@johnslavik@JelleZijlstra@ZeroIntensity

Comments


[8]ページ先頭

©2009-2026 Movatter.jp