FIX: MouseButton representation in boilerplate generated signatures#20148
Merged
timhoffm merged 1 commit intomatplotlib:masterfrom May 4, 2021
Merged
Conversation
anntzer
reviewed
May 4, 2021
| from matplotlib import _api, mlab | ||
| from matplotlib.axes import Axes | ||
| from matplotlib.figure import Figure | ||
| from matplotlib.backend_bases import MouseButton |
Contributor
There was a problem hiding this comment.
order imports alphabetically
In Python 3.10 the repr and str representation of Enums changed from str: 'ClassName.NAME' -> 'NAME' repr: '<ClassName.NAME: value>' -> 'ClassName.NAME' which is more consistent with what str/repr should do, however this breaks boilerplate which needs to get the ClassName.NAME version in all versions of Python. Thus, we locally monkey patch our preferred str representation in here. bpo-40066 python/cpython#22392
97d07b8 to
93973ab
Compare
timhoffm
approved these changes
May 4, 2021
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
May 4, 2021
…erplate generated signatures
timhoffm
added a commit
that referenced
this pull request
May 4, 2021
…148-on-v3.4.x Backport PR #20148 on branch v3.4.x (FIX: MouseButton representation in boilerplate generated signatures)
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
In Python 3.10 the repr and str representation of Enums changed from
str: 'ClassName.NAME' -> 'NAME'
repr: '<ClassName.NAME: value>' -> 'ClassName.NAME'
which is more consistent with what str/repr should do, however this breaks
boilerplate which needs to get the ClassName.NAME version in all versions of
Python. Thus, we locally monkey patch our preferred str representation in
here.
bpo-40066
python/cpython#22392
Other options considered:
MouseButton.__str__inmatplotlib.backend_bases. This has the advantage of maintaining stability ofstr(MouseButton.Left)over time, but this feels like something we should not fight upstream on. If they chose to break this intentionally we should follow them and not make our Enum "special"matplotlib/tools/boilerplate.py
Lines 122 to 125 in f6790c0
MouseButton, but that would more-or-less involve vendoring the str methods from bothinspect.Signatureandinspect.Parameterwhich are about a screen of code in total.PR Checklist
pytestpasses). (this fixes a failure on py310)flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).