Clarify Enum.__format__() change of mixed-in types in the whatsnew/3.11.rst #100387
+2
â1¤72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Hey!ð
Please correct me if I'm wrong, but the description of the change Enum.format() change in 3.11.rst doesn't seem accurate. The behavior in older Python versions was to return the member's value and not the member's key as is currently stated. Example code:
Running this on Python 3.10 prints:
And not
as the changelog states:
I noticed this because we were using the
str
mixin with all Enum classes as a hack to get to the value without needing to writeFoo.BAR.value
ð«£ The new behavior in Python 3.11 broke our code and the current phrasing in the changelog makes it feel this was just a minor bugfix. Should this change be a bit more prominent since it can be a breaking change?By the way, thank you for adding
StrEnum
, it's exactly what we needed!PS: Not sure if this needs a GitHub issue number, it's not exactly a typo, but it's still a minor change. I'm happy to open an issue if needed. Also let me know if I need to open the PR against any other branches as well.ð