Skip to content

Commit 3a994d2

Browse files
authored
Merge pull request #22514 from oscargus/cbookdeprecationremoval
Expire deprecations in cbook.deprecation
2 parents 2e95730 + ebc9d65 commit 3a994d2

File tree

10 files changed

+23
-42
lines changed

10 files changed

+23
-42
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Removal of deprecations in ``cbook``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The module ``cbook.deprecation`` is removed from the public API as it is
5+
considered internal. This also holds for deprecation-related re-imports in
6+
``cbook``: ``deprecated``, ``MatplotlibDeprecationWarning``,
7+
``mplDeprecation``, and ``warn_deprecated``.

lib/matplotlib/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
# cbook must import matplotlib only within function
108108
# definitions, so it is safe to import from it here.
109109
from . import _api, _version, cbook, docstring, rcsetup
110-
from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
111-
from matplotlib.cbook import mplDeprecation # deprecated
110+
from matplotlib.cbook import sanitize_sequence
111+
from matplotlib._api import MatplotlibDeprecationWarning
112112
from matplotlib.rcsetup import validate_backend, cycler
113113

114114

lib/matplotlib/_api/deprecation.py

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ class MatplotlibDeprecationWarning(DeprecationWarning):
2121
"""A class for issuing deprecation warnings for Matplotlib users."""
2222

2323

24-
# mplDeprecation is deprecated. Use MatplotlibDeprecationWarning instead.
25-
# remove when removing the re-import from cbook
26-
mplDeprecation = MatplotlibDeprecationWarning
27-
28-
2924
def _generate_deprecation_warning(
3025
since, message='', name='', alternative='', pending=False, obj_type='',
3126
addendum='', *, removal=''):

lib/matplotlib/cbook/__init__.py

+2-13
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@
2929

3030
import matplotlib
3131
from matplotlib import _api, _c_internal_utils
32-
from matplotlib._api.deprecation import (
33-
MatplotlibDeprecationWarning, mplDeprecation)
34-
35-
36-
@_api.deprecated("3.4")
37-
def deprecated(*args, **kwargs):
38-
return _api.deprecated(*args, **kwargs)
39-
40-
41-
@_api.deprecated("3.4")
42-
def warn_deprecated(*args, **kwargs):
43-
_api.warn_deprecated(*args, **kwargs)
4432

4533

4634
def _get_running_interactive_framework():
@@ -375,7 +363,8 @@ def __repr__(self):
375363

376364

377365
def _local_over_kwdict(
378-
local_var, kwargs, *keys, warning_cls=MatplotlibDeprecationWarning):
366+
local_var, kwargs, *keys,
367+
warning_cls=_api.MatplotlibDeprecationWarning):
379368
out = local_var
380369
for key in keys:
381370
kwarg_val = kwargs.pop(key, None)

lib/matplotlib/cbook/deprecation.py

-8
This file was deleted.

lib/matplotlib/collections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ def __init__(self, segments, # Can be None.
14201420
if args:
14211421
argkw = {name: val for name, val in zip(argnames, args)}
14221422
kwargs.update(argkw)
1423-
cbook.warn_deprecated(
1423+
_api.warn_deprecated(
14241424
"3.4", message="Since %(since)s, passing LineCollection "
14251425
"arguments other than the first, 'segments', as positional "
14261426
"arguments is deprecated, and they will become keyword-only "

lib/matplotlib/tests/test_axes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import matplotlib
1919
import matplotlib as mpl
20-
from matplotlib.testing.decorators import (
21-
image_comparison, check_figures_equal, remove_ticks_and_titles)
20+
from matplotlib import rc_context
21+
from matplotlib._api import MatplotlibDeprecationWarning
2222
import matplotlib.colors as mcolors
2323
import matplotlib.dates as mdates
2424
from matplotlib.figure import Figure
@@ -32,8 +32,8 @@
3232
import matplotlib.transforms as mtransforms
3333
from numpy.testing import (
3434
assert_allclose, assert_array_equal, assert_array_almost_equal)
35-
from matplotlib import rc_context
36-
from matplotlib.cbook import MatplotlibDeprecationWarning
35+
from matplotlib.testing.decorators import (
36+
image_comparison, check_figures_equal, remove_ticks_and_titles)
3737

3838
# Note: Some test cases are run twice: once normally and once with labeled data
3939
# These two must be defined in the same test function or need to have

lib/matplotlib/tests/test_backend_ps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from matplotlib import cbook, patheffects
10-
from matplotlib.cbook import MatplotlibDeprecationWarning
10+
from matplotlib._api import MatplotlibDeprecationWarning
1111
from matplotlib.figure import Figure
1212
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1313
import matplotlib as mpl

lib/matplotlib/tests/test_colors.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010

1111
from numpy.testing import assert_array_equal, assert_array_almost_equal
1212

13-
from matplotlib import cycler
13+
from matplotlib import _api, cbook, cm, cycler
1414
import matplotlib
1515
import matplotlib.colors as mcolors
16-
import matplotlib.cm as cm
1716
import matplotlib.colorbar as mcolorbar
18-
import matplotlib.cbook as cbook
1917
import matplotlib.pyplot as plt
2018
import matplotlib.scale as mscale
2119
from matplotlib.testing.decorators import image_comparison, check_figures_equal
@@ -109,7 +107,7 @@ def test_colormap_global_set_warn():
109107
new_cm = plt.get_cmap('viridis')
110108
# Store the old value so we don't override the state later on.
111109
orig_cmap = copy.copy(new_cm)
112-
with pytest.warns(cbook.MatplotlibDeprecationWarning,
110+
with pytest.warns(_api.MatplotlibDeprecationWarning,
113111
match="You are modifying the state of a globally"):
114112
# This should warn now because we've modified the global state
115113
new_cm.set_under('k')
@@ -120,7 +118,7 @@ def test_colormap_global_set_warn():
120118
# Test that registering and then modifying warns
121119
plt.register_cmap(name='test_cm', cmap=copy.copy(orig_cmap))
122120
new_cm = plt.get_cmap('test_cm')
123-
with pytest.warns(cbook.MatplotlibDeprecationWarning,
121+
with pytest.warns(_api.MatplotlibDeprecationWarning,
124122
match="You are modifying the state of a globally"):
125123
# This should warn now because we've modified the global state
126124
new_cm.set_under('k')
@@ -132,11 +130,11 @@ def test_colormap_global_set_warn():
132130

133131
def test_colormap_dict_deprecate():
134132
# Make sure we warn on get and set access into cmap_d
135-
with pytest.warns(cbook.MatplotlibDeprecationWarning,
133+
with pytest.warns(_api.MatplotlibDeprecationWarning,
136134
match="The global colormaps dictionary is no longer"):
137135
cmap = plt.cm.cmap_d['viridis']
138136

139-
with pytest.warns(cbook.MatplotlibDeprecationWarning,
137+
with pytest.warns(_api.MatplotlibDeprecationWarning,
140138
match="The global colormaps dictionary is no longer"):
141139
plt.cm.cmap_d['test'] = cmap
142140

lib/matplotlib/tests/test_pyplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import matplotlib as mpl
1010
from matplotlib import pyplot as plt
11-
from matplotlib.cbook import MatplotlibDeprecationWarning
11+
from matplotlib._api import MatplotlibDeprecationWarning
1212

1313

1414
def test_pyplot_up_to_date(tmpdir):

0 commit comments

Comments
 (0)