8000 Add explicit versions to deprecation messages. · matplotlib/matplotlib@b1f4b8f · GitHub
[go: up one dir, main page]

Skip to content

Commit b1f4b8f

Browse files
committed
Add explicit versions to deprecation messages.
Messages without `%(since)s` and `%(removal)s` will be ambiguous as to when the were deprecated and when they will be removed.
1 parent 427f0f9 commit b1f4b8f

File tree

10 files changed

+43
-32
lines changed

10 files changed

+43
-32
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5220,9 +5220,9 @@ def _fill_between_x_or_y(
52205220
where = np.asarray(where, dtype=bool)
52215221
if where.size != ind.size:
52225222
cbook.warn_deprecated(
5223-
"3.2", message=f"The parameter where must have the same "
5224-
f"size as {ind} in {func_name}(). This will become an "
5225-
"error in future versions of Matplotlib.")
5223+
"3.2", message=f"Since %(since)s, the parameter *where* "
5224+
f"must have the same size as {ind} in {func_name}(). This "
5225+
"will become an error %(removal)s.")
52265226
where = where & ~functools.reduce(
52275227
np.logical_or, map(np.ma.getmask, [ind, dep1, dep2]))
52285228

@@ -5606,7 +5606,8 @@ def _pcolorargs(funcname, *args, shading='flat'):
56065606
"dimensions as C is deprecated since %(since)s. Either "
56075607
"specify the corners of the quadrilaterals with X and Y, "
56085608
"or pass shading='auto', 'nearest' or 'gouraud', or set "
5609-
"rcParams['pcolor.shading']")
5609+
"rcParams['pcolor.shading']. This will become an error "
5610+
"%(removal)s.")
56105611
C = C[:Ny - 1, :Nx - 1]
56115612
else: # ['nearest', 'gouraud']:
56125613
if (Nx, Ny) != (ncols, nrows):

lib/matplotlib/axes/_subplots.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ def subplot_class_factory(axes_class=None):
188188
if axes_class is None:
189189
cbook.warn_deprecated(
190190
"3.3", message="Support for passing None to subplot_class_factory "
191-
"is deprecated; explicitly pass the default Axes class instead.")
191+
"is deprecated since %(since)s; explicitly pass the default Axes "
192+
"class instead. This will become an error %(removal)s.")
192193
axes_class = Axes
193194
try:
194195
# Avoid creating two different instances of GeoAxesSubplot...

lib/matplotlib/cm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
110110
cbook.warn_deprecated(
111111
"3.3",
112112
message="Passing raw data via parameters data and lut to "
113-
"register_cmap() is deprecated. Instead use: "
114-
"register_cmap("
113+
"register_cmap() is deprecated since %(since)s and will "
114+
"become an error %(removal)s. Instead use: register_cmap("
115115
"cmap=LinearSegmentedColormap(name, data, lut))")
116116
# For the remainder, let exceptions propagate.
117117
if lut is None:
@@ -195,7 +195,8 @@ def _scale_norm(self, norm, vmin, vmax):
195195
cbook.warn_deprecated(
196196
"3.3",
197197
message="Passing parameters norm and vmin/vmax "
198-
"simultaneously is deprecated. Please pass "
198+
"simultaneously is deprecated since %(since)s and "
199+
"will become an error %(removal)s. Please pass "
199200
"vmin/vmax directly to the norm when creating it.")
200201
else:
201202
self.autoscale_None()

lib/matplotlib/colors.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,10 @@ def to_rgba_array(c, alpha=None):
321321
"consisting of single character color specifiers such as "
322322
"'rgb'. Note also that the latter is deprecated." % c) from err
323323
else:
324-
cbook.warn_deprecated("3.2", message="Using a string of single "
325-
"character colors as a color sequence is "
326-
"deprecated. Use an explicit list instead.")
324+
cbook.warn_deprecated(
325+
"3.2", message="Using a string of single character colors as "
326+
"a color sequence is deprecated since %(since)s and will be "
327+
"removed %(removal)s. Use an explicit list instead.")
327328
return result
328329

329330
if len(c) == 0:
@@ -1255,8 +1256,9 @@ def __init__(self, linthresh, linscale=1.0, vmin=None, vmax=None,
12551256
if base is None:
12561257
self._base = np.e
12571258
cbook.warn_deprecated(
1258-
"3.3", message="default base will change from np.e to 10. To "
1259-
"suppress this warning specify the base kwarg.")
1259+
"3.2", removal="3.3", message="default base will change from "
1260+
"np.e to 10 in %(removal)s. To suppress this warning specify "
1261+
"the base keyword argument.")
12601262
else:
12611263
self._base = base
12621264
self._log_base = np.log(self._base)

lib/matplotlib/figure.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,8 @@ def add_axes(self, *args, **kwargs):
12081208
cbook.warn_deprecated(
12091209
"3.3",
12101210
message="Calling add_axes() without argument is "
1211-
"deprecated. You may want to use add_subplot() "
1212-
"instead.")
1211+
"deprecated since %(since)s and will be removed %(removal)s. "
1212+
"You may want to use add_subplot() instead.")
12131213
return
12141214
elif 'rect' in kwargs:
12151215
if len(args):
@@ -1382,7 +1382,8 @@ def add_subplot(self, *args, **kwargs):
13821382
cbook.warn_deprecated(
13831383
"3.3",
13841384
message="Passing non-integers as three-element "
1385-
"position specification is deprecated.")
1385+
"position specification is deprecated since "
1386+
"%(since)s and will be removed %(removal)s.")
13861387
args = tuple(map(int, args))
13871388
else:
13881389
raise TypeError(f'add_subplot() takes 1 or 3 positional arguments '

lib/matplotlib/lines.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ def set_picker(self, p):
608608
# After deprecation, the whole method can be deleted and inherited.
609609
cbook.warn_deprecated(
610610
"3.3", message="Setting the line's pick radius via set_picker "
611-
"is deprecated; use set_pickradius instead.")
611+
"is deprecated since %(since)s and will be removed "
612+
"%(removal)s; use set_pickradius instead.")
612613
self.pickradius = p
613614
self._picker = p
614615

lib/matplotlib/scale.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def __init__(self, axis, **kwargs):
5656
"""
5757
if kwargs:
5858
warn_deprecated(
59-
'3.2.0',
59+
'3.2', removal='3.4',
6060
message=(
61-
f"ScaleBase got an unexpected keyword "
62-
f"argument {next(iter(kwargs))!r}. "
63-
'In the future this will raise TypeError')
61+
f"ScaleBase got an unexpected keyword argument "
62+
f"{next(iter(kwargs))!r}. This will become an error "
63+
"%(removal)s.")
6464
)
6565

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

lib/matplotlib/streamplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def __init__(self, lines, arrows, **kwargs):
237237
cbook.warn_deprecated(
238238
"3.3",
239239
message="Passing arbitrary keyword arguments to StreamplotSet "
240-
"is deprecated.")
240+
"is deprecated since %(since) and will become an "
241+
"error %(removal)s.")
241242
self.lines = lines
242243
self.arrows = arrows
243244

lib/mpl_toolkits/axes_grid1/parasite_axes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def parasite_axes_class_factory(axes_class=None):
5454
if axes_class is None:
5555
cbook.warn_deprecated(
5656
"3.3", message="Support for passing None to "
57-
"parasite_axes_class_factory is deprecated; explicitly pass the "
58-
"default Axes class instead.")
57+
"parasite_axes_class_factory is deprecated since %(since)s and "
58+
"will be removed %(removal)s; explicitly pass the default Axes "
59+
"class instead.")
5960
axes_class = Axes
6061

6162
return type("%sParasite" % axes_class.__name__,
@@ -181,8 +182,9 @@ def parasite_axes_auxtrans_class_factory(axes_class=None):
181182
if axes_class is None:
182183
cbook.warn_deprecated(
183184
"3.3", message="Support for passing None to "
184-
"parasite_axes_auxtrans_class_factory is deprecated; explicitly "
185-
"pass the default ParasiteAxes class instead.")
185+
"parasite_axes_auxtrans_class_factory is deprecated since "
186+
"%(since)s and will be removed %(removal)s; explicitly pass the "
187+
"default ParasiteAxes class instead.")
186188
parasite_axes_class = ParasiteAxes
187189
elif not issubclass(axes_class, ParasiteAxesBase):
188190
parasite_axes_class = parasite_axes_class_factory(axes_class)
@@ -363,7 +365,8 @@ def host_axes_class_factory(axes_class=None):
363365
if axes_class is None:
364366
cbook.warn_deprecated(
365367
"3.3", message="Support for passing None to host_axes_class is "
366-
"deprecated; explicitly pass the default Axes class instead.")
368+
"deprecated since %(since)s and will be removed %(removed)s; "
369+
"explicitly pass the default Axes class instead.")
367370
axes_class = Axes
368371

369372
def _get_base_axes(self):

lib/mpl_toolkits/axisartist/grid_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def _deprecate_factor_none(factor):
1010
# removed.
1111
if factor is None:
1212
cbook.warn_deprecated(
13-
"3.2",
14-
message="factor=None is deprecated; use/return factor=1 instead")
13+
"3.2", message="factor=None is deprecated since %(since)s and "
14+
"support will be removed %(removal)s; use/return factor=1 instead")
1515
factor = 1
1616
return factor
1717

0 commit comments

Comments
 (0)
0