Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-112328: Make EnumDict usable on its own and document it #123669

Merged
merged 13 commits into from
Dec 20, 2024
Prev Previous commit
Next Next commit
Put EnumDict docs on the buttom to de-emphasize the class
  • Loading branch information
encukou committed Sep 4, 2024
commit 05ea9bd80d2b00008ea8e9565ce2063b58951883
42 changes: 22 additions & 20 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ are not normal Python classes. See
Module Contents
---------------

:class:`EnumDict`

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

:class:`EnumType`

The ``type`` for Enum and its subclasses.
Expand Down Expand Up @@ -114,6 +110,11 @@ Module Contents
``KEEP`` which allows for more fine-grained control over how invalid values
are dealt with in an enumeration.

:class:`EnumDict`

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

:class:`auto`

Instances are replaced with an appropriate value for Enum members.
Expand Down Expand Up @@ -163,22 +164,6 @@ 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.

.. 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

*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible
Expand Down Expand Up @@ -841,6 +826,23 @@ Data Types

.. versionadded:: 3.11

.. 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.

.. 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.


---------------

Supported ``__dunder__`` names
Expand Down