Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
20 changes: 20 additions & 0 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ are not normal Python classes. See
Module Contents
---------------

:class:`EnumDict`

A subclass of :class:`dict` that tracks order and enforces unique member names.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is used by EnumType, but I don't think it should go first in the list, unless it is expected to be very widely used. I would suggest the end of the list as it is new? Also ensure that you update the versionadded directives at the end of the list with this new class.

:class:`EnumType`

The ``type`` for Enum and its subclasses.
Expand Down Expand Up @@ -159,6 +163,22 @@ Data Types
----------


.. class:: EnumDict

*EnumDict* is a subclass of :class:`dict` that keeps track of the order of enum members and prevents reusing member names. Use *EnumDict* when member names must be unique and their order needs to be preserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can provide an example in a code block of when using EnumDict is different from a plain dict?

Suggested change
*EnumDict* is a subclass of :class:`dict` that keeps track of the order of enum members and prevents reusing member names. Use *EnumDict* when member names must be unique and their order needs to be preserved.
*EnumDict* is a subclass of :class:`dict` that keeps track of
the order of enum members and prevents reusing member names.
Use *EnumDict* when member names must be unique
and their order needs to be preserved.
.. versionadded:: 3.14

.. attribute:: EnumDict.member_names

Return list of member names.

.. method:: EnumDict.__setitem__(self, key, value)

Set any item as an enum member that is not dundered and not a descriptor.

.. method:: EnumDict.update(self, members, **more_members)

Update the dictionary from the given iterable or dictionary members and more_members.

.. class:: EnumType
Comment thread
encukou marked this conversation as resolved.
Resolved

*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,11 @@ email
(Contributed by Thomas Dwyer and Victor Stinner for :gh:`102988` to improve
the :cve:`2023-27043` fix.)

enum
----

* :class:`~enum.EnumDict` has been made public in :mod:`enum`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's New should provide a quick overview to the casual reader. It might be useful to note that EnumDict was previously private, but I would expect that most people who know that already know what it is used for -- can we rephrase here to say that a new public type has been added that can be used in XYZ scenarios? You can also add a credit note for Ethan and a link to the GH issue (#112328).

Suggested change
* :class:`~enum.EnumDict` has been made public in :mod:`enum`.
* :class:`~enum.EnumDict` has been made public in :mod:`enum`.


fractions
---------

Expand Down