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: Document EnumDict in docs and release notes #121720

Merged
merged 6 commits into from
Dec 19, 2024

Conversation

u2rafi
Copy link
Contributor

@u2rafi u2rafi commented Jul 13, 2024

In PR #112514 EnumDict was made public but was not documented. This patch adds the documentation.

Resolves #112328


📚 Documentation preview 📚: https://cpython-previews--121720.org.readthedocs.build/

@u2rafi u2rafi requested a review from ethanfurman as a code owner July 13, 2024 15:20
Copy link

cpython-cla-bot bot commented Jul 13, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@u2rafi u2rafi force-pushed the enumdict-docs-112328 branch from 75c1bca to d00adac Compare July 14, 2024 08:18
Doc/library/enum.rst Outdated Show resolved Hide resolved
Doc/library/enum.rst Outdated Show resolved Hide resolved
@webknjaz
Copy link
Contributor

Hey @JelleZijlstra, mind taking a look? This was made during the EuroPython sprints.

@@ -64,6 +64,10 @@ are not normal Python classes. See
Module Contents
---------------

:class:`EnumDict`

An enum class :class:`dict` that tracks order and enforces unique member names.
Copy link
Member

Choose a reason for hiding this comment

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

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

.. class:: EnumType
.. class:: EnumDict

*EnumDict* is used by *EnumType* to keep track of the enum member orders and prevent reusing the member names.
Copy link
Member

Choose a reason for hiding this comment

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

I would start by saying what it is, not what it's used for.

Ideally the documentation should also say something about when you would use this and why. I don't know why you would use it though, so I can't help with writing that explanation.

u2rafi and others added 2 commits July 16, 2024 23:37
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Comment on lines 67 to 70
:class:`EnumDict`

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

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

Comment on lines 168 to 169
*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
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

enum
----

* :class:`~enum.EnumDict` has been made public in :mod:`enum`.
Copy link
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`.

@encukou
Copy link
Member

encukou commented Aug 29, 2024

@u2rafi, do you want to address the review?
If not, I can take over this PR next week.

@encukou
Copy link
Member

encukou commented Sep 4, 2024

I'm continuing this PR in #123669.

@ethanfurman ethanfurman merged commit 39e69a7 into python:main Dec 19, 2024
25 checks passed
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Dec 23, 2024
…H-121720)

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Ethan Furman <[email protected]>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
…H-121720)

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Ethan Furman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Enum] make some private attributes public
6 participants