bpo-40066: [Enum] update str() and format() output#30582
bpo-40066: [Enum] update str() and format() output#30582ethanfurman merged 26 commits intopython:mainfrom
Conversation
|
Omg, did not mean to close that at all — sorry!! |
sobolevn
left a comment
There was a problem hiding this comment.
Thanks for your work! Enums' text representation looks way better now.
4da9925 to
d36aeda
Compare
|
This change appears to be causing CI to fail on docs for unrelated PRs |
…ythonGH-30582)" (pythonGH-30632)" This reverts commit 42a64c0.
|
I'm curious: why does this define a It causes pylint to start throwing warnings about subclasses of Enum which have their own |
| @@ -2567,30 +2567,28 @@ class _empty: | |||
|
|
|||
|
|
|||
| class _ParameterKind(enum.IntEnum): | |||
There was a problem hiding this comment.
Is that inheritting correct where the values are changed to str?
There was a problem hiding this comment.
@gryznar Good question: only because the __new__ uses integers as the values, and the "value" on the assignment line is saved in the description attribute. Without the custom __new__ the enum creation would have failed, since strings are not integers.
| if invalid_names: | ||
| raise ValueError('Invalid enum member name: {0}'.format( | ||
| ','.join(invalid_names))) | ||
| raise ValueError('invalid enum member name(s) '.format( |
There was a problem hiding this comment.
@gryznar Only because it was changed to %s later.
https://bugs.python.org/issue40066