FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40066: [Enum] update str() and format() output by ethanfurman · Pull Request #30582 · python/cpython · GitHub

/ cpython Public

bpo-40066: [Enum] update str() and format() output - #30582

Merged
ethanfurman merged 26 commits into
python:mainfrom
ethanfurman:40066-enum_output
Jan 16, 2022
Merged

bpo-40066: [Enum] update str() and format() output#30582
ethanfurman merged 26 commits into
python:mainfrom
ethanfurman:40066-enum_output

Conversation

ethanfurman commented Jan 13, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

Omg, did not mean to close that at all — sorry!!

sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for your work! Enums' text representation looks way better now.

Comment thread Doc/library/enum.rst Outdated
Comment thread Doc/library/enum.rst Outdated
Comment thread Doc/library/enum.rst Outdated
Comment thread Doc/library/enum.rst Outdated
Comment thread Lib/enum.py Outdated
Comment thread Lib/enum.py Outdated
Comment thread Lib/enum.py Outdated
Comment thread Lib/enum.py Outdated
Comment thread Lib/enum.py Outdated
ethanfurman merged commit acf7403 into python:main Jan 16, 2022

Copy link
Copy Markdown
Member

This change appears to be causing CI to fail on docs for unrelated PRs ☹️ https://github.com/python/cpython/runs/4831439882?check_suite_focus=true

Copy link
Copy Markdown
Contributor

I'm curious: why does this define a __init__ for Enum which does nothing at all (just pass)?

It causes pylint to start throwing warnings about subclasses of Enum which have their own __init__ not calling super's __init__, which Python's own docs and examples don't say they should, and which of course would be pointless since it does nothing. I'm sending a PR for pylint to not emit this warning for subclasses of Enum, but I don't understand why the do-nothing __init__ was added at all.

Comment thread Lib/inspect.py
@@ -2567,30 +2567,28 @@ class _empty:


class _ParameterKind(enum.IntEnum):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is that inheritting correct where the values are changed to str?

ethanfurman Nov 25, 2022
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@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.

Comment thread Lib/enum.py
if invalid_names:
raise ValueError('Invalid enum member name: {0}'.format(
','.join(invalid_names)))
raise ValueError('invalid enum member name(s) '.format(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is removing "{0}" proper?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@gryznar Only because it was changed to %s later.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL