-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-104874: Document NewType.__supertype__ #104875
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 in c90a862
def test_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 |
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 commit 41768a2) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-104906 is a backport of this pull request to the 3.12 branch. |
(cherry picked from commit 41768a2) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-104907 is a backport of this pull request to the 3.11 branch. |
Fixes #104874
NewType.__supertype__
#104874📚 Documentation preview 📚: https://cpython-previews--104875.org.readthedocs.build/