]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118310: Fix documentation for `enum.Enum.__new__` (GH-118311)
authorMomo Eissenhauer <mmEissen@users.noreply.github.com>
Tue, 7 May 2024 11:42:18 +0000 (13:42 +0200)
committerGitHub <noreply@github.com>
Tue, 7 May 2024 11:42:18 +0000 (13:42 +0200)
The provided example was incorrect:
- The example enum was missing the `int` mixin as implied by the context
- The value of `int('1a', 16)` was incorrectly given as 17
  (should be 26)

Doc/library/enum.rst

index 00f617e5ffc5e74f3bb849a884851097de37996f..6837b45894b3a92f015d56b6ea034216a8b18cec 100644 (file)
@@ -402,13 +402,15 @@ Data Types
       in the member assignment will be passed; e.g.
 
          >>> from enum import Enum
-         >>> class MyIntEnum(Enum):
-         ...     SEVENTEEN = '1a', 16
+         >>> class MyIntEnum(int, Enum):
+         ...     TWENTYSIX = '1a', 16
 
-      results in the call ``int('1a', 16)`` and a value of ``17`` for the member.
+      results in the call ``int('1a', 16)`` and a value of ``26`` for the member.
 
-      .. note:: When writing a custom ``__new__``, do not use ``super().__new__`` --
-                call the appropriate ``__new__`` instead.
+      .. note::
+
+         When writing a custom ``__new__``, do not use ``super().__new__`` --
+         call the appropriate ``__new__`` instead.
 
    .. method:: Enum.__repr__(self)