8000 gh-112328: Document EnumDict in docs and release notes by u2rafi · Pull Request #121720 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112328: Document EnumDict in docs and release notes #121720

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

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
Next Next commit
move entries; some rewording
  • Loading branch information
ethanfurman committed Dec 19, 2024
commit 58fbf7ba81687a7732e90f105e19957a09562009
37 changes: 16 additions & 21 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 @@ -153,32 +149,21 @@ Module Contents

Return a list of all power-of-two integers contained in a flag.

:class:`EnumDict`

A subclass of :class:`dict` for use when subclassing :class:`EnumType`.


.. versionadded:: 3.6 ``Flag``, ``IntFlag``, ``auto``
.. versionadded:: 3.11 ``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, ``member``, ``nonmember``, ``global_enum``, ``show_flag_values``
.. versionadded:: 3.14 ``EnumDict``

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

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 @@ -839,7 +824,17 @@ Data Types
>>> KeepFlag(2**2 + 2**4)
<KeepFlag.BLUE|16: 20>

.. versionadded:: 3.11
.. versionadded:: 3.11

.. class:: EnumDict

*EnumDict* is a subclass of :class:`dict` for use when subclassing :class:`EnumType`.

.. attribute:: EnumDict.member_names

Return list of member names.

.. versionadded:: 3.14

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

Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ email
enum
----

* :class:`~enum.EnumDict` has been made public in :mod:`enum`.
* :class:`~enum.EnumDict` has been made public in :mod:`enum` to better support
subclassing :class:`~enum.EnumType`.

fractions
---------
Expand Down
0