Skip to content

Fix usages of warn_deprecated() #12823

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 1 commit into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ def set_adjustable(self, adjustable, share=False):
"""
if adjustable == 'box-forced':
cbook.warn_deprecated(
"2.2", "box-forced", obj_type="keyword argument")
"2.2", name="box-forced", obj_type="keyword argument")
Copy link
Member

Choose a reason for hiding this comment

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

passing obj_type is deprecated and has no effect. Probably doesn't make sense to have a deprecation warning trigger another deprecation warning if we can prevent it...

Copy link
Member Author

Choose a reason for hiding this comment

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

Where is that? I cannot find a deprecation of obj_type in the code. Have you maybe misinterpreded the docstring?

    obj_type : str, optional
        The object type being deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

It was deprecated in #11395 because it does nothing.

if adjustable not in ('box', 'datalim', 'box-forced'):
raise ValueError("argument must be 'box', or 'datalim'")
if share:
Expand Down Expand Up @@ -1641,8 +1641,8 @@ def axis(self, *v, **kwargs):
'auto', 'image', 'square'):
if s == 'normal':
cbook.warn_deprecated(
"3.1", "Passing 'normal' to axis() is deprecated "
"since %(since)s; use 'auto' instead.")
"3.1", message="Passing 'normal' to axis() is "
"deprecated since %(since)s; use 'auto' instead.")
self.set_autoscale_on(True)
self.set_aspect('auto')
self.autoscale_view(tight=False)
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,9 +1637,9 @@ def set_ticklabels(self, ticklabels, *args, minor=False, **kwargs):
"""
if args:
cbook.warn_deprecated(
"3.1", "Additional positional arguments to set_ticklabels are "
"ignored, and deprecated since Matplotlib 3.1; passing them "
"will raise a TypeError in Matplotlib 3.3.")
"3.1", message="Additional positional arguments to "
"set_ticklabels are ignored, and deprecated since Matplotlib "
"3.1; passing them will raise a TypeError in Matplotlib 3.3.")
get_labels = []
for t in ticklabels:
# try calling get_text() to check whether it is Text object
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ def _string_to_bool(s):
"""Parses the string argument as a boolean"""
if not isinstance(s, str):
return bool(s)
warn_deprecated("2.2", "Passing one of 'on', 'true', 'off', 'false' as a "
"boolean is deprecated; use an actual boolean "
"(True/False) instead.")
warn_deprecated("2.2", message="Passing one of 'on', 'true', 'off', "
"'false' as a boolean is deprecated; use an actual "
"boolean (True/False) instead.")
if s.lower() in ['on', 'true']:
return True
if s.lower() in ['off', 'false']:
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/cbook/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ def the_function_to_deprecate():

if obj_type is not None:
warn_deprecated(
"3.0", "Passing 'obj_type' to the 'deprecated' decorator has no "
"effect, and is deprecated since Matplotlib %(since)s; support "
"for it will be removed %(removal)s.")
"3.0", message="Passing 'obj_type' to the 'deprecated' decorator "
"has no effect, and is deprecated since Matplotlib %(since)s; "
"support for it will be removed %(removal)s.")
Copy link
Member

Choose a reason for hiding this comment

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

I got confused by this over here. This is not confusing at all!


def deprecate(obj, message=message, name=name, alternative=alternative,
pending=pending, addendum=addendum):
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def get_subplot_params(self, figure=None, fig=None):
parameters are from rcParams unless a figure attribute is set.
"""
if fig is not None:
cbook.warn_deprecated("2.2", "fig", obj_type="keyword argument",
cbook.warn_deprecated("2.2", name="fig",
obj_type="keyword argument",
Copy link
Member

Choose a reason for hiding this comment

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

obj_type has no effect and is deprecated.

alternative="figure")
if figure is None:
figure = fig
Expand Down Expand Up @@ -382,7 +383,8 @@ def get_subplot_params(self, figure=None, fig=None):
"""Return a dictionary of subplot layout parameters.
"""
if fig is not None:
cbook.warn_deprecated("2.2", "fig", obj_type="keyword argument",
cbook.warn_deprecated("2.2", name="fig",
obj_type="keyword argument",
Copy link
Member

Choose a reason for hiding this comment

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

ditto

alternative="figure")
if figure is None:
figure = fig
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,10 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
badkwargs = {'ha', 'horizontalalignment', 'va', 'verticalalignment'}
if badkwargs & set(prop):
cbook.warn_deprecated(
"3.1", "Mixing horizontalalignment or verticalalignment with "
"AnchoredText is not supported, deprecated since %(version)s, "
"and will raise an exception %(removal)s.")
"3.1", message="Mixing horizontalalignment or "
"verticalalignment with AnchoredText is not supported, "
"deprecated since %(version)s, and will raise an exception "
"%(removal)s.")

self.txt = TextArea(s, textprops=prop, minimumdescent=False)
fp = self.txt._text.get_fontproperties()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def validate_svg_fonttype(s):
return s
if s == "svgfont":
cbook.warn_deprecated(
"2.2", "'svgfont' support for svg.fonttype is deprecated.")
"2.2", message="'svgfont' support for svg.fonttype is deprecated.")
return s
raise ValueError("Unrecognized svg.fonttype string '{}'; "
"valid strings are 'none', 'path'")
Expand Down
7 changes: 4 additions & 3 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,9 +1662,10 @@ def plot_surface(self, X, Y, Z, *args, norm=None, vmin=None,
if shade is None:
cbook.warn_deprecated(
"3.1",
"Passing shade=None to Axes3D.plot_surface() is deprecated "
"since matplotlib 3.1 and will change its semantic or raise "
"an error in matplotlib 3.3. Please use shade=False instead.")
message="Passing shade=None to Axes3D.plot_surface() is "
"deprecated since matplotlib 3.1 and will change its "
"semantic or raise an error in matplotlib 3.3. "
"Please use shade=False instead.")

# evenly spaced, and including both endpoints
row_inds = list(range(0, rows-1, rstride)) + [rows-1]
Expand Down