@@ -819,17 +819,20 @@ Some rules:
819
819
1. When subclassing :class: `Enum `, mix-in types must appear before
820
820
:class: `Enum ` itself in the sequence of bases, as in the :class: `IntEnum `
821
821
example above.
822
- 2. While :class: `Enum ` can have members of any type, once you mix in an
822
+ 2. Mix-in types must be subclassable. For example,
823
+ :class: `bool ` and :class: `range ` are not subclassable
824
+ and will throw an error during Enum creation if used as the mix-in type.
825
+ 3. While :class: `Enum ` can have members of any type, once you mix in an
823
826
additional type, all the members must have values of that type, e.g.
824
827
:class: `int ` above. This restriction does not apply to mix-ins which only
825
828
add methods and don't specify another type.
826
- 3 . When another data type is mixed in, the :attr: `value ` attribute is *not the
829
+ 4 . When another data type is mixed in, the :attr: `value ` attribute is *not the
827
830
same * as the enum member itself, although it is equivalent and will compare
828
831
equal.
829
- 4 . %-style formatting: `%s ` and `%r ` call the :class: `Enum ` class's
832
+ 5 . %-style formatting: `%s ` and `%r ` call the :class: `Enum ` class's
830
833
:meth: `__str__ ` and :meth: `__repr__ ` respectively; other codes (such as
831
834
`%i ` or `%h ` for IntEnum) treat the enum member as its mixed-in type.
832
- 5 . :ref: `Formatted string literals <f-strings >`, :meth: `str.format `,
835
+ 6 . :ref: `Formatted string literals <f-strings >`, :meth: `str.format `,
833
836
and :func: `format ` will use the mixed-in type's :meth: `__format__ `
834
837
unless :meth: `__str__ ` or :meth: `__format__ ` is overridden in the subclass,
835
838
in which case the overridden methods or :class: `Enum ` methods will be used.
0 commit comments