Skip to content

Make deprecations versions explicit #17242

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 4 commits into from
Apr 30, 2020
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
4 changes: 2 additions & 2 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ def get_data_path(*, _from_rc=None):
cbook.warn_deprecated(
"3.2",
message=("Setting the datapath via matplotlibrc is deprecated "
"%(since)s and will be removed in %(removal)s."),
removal='3.3')
"%(since)s and will be removed %(removal)s."),
removal='3.4')
path = Path(_from_rc)
if path.is_dir():
defaultParams['datapath'][0] = str(path)
Expand Down
9 changes: 5 additions & 4 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5220,9 +5220,9 @@ def _fill_between_x_or_y(
where = np.asarray(where, dtype=bool)
if where.size != ind.size:
cbook.warn_deprecated(
"3.2", message=f"The parameter where must have the same "
f"size as {ind} in {func_name}(). This will become an "
"error in future versions of Matplotlib.")
"3.2", message=f"Since %(since)s, the parameter *where* "
f"must have the same size as {ind} in {func_name}(). This "
"will become an error %(removal)s.")
where = where & ~functools.reduce(
np.logical_or, map(np.ma.getmask, [ind, dep1, dep2]))

Expand Down Expand Up @@ -5606,7 +5606,8 @@ def _pcolorargs(funcname, *args, shading='flat'):
"dimensions as C is deprecated since %(since)s. Either "
"specify the corners of the quadrilaterals with X and Y, "
"or pass shading='auto', 'nearest' or 'gouraud', or set "
"rcParams['pcolor.shading']")
"rcParams['pcolor.shading']. This will become an error "
"%(removal)s.")
C = C[:Ny - 1, :Nx - 1]
else: # ['nearest', 'gouraud']:
if (Nx, Ny) != (ncols, nrows):
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/axes/_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def subplot_class_factory(axes_class=None):
if axes_class is None:
cbook.warn_deprecated(
"3.3", message="Support for passing None to subplot_class_factory "
"is deprecated; explicitly pass the default Axes class instead.")
"is deprecated since %(since)s; explicitly pass the default Axes "
"class instead. This will become an error %(removal)s.")
axes_class = Axes
try:
# Avoid creating two different instances of GeoAxesSubplot...
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,8 +1837,10 @@ def enter_notify_event(self, guiEvent=None, xy=None):
x = None
y = None
cbook.warn_deprecated(
'3.0', message='enter_notify_event expects a location but '
'your backend did not pass one.')
'3.0', removal='3.5', name='enter_notify_event',
message='Since %(since)s, %(name)s expects a location but '
'your backend did not pass one. This will become an error '
'%(removal)s.')

event = LocationEvent('figure_enter_event', self, x, y, guiEvent)
self.callbacks.process('figure_enter_event', event)
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
cbook.warn_deprecated(
"3.3",
message="Passing raw data via parameters data and lut to "
"register_cmap() is deprecated. Instead use: "
"register_cmap("
"register_cmap() is deprecated since %(since)s and will "
"become an error %(removal)s. Instead use: register_cmap("
"cmap=LinearSegmentedColormap(name, data, lut))")
# For the remainder, let exceptions propagate.
if lut is None:
Expand Down Expand Up @@ -195,7 +195,8 @@ def _scale_norm(self, norm, vmin, vmax):
cbook.warn_deprecated(
"3.3",
message="Passing parameters norm and vmin/vmax "
"simultaneously is deprecated. Please pass "
"simultaneously is deprecated since %(since)s and "
"will become an error %(removal)s. Please pass "
"vmin/vmax directly to the norm when creating it.")
else:
self.autoscale_None()
Expand Down
12 changes: 7 additions & 5 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,10 @@ def to_rgba_array(c, alpha=None):
"consisting of single character color specifiers such as "
"'rgb'. Note also that the latter is deprecated." % c) from err
else:
cbook.warn_deprecated("3.2", message="Using a string of single "
"character colors as a color sequence is "
"deprecated. Use an explicit list instead.")
cbook.warn_deprecated(
"3.2", message="Using a string of single character colors as "
"a color sequence is deprecated since %(since)s and will be "
"removed %(removal)s. Use an explicit list instead.")
return result

if len(c) == 0:
Expand Down Expand Up @@ -1255,8 +1256,9 @@ def __init__(self, linthresh, linscale=1.0, vmin=None, vmax=None,
if base is None:
self._base = np.e
cbook.warn_deprecated(
"3.3", message="default base will change from np.e to 10. To "
"suppress this warning specify the base kwarg.")
"3.2", removal="3.4", message="default base will change from "
"np.e to 10 %(removal)s. To suppress this warning specify "
"the base keyword argument.")
else:
self._base = base
self._log_base = np.log(self._base)
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,8 @@ def add_axes(self, *args, **kwargs):
cbook.warn_deprecated(
"3.3",
message="Calling add_axes() without argument is "
"deprecated. You may want to use add_subplot() "
"instead.")
"deprecated since %(since)s and will be removed %(removal)s. "
"You may want to use add_subplot() instead.")
return
elif 'rect' in kwargs:
if len(args):
Expand Down Expand Up @@ -1382,7 +1382,8 @@ def add_subplot(self, *args, **kwargs):
cbook.warn_deprecated(
"3.3",
message="Passing non-integers as three-element "
"position specification is deprecated.")
"position specification is deprecated since "
"%(since)s and will be removed %(removal)s.")
args = tuple(map(int, args))
else:
raise TypeError(f'add_subplot() takes 1 or 3 positional arguments '
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ def set_picker(self, p):
# After deprecation, the whole method can be deleted and inherited.
cbook.warn_deprecated(
"3.3", message="Setting the line's pick radius via set_picker "
"is deprecated; use set_pickradius instead.")
"is deprecated since %(since)s and will be removed "
"%(removal)s; use set_pickradius instead.")
self.pickradius = p
self._picker = p

Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ def validate_axisbelow(s):
cbook.warn_deprecated(
"3.3", message=f"Support for setting axes.axisbelow to "
f"{s!r} to mean 'line' is deprecated since %(since)s and "
f"will be removed in %(removal)s; set it to 'line' "
"instead.")
f"will be removed %(removal)s; set it to 'line' instead.")
return 'line'
raise ValueError('%s cannot be interpreted as'
' True, False, or "line"' % s)
Expand Down
14 changes: 7 additions & 7 deletions lib/matplotlib/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def __init__(self, axis, **kwargs):
"""
if kwargs:
warn_deprecated(
'3.2.0',
'3.2', removal='3.4',
message=(
f"ScaleBase got an unexpected keyword "
f"argument {next(iter(kwargs))!r}. "
'In the future this will raise TypeError')
f"ScaleBase got an unexpected keyword argument "
f"{next(iter(kwargs))!r}. This will become an error "
"%(removal)s.")
)

def get_transform(self):
Expand Down Expand Up @@ -483,11 +483,11 @@ def __init__(self, axis, **kwargs):
def __init__(*, base=10, linthresh=2, subs=None, linscale=1, **kwargs):
if kwargs:
warn_deprecated(
"3.2.0",
'3.2', removal='3.4',
message=(
f"SymmetricalLogScale got an unexpected keyword "
f"argument {next(iter(kwargs))!r}; in the future, "
f"this will raise a TypeError")
f"argument {next(iter(kwargs))!r}. This will become "
"an error %(removal)s.")
)
return base, linthresh, subs, linscale

Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/streamplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def __init__(self, lines, arrows, **kwargs):
cbook.warn_deprecated(
"3.3",
message="Passing arbitrary keyword arguments to StreamplotSet "
"is deprecated.")
"is deprecated since %(since) and will become an "
"error %(removal)s.")
self.lines = lines
self.arrows = arrows

Expand Down
13 changes: 8 additions & 5 deletions lib/mpl_toolkits/axes_grid1/parasite_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def parasite_axes_class_factory(axes_class=None):
if axes_class is None:
cbook.warn_deprecated(
"3.3", message="Support for passing None to "
"parasite_axes_class_factory is deprecated; explicitly pass the "
"default Axes class instead.")
"parasite_axes_class_factory is deprecated since %(since)s and "
"will be removed %(removal)s; explicitly pass the default Axes "
"class instead.")
axes_class = Axes

return type("%sParasite" % axes_class.__name__,
Expand Down Expand Up @@ -181,8 +182,9 @@ def parasite_axes_auxtrans_class_factory(axes_class=None):
if axes_class is None:
cbook.warn_deprecated(
"3.3", message="Support for passing None to "
"parasite_axes_auxtrans_class_factory is deprecated; explicitly "
"pass the default ParasiteAxes class instead.")
"parasite_axes_auxtrans_class_factory is deprecated since "
"%(since)s and will be removed %(removal)s; explicitly pass the "
"default ParasiteAxes class instead.")
parasite_axes_class = ParasiteAxes
elif not issubclass(axes_class, ParasiteAxesBase):
parasite_axes_class = parasite_axes_class_factory(axes_class)
Expand Down Expand Up @@ -363,7 +365,8 @@ def host_axes_class_factory(axes_class=None):
if axes_class is None:
cbook.warn_deprecated(
"3.3", message="Support for passing None to host_axes_class is "
"deprecated; explicitly pass the default Axes class instead.")
"deprecated since %(since)s and will be removed %(removed)s; "
"explicitly pass the default Axes class instead.")
axes_class = Axes

def _get_base_axes(self):
Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/axisartist/grid_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def _deprecate_factor_none(factor):
# removed.
if factor is None:
cbook.warn_deprecated(
"3.2",
message="factor=None is deprecated; use/return factor=1 instead")
"3.2", message="factor=None is deprecated since %(since)s and "
"support will be removed %(removal)s; use/return factor=1 instead")
factor = 1
return factor

Expand Down