Skip to content

bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__#14545

Merged
ethanfurman merged 7 commits into
python:masterfrom
jason-curtis:fix-issue-37479
Jul 4, 2019
Merged

bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__#14545
ethanfurman merged 7 commits into
python:masterfrom
jason-curtis:fix-issue-37479

Conversation

@jason-curtis

@jason-curtis jason-curtis commented Jul 2, 2019

Copy link
Copy Markdown

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

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

In addition to the test you have, I'd like to see some tests with classes that define format, and with format and str.

@jason-curtis

Copy link
Copy Markdown
Author

Test coverage is now something like:

overrides __str__ overrides __format__ mixin/"pure" Enum asserts str asserts format test name
y n pure y y test_str_override_enum (new)
n y pure y y test_format_override_enum (new)
y y pure y y test_str_and_format_override_enum (new)
y n mixin y y test_str_override_mixin (new)
y y mixin y y test_str_and_format_override_mixin (new)
n y mixin y (new) y test_format_override_mixin (renamed)
n n mixin n y test_format_enum_date etc
n n mixin y n test_multiple_mixin
y n pure y n TestFlag.test_str

@ethanfurman ethanfurman self-assigned this Jul 3, 2019

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

Just a couple changes needed.

Also, please add yourself to the ACKS file.

Thank you for working on this!

Comment thread Doc/library/enum.rst Outdated
Comment thread Doc/library/enum.rst Outdated
Comment thread Lib/test/test_enum.py Outdated
@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@jason-curtis

Copy link
Copy Markdown
Author

Thanks for the review! I have made the requested changes; please review again :)

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@ethanfurman: please review the changes made to this pull request.

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

Nearly there!

Comment thread Doc/library/enum.rst Outdated
@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@jason-curtis

Copy link
Copy Markdown
Author

I have made the requested changes; please review again - though check the comment above in case we want to do one more quick round.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@ethanfurman: please review the changes made to this pull request.

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry @thatneat and @ethanfurman, I had trouble checking out the 3.8 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 2f19e82fbe98ce86bcd98a176328af2808b678e8 3.8

@jason-curtis

jason-curtis commented Jul 4, 2019 via email

Copy link
Copy Markdown
Author

@ethanfurman

Copy link
Copy Markdown
Member

@thatneat If you know your way around git and GitHub feel free! My git-fu is very weak. In case you haven't seen it, the dev guide is here:

https://devguide.python.org/

@jason-curtis

jason-curtis commented Jul 4, 2019

Copy link
Copy Markdown
Author

It looks like I don't have the permissions I need to use the cherry_picker tool. I almost got there, but it requires push access to the repo. I didn't even have to get too dirty in git-land. All I had to do was:

pip install cherry_picker --user
cherry_picker 2f19e82fbe98ce86bcd98a176328af2808b678e8 3.7

Then, manually edit Misc/ACKS to remove the merge markers but keep the additions (search for ">>>>" and delete the 3 lines that don't belong), then

git add Misc/ACKS
cherry_picker --continue # This is where I was blocked by not being allowed to push to the 3.7 branch

# This one didn't even appear to require a manual merge; it was just good to go.
cherry_picker 2f19e82fbe98ce86bcd98a176328af2808b678e8 3.8

lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
… __str__ (pythonGH-14545)

* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
… __str__ (pythonGH-14545)

* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @thatneat for the PR, and @ethanfurman for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @thatneat and @ethanfurman, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 2f19e82fbe98ce86bcd98a176328af2808b678e8 3.8

ethanfurman pushed a commit to ethanfurman/cpython that referenced this pull request Sep 13, 2020
…ridden __str__ (pythonGH-14545)

* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__.
(cherry picked from commit 2f19e82)

Co-authored-by: thatneat <thatneat@users.noreply.github.com>
@bedevere-bot

Copy link
Copy Markdown

GH-22227 is a backport of this pull request to the 3.8 branch.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @thatneat for the PR, and @ethanfurman for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry @thatneat and @ethanfurman, I had trouble checking out the 3.7 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 2f19e82fbe98ce86bcd98a176328af2808b678e8 3.7

ethanfurman pushed a commit to ethanfurman/cpython that referenced this pull request Sep 13, 2020
…ridden __str__ (pythonGH-14545)

* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__.
(cherry picked from commit 2f19e82)

Co-authored-by: thatneat <thatneat@users.noreply.github.com>
@bedevere-bot

Copy link
Copy Markdown

GH-22228 is a backport of this pull request to the 3.7 branch.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @thatneat for the PR, and @ethanfurman for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @thatneat and @ethanfurman, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 2f19e82fbe98ce86bcd98a176328af2808b678e8 3.9

ethanfurman added a commit that referenced this pull request Sep 13, 2020
* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__.
(cherry picked from commit 2f19e82)

Co-authored-by: thatneat <thatneat@users.noreply.github.com>
@dvarrazzo

Copy link
Copy Markdown

Maybe this change should be mentioned in the 3.11 what's new. It has the potential of breaking a lot of code.

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