8000 Add deprecation messages for unused kwargs in FancyArrowPatch by dstansby · Pull Request #11224 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add deprecation messages for unused kwargs in FancyArrowPatch #11224

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

Merged
merged 2 commits into from
Jun 16, 2018

Conversation

dstansby
Copy link
Member
@dstansby dstansby commented May 10, 2018

I've gone with removal in 3.1, but I'm not sure if that's too soon or not? I've also added a newline before deprecation messages, as it makes them more readable, changing them from:

/Users/dstansby/github/matplotlib/lib/matplotlib/patches.py:4069: MatplotlibDeprecationWarning: The "arrow_transmuter" keyword argument is not used, and will be removed in Matplotlib 3.1

to

/Users/dstansby/github/matplotlib/lib/matplotlib/patches.py:4069: MatplotlibDeprecationWarning: 
The "arrow_transmuter" keyword argument is not used, and will be removed in Matplotlib 3.1

@dstansby dstansby added this to the v3.0 milestone May 10, 2018
message=('The "connector" keyword argument is not used,'
' and will be removed in Matplotlib 3.1'),
name='arrow_transmuter',
obj_type='keyword argument')

Choose a reason for hiding this comment

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

should be name=connector' ?

@dstansby dstansby force-pushed the fancyarrowkwargs branch from 7e82f3f to 2cdb484 Compare May 10, 2018 14:52
@@ -100,6 +100,7 @@ def warn_deprecated(
"""
message = _generate_deprecation_message(
since, message, name, alternative, pending, obj_type, removal=removal)
message = '\n' + message
Copy link
Member

Choose a reason for hiding this comment

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

Minor style thing: I would not do this explicitly on a separate line, but rather:
warnings.warn('\n' + message, ...)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually quite strongly -1 on embedding explicit newlines in warnings and error messages.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why, out of interest?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because you are making assumptions about the width of the window of the output (most of the time a normal linewrap will just work as well); moreover people can for example capture warnings into the logging system (logging.captureWarnings) and do all kinds of custom formatting of the message there as well.
Not going to block the PR over that, just giving my opinion though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think of it as making assumptions about the maximum number of characters that should reasonably fit on one line, with the linebreak making the message as a whole more readable. I'd be inclined to say that if advanced users want to do custom formatting then it's much easier to remove line breaks than try and work out where to put them in.

cbook.warn_deprecated(
3.0,
message=('The "arrow_transmuter" keyword argument is not used,'
' and will be removed in Matplotlib 3.1'),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do something like cbook.warn_deprecated("3.0", "arrow_transmuter", obj_type="keyword argument", removal="3.1") and that'll give you the right message.

Copy link
Member

Choose a reason for hiding this comment

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

@dstansby, did you want to do this, or should I just merge as is?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the message looks fine as is then can it be merged as is?

@timhoffm timhoffm merged commit 932fd81 into matplotlib:master Jun 16, 2018
@dstansby dstansby deleted the fancyarrowkwargs branch June 16, 2018 09:46
@pavoljuhas
Copy link
Contributor

@timhoffm @tacaswell - Can this be reverted?

I just ventured here after looking for a reason why my warnings filter stopped working.
The prefixed \n makes it more tricky to filter warnings by their message and makes them
fairly impossible to match with -Waction:message: command line option.
The message argument in filterwarnings must match from the start of the message and this change makes it more tricky.

# before
filterwarnings('ignore', message='Adding an axes using the same arguments')
# now
filterwarnings('ignore', message=r'\s*Adding an axes using the same arguments')

QuLogic added a commit to QuLogic/matplotlib that referenced this pull request May 25, 2022
This breaks the summary from Pytest when warnings are errors, as then
you just get a bunch of:
```
FAILED lib/matplotlib/tests/test_getattr.py::test_getattr[matplotlib.afm] - matplotlib._api.deprecation.MatplotlibDeprecationWarning:
```
with no real context as to the problem.

Also, as noted at the original PR [1], it makes setting `filterwarnings`
more complicated.

[1] matplotlib#11224 (comment)
andrew-fennell pushed a commit to andrew-fennell/matplotlib that referenced this pull request Jun 14, 2022
This breaks the summary from Pytest when warnings are errors, as then
you just get a bunch of:
```
FAILED lib/matplotlib/tests/test_getattr.py::test_getattr[matplotlib.afm] - matplotlib._api.deprecation.MatplotlibDeprecationWarning:
```
with no real context as to the problem.

Also, as noted at the original PR [1], it makes setting `filterwarnings`
more complicated.

[1] matplotlib#11224 (comment)
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.

6 participants
0