Visitar URL original
gh-104874: Document NewType.__supertype__ by JelleZijlstra 路 Pull Request #104875 路 python/cpython 路 GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Document NewType.__supertype__
  • Loading branch information
JelleZijlstra committed May 24, 2023
commit 6dc254f97cd88239bbdb299f5ee040c85d0481a4
8 changes: 8 additions & 0 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,14 @@ These are not used in annotations. They are building blocks for declaring types.
UserId = NewType('UserId', int)
first_user = UserId(1)

.. 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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Document the ``__name__`` and ``__supertype__`` attributes of
:class:`typing.NewType`. Patch by Jelle Zijlstra.