Skip to content

Commit 6bde340

Browse files
authored
[Enum] add whatsnew entries (GH-95455)
1 parent ebd6601 commit 6bde340

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Doc/whatsnew/3.11.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,49 @@ datetime
471471
formats (barring only those that support fractional hours and minutes).
472472
(Contributed by Paul Ganssle in :gh:`80010`.)
473473

474+
enum
475+
----
476+
477+
* ``EnumMeta`` renamed to ``EnumType`` (``EnumMeta`` kept as alias).
478+
479+
* ``StrEnum`` added -- enum members are and must be strings.
480+
481+
* ``ReprEnum`` added -- causes only the ``__repr__`` to be modified, not the
482+
``__str__`` nor the ``__format__``.
483+
484+
* ``FlagBoundary`` added -- controls behavior when invalid values are given to
485+
a flag.
486+
487+
* ``EnumCheck`` added -- used by ``verify`` to ensure various constraints.
488+
489+
* ``verify`` added -- function to ensure given ``EnumCheck`` constraints.
490+
491+
* ``member`` added -- decorator to ensure given object is converted to an enum
492+
member.
493+
494+
* ``nonmember`` added -- decorator to ensure given object is not converted to
495+
an enum member.
496+
497+
* ``property`` added -- use instead of ``types.DynamicClassAttribute``.
498+
499+
* ``global_enum`` added -- enum decorator to adjust ``__repr__`` and ``__str__``
500+
to show members in the global context -- see ``re.RegexFlag`` for an example.
501+
502+
* ``Flag`` enhancements: members support length, iteration, and containment
503+
checks.
504+
505+
* ``Enum``/``Flag`` fixes: members are now defined before ``__init_subclass__``
506+
is called; ``dir()`` now includes methods, etc., from mixed-in data types.
507+
508+
* ``Flag`` fixes: only primary values (power of two) are considered canonical
509+
while composite values (3, 6, 10, etc.) are considered aliases; inverted
510+
flags are coerced to their positive equivalent.
511+
512+
* ``IntEnum`` / ``IntFlag`` / ``StrEnum`` fixes: these now inherit from
513+
``ReprEnum`` so the ``str()`` output now matches ``format()`` output,
514+
which is the data types' (so both ``str(AnIntEnum.ONE)`` and
515+
``format(AnIntEnum.ONE)`` is equal to ``'1'``).
516+
474517
fractions
475518
---------
476519

0 commit comments

Comments
 (0)