[Python-checkins] [3.12] gh-104874: Document NewType.__supertype__ (GH-104875) (#104906)
AlexWaygood
webhook-mailer at python.org
Wed May 24 19:33:59 EDT 2023
https://github.com/python/cpython/commit/a06423388618424e2c6dab2ab503fdca5a953e38
commit: a06423388618424e2c6dab2ab503fdca5a953e38
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: AlexWaygood <Alex.Waygood at Gmail.com>
date: 2023-05-25T00:33:52+01:00
summary:
[3.12] gh-104874: Document NewType.__supertype__ (GH-104875) (#104906)
gh-104874: Document NewType.__supertype__ (GH-104875)
(cherry picked from commit 41768a2bd3a8f57e6ce4e4ae9cab083b69817ec1)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra at gmail.com>
files:
A Misc/NEWS.d/next/Library/2023-05-24-09-34-23.gh-issue-104874.oqyJSy.rst
M Doc/library/typing.rst
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index c90cb411acde0..cd4df61c5ac3a 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -1648,6 +1648,18 @@ These are not used in annotations. They are building blocks for declaring types.
UserId = NewType('UserId', int)
first_user = UserId(1)
+ .. attribute:: __module__
+
+ The module in which the new type is defined.
+
+ .. attribute:: __name__
+
+ The name of the new type.
+
+ .. attribute:: __supertype__
+
+ The type that the new type is based on.
+
.. versionadded:: 3.5.2
.. versionchanged:: 3.10
diff --git a/Misc/NEWS.d/next/Library/2023-05-24-09-34-23.gh-issue-104874.oqyJSy.rst b/Misc/NEWS.d/next/Library/2023-05-24-09-34-23.gh-issue-104874.oqyJSy.rst
new file mode 100644
index 0000000000000..9d5904bc14642
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-05-24-09-34-23.gh-issue-104874.oqyJSy.rst
@@ -0,0 +1,2 @@
+Document the ``__name__`` and ``__supertype__`` attributes of
+:class:`typing.NewType`. Patch by Jelle Zijlstra.
More information about the Python-checkins
mailing list