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-104874: Document NewType.__supertype__#104875

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AlexWaygood merged 4 commits intopython:mainfromJelleZijlstra:supernew
May 24, 2023

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commentedMay 24, 2023
edited by github-actionsbot
Loading

@JelleZijlstraJelleZijlstra added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsMay 24, 2023
@bedevere-botbedevere-bot added the docsDocumentation in the Doc dir labelMay 24, 2023
@JelleZijlstraJelleZijlstra marked this pull request as ready for reviewMay 24, 2023 16:56
Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

Looks good. We also test for__qualname__ and__module__; should we document those as well?

deftest_special_attrs(self):
self.assertEqual(UserId.__name__,'UserId')
self.assertEqual(UserId.__qualname__,'UserId')
self.assertEqual(UserId.__module__,__name__)
self.assertEqual(UserId.__supertype__,int)
UserName=self.UserName
self.assertEqual(UserName.__name__,'UserName')
self.assertEqual(UserName.__qualname__,
self.__class__.__qualname__+'.UserName')
self.assertEqual(UserName.__module__,__name__)
self.assertEqual(UserName.__supertype__,str)

@JelleZijlstra
Copy link
MemberAuthor

__qualname__ is actually wrong as implemented (it's always the same as__name__) and__module__ is mostly an implementation detail for pickling, so I'd prefer to leave those undocumented.

@AlexWaygood
Copy link
Member

__module__ is mostly an implementation detail for pickling

I feel like it could be useful to be able to know the module the newtype was defined in, and it seems useful to mention the ways in which instances ofNewType are similar to classes, even though they're not classes.

@miss-islington
Copy link
Contributor

Thanks@JelleZijlstra for the PR, and@AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 24, 2023
(cherry picked from commit41768a2)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-bot
Copy link

GH-104906 is a backport of this pull request to the3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelMay 24, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 24, 2023
(cherry picked from commit41768a2)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-bot
Copy link

GH-104907 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelMay 24, 2023
AlexWaygood pushed a commit that referenced this pull requestMay 24, 2023
gh-104874: Document NewType.__supertype__ (GH-104875)(cherry picked from commit41768a2)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
AlexWaygood pushed a commit that referenced this pull requestMay 24, 2023
gh-104874: Document NewType.__supertype__ (GH-104875)(cherry picked from commit41768a2)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@Fidget-SpinnerFidget-SpinnerAwaiting requested review from Fidget-Spinner

@AlexWaygoodAlexWaygoodAwaiting requested review from AlexWaygoodAlexWaygood is a code owner

Assignees
No one assigned
Labels
docsDocumentation in the Doc dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

DocumentNewType.__supertype__
4 participants
@JelleZijlstra@AlexWaygood@miss-islington@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp