From 5a97410ddcbb9281e9af53fa9bcf44f5c9cdb6e1 Mon Sep 17 00:00:00 2001 From: Momo Eissenhauer Date: Fri, 26 Apr 2024 11:38:43 +0200 Subject: [PATCH] Fix documentation for `enum.Enum.__new__` 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) - The `.. note` tag was missing a space - Fix the indent to match other note tags --- Doc/library/enum.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst index d84d9d9b4161b1..f79cde46295097 100644 --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -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)