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

Document new 3.11 enum APIs (ReprEnum, global_* and/or show_flag_values) #98298

Closed
CAM-Gerlach opened this issue Oct 15, 2022 · 9 comments
Closed
Assignees
Labels
3.11 only security fixes docs Documentation in the Doc dir

Comments

@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Oct 15, 2022

As discovered in #98295 , there are several undocumented new APIs in the enum module:

  • ReprEnum and is documented in What's New (and exported in __all__), but not anywhere in the enum library module documentation, which seems like an oversight.
  • Likewise, global_enum is documented in What's New (and exported in __all__) and was previously documented in the library docs, but that documentation was reverted in bpo-40066: Revert "Revert "bpo-40066: [Enum] update str() and format() output..." #30637 , and not restored, so I'm unsure on the current status.
  • global_str, global_enum_repr and global_flag_repr were added (to replace the __str__() and __repr__() of the appropriate classes) and are not marked as private (_) and are exported by __all__, but aren't documented either. Should they be?
  • show_flag_values was added and is not in __all__, but its use is referred to in an error message (cited in the docs) and it is not marked private (_). Should this be documented as well?

@ethanfurman your guidance here would be much appreciated, thanks. I'm happy to review/copyedit a PR, or if you prefer, I can draft something and you review it. Ideally, we should get this in before the 3.11 release in a week or so...

Related: #95913

Linked PRs

@CAM-Gerlach CAM-Gerlach added docs Documentation in the Doc dir 3.11 only security fixes labels Oct 15, 2022
@ethanfurman
Copy link
Member

Working on something now. I presume I commit to main and backport to 3.11?

@CAM-Gerlach
Copy link
Member Author

CAM-Gerlach commented Oct 19, 2022

I presume I commit to main and backport to 3.11?

Yup 👍 Thanks!

ethanfurman added a commit that referenced this issue Oct 21, 2022
…GH-98455)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 21, 2022
…values (pythonGH-98455)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 3e95ffc)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
miss-islington added a commit that referenced this issue Oct 21, 2022
…GH-98455)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 3e95ffc)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@CAM-Gerlach
Copy link
Member Author

Hey @ethanfurman , are we all done here?

@ethanfurman
Copy link
Member

@CAM-Gerlach I tihnk so.

@Bktero
Copy link

Bktero commented Jan 12, 2023

Hi!

Inthe documentation, we can read (3.11.1) :

@enum.global_enum
A decorator to change the str() and repr() of an enum to show its members as belonging to the module instead of its class

It is not said that members of the enum are also added to the global namespace. Example:

from enum import global_enum, Enum

@global_enum
class Foo(Enum):
    BAR = 1

print(BAR) # the documentation doesn't tell that this is possible

Is this behavior a bug? Or is there something missing in the documentation?

@ethanfurman ethanfurman reopened this Jan 12, 2023
@ethanfurman
Copy link
Member

The behavior is intended, the docs need updating.

@Bktero
Copy link

Bktero commented Jan 13, 2023

I have been testing the almost all the new enum features yesterday, and I have other points for improving the documentation.

Should I create a new issue or is there an existing issue I can contribute to? EDIT: this current issue is not closed, so I can add stuff here, right?

@ethanfurman
Copy link
Member

Yes, you can link PRs to this issue. Thanks!

ethanfurman added a commit that referenced this issue Apr 3, 2023
fix FlagBoundary statements
add warning about reloading modules and enum identity
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 3, 2023
fix FlagBoundary statements
add warning about reloading modules and enum identity
(cherry picked from commit 5ffc1e5)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
miss-islington added a commit that referenced this issue Apr 3, 2023
fix FlagBoundary statements
add warning about reloading modules and enum identity
(cherry picked from commit 5ffc1e5)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@ethanfurman
Copy link
Member

@Bktero Closing this issue. When you have more doc updates, please open a new issue. 😄

gaogaotiantian pushed a commit to gaogaotiantian/cpython that referenced this issue Apr 8, 2023
fix FlagBoundary statements
add warning about reloading modules and enum identity
warsaw pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
fix FlagBoundary statements
add warning about reloading modules and enum identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants