Repository navigation
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
Changes from 4 commits
d00adac
3bff0b9
11e2fd1
e8c368e
58fbf7b
aee56d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||||||||||||||
|
|
||||||||||||||||||
| :class:`EnumType` | ||||||||||||||||||
|
|
||||||||||||||||||
| The ``type`` for Enum and its subclasses. | ||||||||||||||||||
|
|
@@ -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. | ||||||||||||||||||
|
|
||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||
| .. 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 | ||||||||||||||||||
|
encukou marked this conversation as resolved.
Resolved
|
||||||||||||||||||
|
|
||||||||||||||||||
| *EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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`. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||
|
|
||||||
| fractions | ||||||
| --------- | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
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 theversionaddeddirectives at the end of the list with this new class.