Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Whatsnew: Convert literals in enum section to actual x-references
  • Loading branch information
CAM-Gerlach committed Oct 15, 2022
commit 2e15caa298e223531b2e3658fc19116bbd4f3ac2
61 changes: 37 additions & 24 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -619,46 +619,59 @@ datetime
formats (barring only those that support fractional hours and minutes).
(Contributed by Paul Ganssle in :gh:`80010`.)


.. _whatsnew311-enum:

enum
----

* ``EnumMeta`` renamed to ``EnumType`` (``EnumMeta`` kept as alias).
* :class:`!EnumMeta` renamed to :class:`~enum.EnumType`
(:class:`!EnumMeta` kept as alias).

* ``StrEnum`` added -- enum members are and must be strings.
* :class:`~enum.StrEnum` added -- enum members are and must be strings.

* ``ReprEnum`` added -- causes only the ``__repr__`` to be modified, not the
``__str__`` nor the ``__format__``.
* :class:`~enum.ReprEnum` added --
causes only the :meth:`~object.__repr__` to be modified,
not the :meth:`~object.__str__` nor the :meth:`~object.__format__`.

* ``FlagBoundary`` added -- controls behavior when invalid values are given to
a flag.
* :class:`~enum.FlagBoundary` added --
controls behavior when invalid values are given to a flag.

* ``EnumCheck`` added -- used by ``verify`` to ensure various constraints.
* :class:`~enum.EnumCheck` added --
used by :func:`~enum.verify` to ensure various constraints.

* ``verify`` added -- function to ensure given ``EnumCheck`` constraints.
* :func:`~enum.verify` added --
function to ensure given :class:`~enum.EnumCheck` constraints.

* ``member`` added -- decorator to ensure given object is converted to an enum
member.
* :func:`~enum.member` added --
decorator to ensure given object is converted to an enum member.

* ``nonmember`` added -- decorator to ensure given object is not converted to
an enum member.
* :func:`~enum.nonmember` added --
decorator to ensure given object is not converted to an enum member.

* ``property`` added -- use instead of ``types.DynamicClassAttribute``.
* :func:`~enum.property` added --
use instead of :func:`types.DynamicClassAttribute`.

* ``global_enum`` added -- enum decorator to adjust ``__repr__`` and ``__str__``
to show members in the global context -- see ``re.RegexFlag`` for an example.
* :func:`~enum.global_enum` added --
enum decorator to adjust :meth:`~object.__repr__` and :meth:`~object.__str__`
to show members in the global context.
See :class:`re.RegexFlag` for an example.

* ``Flag`` enhancements: members support length, iteration, and containment
checks.
* :class:`~enum.Flag` enhancements:
members support length, iteration, and containment checks.

* ``Enum``/``Flag`` fixes: members are now defined before ``__init_subclass__``
is called; ``dir()`` now includes methods, etc., from mixed-in data types.
* :class:`~enum.Enum`/:class:`~enum.Flag` fixes:
members are now defined before :meth:`~object.__init_subclass__` is called;
:func:`dir` now includes methods, etc., from mixed-in data types.

* ``Flag`` fixes: only primary values (power of two) are considered canonical
while composite values (3, 6, 10, etc.) are considered aliases; inverted
flags are coerced to their positive equivalent.
* :class:`~enum.Flag` fixes:
only primary values (power of two) are considered canonical
while composite values (3, 6, 10, etc.) are considered aliases;
inverted flags are coerced to their positive equivalent.

* ``IntEnum`` / ``IntFlag`` / ``StrEnum`` fixes: these now inherit from
``ReprEnum`` so the ``str()`` output now matches ``format()`` output,
* :class:`~enum.IntEnum` / :class:`~enum.IntFlag` / :class:`~enum.StrEnum` fixes:
these now inherit from :class:`~enum.ReprEnum`
so the :func:`str` output now matches :func:`format` output,
which is the data types' (so both ``str(AnIntEnum.ONE)`` and
``format(AnIntEnum.ONE)`` is equal to ``'1'``).

Expand Down