Repository navigation
Document new 3.11 enum APIs (ReprEnum, global_* and/or show_flag_values) #98298
Description
Activity
- addeddocsDocumentation in the Doc dirDocumentation in the Doc dir3.11only security fixesonly security fixes
on Oct 15, 2022 Working on something now. I presume I commit to main and backport to 3.11?
Reacted by C.A.M. GerlachReacted by C.A.M. GerlachI presume I commit to main and backport to 3.11?
Yup 👍 Thanks!
- added a commit that references this issue
on Oct 21, 2022 Hey @ethanfurman , are we all done here?
@CAM-Gerlach I tihnk so.
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 classIt 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?
Reacted by C.A.M. GerlachThe behavior is intended, the docs need updating.
I have been testing the almost all the new
enumfeatures 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?
Yes, you can link PRs to this issue. Thanks!
@Bktero Closing this issue. When you have more doc updates, please open a new issue. 😄
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
As discovered in #98295 , there are several undocumented new APIs in the
enummodule:ReprEnumand is documented in What's New (and exported in__all__), but not anywhere in the enum library module documentation, which seems like an oversight.global_enumis 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_reprandglobal_flag_reprwere 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_valueswas 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