@@ -92,6 +92,11 @@ Module Contents
9292 the bitwise operators without losing their :class: `IntFlag ` membership.
9393 :class: `IntFlag ` members are also subclasses of :class: `int `. (`Notes `_)
9494
95+ :class: `ReprEnum `
96+
97+ Used by :class: `IntEnum `, :class: `StrEnum `, and :class: `IntFlag `
98+ to keep the :class: `str() <str> ` of the mixed-in type.
99+
95100 :class: `EnumCheck `
96101
97102 An enumeration with the values ``CONTINUOUS ``, ``NAMED_FLAGS ``, and
@@ -132,9 +137,20 @@ Module Contents
132137
133138 Do not make ``obj `` a member. Can be used as a decorator.
134139
140+ :func: `global_enum `
141+
142+ Modify the :class: `str() <str> ` and :func: `repr ` of an enum
143+ to show its members as belonging to the module instead of its class.
144+ Should only be used if the enum members will be exported to the
145+ module global namespace.
146+
147+ :func: `show_flag_values `
148+
149+ Return a list of all power-of-two integers contained in a flag.
150+
135151
136152.. versionadded :: 3.6 ``Flag``, ``IntFlag``, ``auto``
137- .. versionadded :: 3.11 ``StrEnum``, ``EnumCheck``, ``FlagBoundary``, ``property``, ``member``, ``nonmember``
153+ .. versionadded :: 3.11 ``StrEnum``, ``EnumCheck``, ``ReprEnum``, `` FlagBoundary``, ``property``, ``member``, ``nonmember``, ``global_enum``, ``show_flag_values ``
138154
139155---------------
140156
@@ -580,6 +596,20 @@ Data Types
580596 better support the *replacement of existing constants * use-case.
581597 :meth: `__format__ ` was already :func: `int.__format__ ` for that same reason.
582598
599+ .. class :: ReprEnum
600+
601+ :class: `!ReprEum ` uses the :meth: `repr() <Enum.__repr__> ` of :class: `Enum `,
602+ but the :class: `str() <str> ` of the mixed-in data type:
603+
604+ * :meth: `!int.__str__ ` for :class: `IntEnum ` and :class: `IntFlag `
605+ * :meth: `!str.__str__ ` for :class: `StrEnum `
606+
607+ Inherit from :class: `!ReprEnum ` to keep the :class: `str() <str> / :func:`format `
608+ of the mixed-in data type instead of using the
609+ :class: `Enum `-default :meth: `str() <Enum.__str__> `.
610+
611+
612+ .. versionadded :: 3.11
583613
584614.. class :: EnumCheck
585615
@@ -815,6 +845,22 @@ Utilities and Decorators
815845
816846 .. versionadded :: 3.11
817847
848+ .. decorator :: global_enum
849+
850+ A decorator to change the :class: `str() <str> ` and :func: `repr ` of an enum
851+ to show its members as belonging to the module instead of its class.
852+ Should only be used when the enum members are exported
853+ to the module global namespace (see :class: `re.RegexFlag ` for an example).
854+
855+
856+ .. versionadded :: 3.11
857+
858+ .. function :: show_flag_values(value)
859+
860+ Return a list of all power-of-two integers contained in a flag *value *.
861+
862+ .. versionadded :: 3.11
863+
818864---------------
819865
820866Notes
0 commit comments