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
Prev Previous commit
update prose
  • Loading branch information
ethanfurman committed Apr 18, 2023
commit 6aed4ca8b102df137e26452ddcfb1955a3b26d52
20 changes: 5 additions & 15 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -667,21 +667,11 @@ enum
for :meth:`~object.__str__` and :meth:`~object.__format__`
(used by :func:`str`, :func:`format` and :term:`f-string`\s).

* Changed :class:`~enum.IntEnum`, :class:`~enum.IntFlag` and :class:`~enum.StrEnum`
to now inherit from :class:`~enum.ReprEnum`,
so their :func:`str` output now matches :func:`format`
(both ``str(AnIntEnum.ONE)`` and ``format(AnIntEnum.ONE)`` return ``'1'``,
whereas before ``str(AnIntEnum.ONE)`` returned ``'AnIntEnum.ONE'``.

* Changed :meth:`Enum.__format__() <enum.Enum.__format__>`
(the default for :func:`format`, :meth:`str.format` and :term:`f-string`\s)
of enums with mixed-in types (e.g. :class:`int`, :class:`str`)
to show the class name and member name in the output, instead of the member's value.
This matches the existing behavior of :meth:`enum.Enum.__str__`,
returning e.g. ``'AnEnum.MEMBER'`` for an enum ``AnEnum(str, Enum)``.
Those wishing to keep the old formatting behavior
may wish to modify their enums with mixed-in types to inherit from the appropriate
:class:`StrEnum` or :class:`IntEnum` class.
* Changed :meth:`Enum.__format__() <enum.Enum.__format__>` (the default for
:func:`format`, :meth:`str.format` and :term:`f-string`\s) to always produce
the same result as :meth:`Enum.__str__()`: for enums inheriting from
:class:`~enum.ReprEnum` it will be the member's value; for all other enums
it will be the enum and member name (e.g. ``Color.RED``).

* Added a new *boundary* class parameter to :class:`~enum.Flag` enums
and the :class:`~enum.FlagBoundary` enum with its options,
Expand Down