File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -430,6 +430,19 @@ Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__` then
430430any value(s) given to the enum member will be passed into those methods.
431431See `Planet `_ for an example.
432432
433+ .. note ::
434+
435+ The :meth: `__new__ ` method, if defined, is used during creation of the Enum
436+ members; it is then replaced by Enum's :meth: `__new__ ` which is used after
437+ class creation for lookup of existing members.
438+
439+ .. warning ::
440+
441+ *Do not * call ``super().__new__() ``, as the lookup-only ``__new__ `` is the one
442+ that is found; instead, use the data type directly -- e.g.::
443+
444+ obj = int.__new__(cls, value)
445+
433446
434447Restricted Enum subclassing
435448---------------------------
@@ -927,6 +940,11 @@ want one of them to be the value::
927940 >>> print(Coordinate(3))
928941 Coordinate.VY
929942
943+ .. warning ::
944+
945+ *Do not * call ``super().__new__() ``, as the lookup-only ``__new__ `` is the one
946+ that is found; instead, use the data type directly.
947+
930948
931949Finer Points
932950^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments