Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Looks good. We also test for__qualname__
and__module__
; should we document those as well?
cpython/Lib/test/test_typing.py
Lines 6658 to 6669 inc90a862
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) |
|
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 of |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Thanks@JelleZijlstra for the PR, and@AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
(cherry picked from commit41768a2)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
bedevere-bot commentedMay 24, 2023
GH-104906 is a backport of this pull request to the3.12 branch. |
(cherry picked from commit41768a2)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
bedevere-bot commentedMay 24, 2023
GH-104907 is a backport of this pull request to the3.11 branch. |
Uh oh!
There was an error while loading.Please reload this page.
Fixes#104874
NewType.__supertype__
#104874📚 Documentation preview 📚:https://cpython-previews--104875.org.readthedocs.build/