-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-40066: [Enum] update str() and format() output #30582
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
Conversation
|
Omg, did not mean to close that at all — sorry!! |
sobolevn
left a comment
There was a problem hiding this 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! 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 |
| """Marker object for Signature.empty and Parameter.empty.""" | ||
|
|
||
|
|
||
| class _ParameterKind(enum.IntEnum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that inheritting correct where the values are changed to str?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is removing "{0}" proper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gryznar Only because it was changed to %s later.
https://bugs.python.org/issue40066