diff --git a/doc/api/next_api_changes/removals/22514-OG.rst b/doc/api/next_api_changes/removals/22514-OG.rst new file mode 100644 index 000000000000..edce714555bd --- /dev/null +++ b/doc/api/next_api_changes/removals/22514-OG.rst @@ -0,0 +1,7 @@ +Removal of deprecations in ``cbook`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The module ``cbook.deprecation`` is removed from the public API as it is +considered internal. This also holds for deprecation-related re-imports in +``cbook``: ``deprecated``, ``MatplotlibDeprecationWarning``, +``mplDeprecation``, and ``warn_deprecated``. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index e68c3cb68f7d..4663ce58636a 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -107,8 +107,8 @@ # cbook must import matplotlib only within function # definitions, so it is safe to import from it here. from . import _api, _version, cbook, docstring, rcsetup -from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence -from matplotlib.cbook import mplDeprecation # deprecated +from matplotlib.cbook import sanitize_sequence +from matplotlib._api import MatplotlibDeprecationWarning from matplotlib.rcsetup import validate_backend, cycler diff --git a/lib/matplotlib/_api/deprecation.py b/lib/matplotlib/_api/deprecation.py index 0eacc3730cdc..5c491e49772d 100644 --- a/lib/matplotlib/_api/deprecation.py +++ b/lib/matplotlib/_api/deprecation.py @@ -21,11 +21,6 @@ class MatplotlibDeprecationWarning(DeprecationWarning): """A class for issuing deprecation warnings for Matplotlib users.""" -# mplDeprecation is deprecated. Use MatplotlibDeprecationWarning instead. -# remove when removing the re-import from cbook -mplDeprecation = MatplotlibDeprecationWarning - - def _generate_deprecation_warning( since, message='', name='', alternative='', pending=False, obj_type='', addendum='', *, removal=''): diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 17458cb76c16..035cdef44124 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -29,18 +29,6 @@ import matplotlib from matplotlib import _api, _c_internal_utils -from matplotlib._api.deprecation import ( - MatplotlibDeprecationWarning, mplDeprecation) - - -@_api.deprecated("3.4") -def deprecated(*args, **kwargs): - return _api.deprecated(*args, **kwargs) - - -@_api.deprecated("3.4") -def warn_deprecated(*args, **kwargs): - _api.warn_deprecated(*args, **kwargs) def _get_running_interactive_framework(): @@ -365,7 +353,8 @@ def __repr__(self): def _local_over_kwdict( - local_var, kwargs, *keys, warning_cls=MatplotlibDeprecationWarning): + local_var, kwargs, *keys, + warning_cls=_api.MatplotlibDeprecationWarning): out = local_var for key in keys: kwarg_val = kwargs.pop(key, None) diff --git a/lib/matplotlib/cbook/deprecation.py b/lib/matplotlib/cbook/deprecation.py deleted file mode 100644 index 5a0f02f7decf..000000000000 --- a/lib/matplotlib/cbook/deprecation.py +++ /dev/null @@ -1,8 +0,0 @@ -# imports are for backward compatibility -from matplotlib._api.deprecation import ( - MatplotlibDeprecationWarning, mplDeprecation, warn_deprecated, deprecated) - -warn_deprecated("3.4", - message="The module matplotlib.cbook.deprecation is " - "considered internal and it will be made private in the " - "future.") diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index eb05aaf00a5a..7e4407908eb8 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -1420,7 +1420,7 @@ def __init__(self, segments, # Can be None. if args: argkw = {name: val for name, val in zip(argnames, args)} kwargs.update(argkw) - cbook.warn_deprecated( + _api.warn_deprecated( "3.4", message="Since %(since)s, passing LineCollection " "arguments other than the first, 'segments', as positional " "arguments is deprecated, and they will become keyword-only " diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 26579aaf8671..b92cf402a837 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -17,8 +17,8 @@ import matplotlib import matplotlib as mpl -from matplotlib.testing.decorators import ( - image_comparison, check_figures_equal, remove_ticks_and_titles) +from matplotlib import rc_context +from matplotlib._api import MatplotlibDeprecationWarning import matplotlib.colors as mcolors import matplotlib.dates as mdates from matplotlib.figure import Figure @@ -32,8 +32,8 @@ import matplotlib.transforms as mtransforms from numpy.testing import ( assert_allclose, assert_array_equal, assert_array_almost_equal) -from matplotlib import rc_context -from matplotlib.cbook import MatplotlibDeprecationWarning +from matplotlib.testing.decorators import ( + image_comparison, check_figures_equal, remove_ticks_and_titles) # Note: Some test cases are run twice: once normally and once with labeled data # These two must be defined in the same test function or need to have diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index 9223d9f85c7d..b6e90887c3cc 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -7,7 +7,7 @@ import pytest from matplotlib import cbook, patheffects -from matplotlib.cbook import MatplotlibDeprecationWarning +from matplotlib._api import MatplotlibDeprecationWarning from matplotlib.figure import Figure from matplotlib.testing.decorators import check_figures_equal, image_comparison import matplotlib as mpl diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 001743006269..2f5a43f6fecc 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -10,12 +10,10 @@ from numpy.testing import assert_array_equal, assert_array_almost_equal -from matplotlib import cycler +from matplotlib import _api, cbook, cm, cycler import matplotlib import matplotlib.colors as mcolors -import matplotlib.cm as cm import matplotlib.colorbar as mcolorbar -import matplotlib.cbook as cbook import matplotlib.pyplot as plt import matplotlib.scale as mscale from matplotlib.testing.decorators import image_comparison, check_figures_equal @@ -109,7 +107,7 @@ def test_colormap_global_set_warn(): new_cm = plt.get_cmap('viridis') # Store the old value so we don't override the state later on. orig_cmap = copy.copy(new_cm) - with pytest.warns(cbook.MatplotlibDeprecationWarning, + with pytest.warns(_api.MatplotlibDeprecationWarning, match="You are modifying the state of a globally"): # This should warn now because we've modified the global state new_cm.set_under('k') @@ -120,7 +118,7 @@ def test_colormap_global_set_warn(): # Test that registering and then modifying warns plt.register_cmap(name='test_cm', cmap=copy.copy(orig_cmap)) new_cm = plt.get_cmap('test_cm') - with pytest.warns(cbook.MatplotlibDeprecationWarning, + with pytest.warns(_api.MatplotlibDeprecationWarning, match="You are modifying the state of a globally"): # This should warn now because we've modified the global state new_cm.set_under('k') @@ -132,11 +130,11 @@ def test_colormap_global_set_warn(): def test_colormap_dict_deprecate(): # Make sure we warn on get and set access into cmap_d - with pytest.warns(cbook.MatplotlibDeprecationWarning, + with pytest.warns(_api.MatplotlibDeprecationWarning, match="The global colormaps dictionary is no longer"): cmap = plt.cm.cmap_d['viridis'] - with pytest.warns(cbook.MatplotlibDeprecationWarning, + with pytest.warns(_api.MatplotlibDeprecationWarning, match="The global colormaps dictionary is no longer"): plt.cm.cmap_d['test'] = cmap diff --git a/lib/matplotlib/tests/test_pyplot.py b/lib/matplotlib/tests/test_pyplot.py index 718e64755476..25c52ae9967c 100644 --- a/lib/matplotlib/tests/test_pyplot.py +++ b/lib/matplotlib/tests/test_pyplot.py @@ -8,7 +8,7 @@ import matplotlib as mpl from matplotlib import pyplot as plt -from matplotlib.cbook import MatplotlibDeprecationWarning +from matplotlib._api import MatplotlibDeprecationWarning def test_pyplot_up_to_date(tmpdir):
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: