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: [Enum] Make some private attributes public. #112514

Merged
merged 6 commits into from
Dec 5, 2023

Conversation

ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Nov 29, 2023

  • _EnumDict --> EnumDict
  • EnumDict._member_names --> EnumDict.member_names
  • Enum._add_alias_
  • Enum._add_value_alias_

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

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``EnumType._add_alias_``
- ``EnumType._add_value_alias_``
@ethanfurman ethanfurman added type-feature A feature request or enhancement tests Tests in the Lib/test dir docs Documentation in the Doc dir stdlib Python modules in the Lib dir 3.13 bugs and security fixes labels Nov 29, 2023
@ethanfurman ethanfurman requested a review from sobolevn November 29, 2023 05:09
@ethanfurman ethanfurman self-assigned this Nov 29, 2023
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks for your work! The main question I have, since I am not as deep in the context of enum as you are, what is the main motivation for this? The issue does not have any details :(

- :attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a
:class:`str`, that will not be transformed into members, and will be removed
from the final class
- :attr:`~Enum._order_` -- used in Python 2/3 code to ensure member order is
Copy link
Member

Choose a reason for hiding this comment

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

I think we can drop Python2 part.

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping for now -- I'll probably change _order_ to be definitive so Enum still works on python implementations without ordered dictionaries.

Doc/library/enum.rst Show resolved Hide resolved
Doc/howto/enum.rst Outdated Show resolved Hide resolved
Lib/enum.py Outdated Show resolved Hide resolved
Lib/enum.py Outdated Show resolved Hide resolved
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Some of the syntax in enum.rst is incorrect currently:

Doc/library/enum.rst Outdated Show resolved Hide resolved
Doc/library/enum.rst Outdated Show resolved Hide resolved
Doc/library/enum.rst Outdated Show resolved Hide resolved
@bedevere-app
Copy link

bedevere-app bot commented Nov 29, 2023

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Doc/howto/enum.rst Outdated Show resolved Hide resolved
Lib/enum.py Outdated Show resolved Hide resolved
@AlexWaygood AlexWaygood dismissed their stale review November 29, 2023 15:42

Requested changes were made

@ethanfurman
Copy link
Member Author

I have made the requested changes; please review again.

I also moved the two _add_* methods from EnumType to Enum, and fixed unhashable value handling.

@ethanfurman ethanfurman merged commit de6bca9 into python:main Dec 5, 2023
24 checks passed
@ethanfurman ethanfurman deleted the enum-private_public branch December 5, 2023 16:27
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…H-112514)

* [Enum] Make some private attributes public.

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``

---------

Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Nikita Sobolev <[email protected]>
@ethanfurman ethanfurman added 3.12 bugs and security fixes needs backport to 3.12 bug and security fixes labels Apr 9, 2024
@miss-islington-app
Copy link

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @ethanfurman, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker de6bca956432cc852a4a41e2a2cee9cdacd19f35 3.12

@ethanfurman
Copy link
Member Author

Backporting because changes are needed for a bug-fix.

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…H-112514)

* [Enum] Make some private attributes public.

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``

---------

Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Nikita Sobolev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes docs Documentation in the Doc dir needs backport to 3.12 bug and security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants