Skip to content
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

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

Merged
merged 7 commits into from Jul 4, 2019

Conversation

thatneat
Copy link
Contributor

@thatneat thatneat commented Jul 2, 2019

@the-knights-who-say-ni
Copy link

@the-knights-who-say-ni the-knights-who-say-ni commented Jul 2, 2019

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!

Copy link
Member

@ericvsmith ericvsmith left a comment

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

@thatneat
Copy link
Contributor Author

@thatneat thatneat commented Jul 2, 2019

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
Copy link
Member

@ethanfurman ethanfurman left a comment

Just a couple changes needed.

Also, please add yourself to the ACKS file.

Thank you for working on this!

Doc/library/enum.rst Outdated Show resolved Hide resolved
Doc/library/enum.rst Outdated Show resolved Hide resolved
Lib/test/test_enum.py Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 4, 2019

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.

@thatneat
Copy link
Contributor Author

@thatneat thatneat commented Jul 4, 2019

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

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 4, 2019

Thanks for making the requested changes!

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

Copy link
Member

@ethanfurman ethanfurman left a comment

Nearly there!

Doc/library/enum.rst Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 4, 2019

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.

@thatneat
Copy link
Contributor Author

@thatneat thatneat commented Jul 4, 2019

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

@bedevere-bot bedevere-bot commented Jul 4, 2019

Thanks for making the requested changes!

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

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 4, 2019

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

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 4, 2019

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

@thatneat
Copy link
Contributor Author

@thatneat thatneat commented Jul 4, 2019

@ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Jul 4, 2019

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

@thatneat
Copy link
Contributor Author

@thatneat thatneat commented Jul 4, 2019

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

LorenzMende pushed a commit to LorenzMende/cpython that referenced this issue Aug 11, 2019
… __str__ (pythonGH-14545)

* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
lisroach pushed a commit to lisroach/cpython that referenced this issue 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 issue Jan 14, 2020
… __str__ (pythonGH-14545)

* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
ethanfurman pushed a commit to ethanfurman/cpython that referenced this issue Sep 13, 2020
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 13, 2020

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
Contributor

@miss-islington miss-islington commented Sep 13, 2020

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 issue 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

@bedevere-bot bedevere-bot commented Sep 13, 2020

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

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 13, 2020

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
Contributor

@miss-islington miss-islington commented Sep 13, 2020

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 issue 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

@bedevere-bot bedevere-bot commented Sep 13, 2020

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

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 13, 2020

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
Contributor

@miss-islington miss-islington commented Sep 13, 2020

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 issue 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

@dvarrazzo dvarrazzo commented May 16, 2022

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants