8000 Merge pull request #19151 from timhoffm/change-deprecated-usage · matplotlib/matplotlib@99e6240 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99e6240

Browse files
authored
Merge pull request #19151 from timhoffm/change-deprecated-usage
Deprecate @cbook.deprecated and move internal calls to @_api.deprecated
2 parents 3798e5f + fa71a21 commit 99e6240

File tree

17 files changed

+64
-57
lines changed

17 files changed

+64
-57
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def __init__(self, default_font_prop, mathtext_backend=None):
795795
self.fonts['default'] = default_font
796796
self.fonts['regular'] = default_font
797797

798-
pswriter = cbook.deprecated("3.4")(property(lambda self: StringIO()))
798+
pswriter = _api.deprecated("3.4")(property(lambda self: StringIO()))
799799

800800
def _get_font(self, font):
801801
if font in self.fontmap:
@@ -1549,7 +1549,7 @@ class Glue(Node):
15491549
it's easier to stick to what TeX does.)
15501550
"""
15511551

1552-
glue_subtype = cbook.deprecated("3.3")(property(lambda self: "normal"))
1552+
glue_subtype = _api.deprecated("3.3")(property(lambda self: "normal"))
15531553

15541554
@_api.delete_parameter("3.3", "copy")
15551555
def __init__(self, glue_type, copy=False):

lib/matplotlib/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class HTMLWriter(FileMovieWriter):
795795
"""Writer for JavaScript-based HTML movies."""
796796

797797
supported_formats = ['png', 'jpeg', 'tiff', 'svg']
798-
args_key = cbook.deprecated("3.3")(property(
798+
args_key = _api.deprecated("3.3")(property(
799799
lambda self: 'animation.html_args'))
800800

801801
@classmethod

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ class FigureManagerBase:
27102710
figure.canvas.manager.button_press_handler_id)
27112711
"""
27122712

2713-
statusbar = cbook.deprecated("3.3")(property(lambda self: None))
2713+
statusbar = _api.deprecated("3.3")(property(lambda self: None))
27142714

27152715
def __init__(self, canvas, num):
27162716
self.canvas = canvas

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import functools
66

77
import matplotlib as mpl
8+
from matplotlib import _api
89
from .. import font_manager, ft2font
910
from ..afm import AFM
1011
from ..backend_bases import RendererBase
@@ -27,7 +28,7 @@ class CharacterTracker:
2728
def __init__(self):
2829
self.used = {}
2930

30-
@mpl.cbook.deprecated("3.3")
31+
@_api.deprecated("3.3")
3132
@property
3233
def used_characters(self):
3334
d = {}

lib/matplotlib/backends/backend_cairo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ def attr(field):
121121

122122

123123
class RendererCairo(RendererBase):
124-
fontweights = cbook.deprecated("3.3")(property(lambda self: {*_f_weights}))
125-
fontangles = cbook.deprecated("3.3")(property(lambda self: {*_f_angles}))
126-
mathtext_parser = cbook.deprecated("3.4")(
124+
fontweights = _api.deprecated("3.3")(property(lambda self: {*_f_weights}))
125+
fontangles = _api.deprecated("3.3")(property(lambda self: {*_f_angles}))
126+
mathtext_parser = _api.deprecated("3.4")(
127127
property(lambda self: MathTextParser('Cairo')))
128128

129129
def __init__(self, dpi):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def resize(self, width, height):
432432

433433

434434
class NavigationToolbar2GTK3(NavigationToolbar2, Gtk.Toolbar):
435-
ctx = cbook.deprecated("3.3")(property(
435+
ctx = _api.deprecated("3.3")(property(
436436
lambda self: self.canvas.get_property("window").cairo_create()))
437437

438438
def __init__(self, canvas, window):

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ class PdfPages:
932932
'_info_dict',
933933
'_metadata',
934934
)
935-
metadata = cbook.deprecated('3.3')(property(lambda self: self._metadata))
935+
metadata = _api.deprecated('3.3')(property(lambda self: self._metadata))
936936

937937
def __init__(self, filename, *, keep_empty=True, metadata=None):
938938
"""

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ class RendererPS(_backend_pdf_ps.RendererPDFPSBase):
223223
_afm_font_dir = cbook._get_data_path("fonts/afm")
224224
_use_afm_rc_name = "ps.useafm"
225225

226-
mathtext_parser = cbook.deprecated("3.4")(property(
226+
mathtext_parser = _api.deprecated("3.4")(property(
227227
lambda self: MathTextParser("PS")))
228-
used_characters = cbook.deprecated("3.3")(property(
228+
used_characters = _api.deprecated("3.3")(property(
229229
lambda self: self._character_tracker.used_characters))
230230

231231
def __init__(self, width, height, pswriter, imagedpi=72):

lib/matplotlib/backends/qt_compat.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919

2020
import matplotlib as mpl
21+
from matplotlib import _api
2122

2223

2324
QT_API_PYQT5 = "PyQt5"
@@ -87,7 +88,7 @@ def _isdeleted(obj): return not shiboken2.isValid(obj)
8788
raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
8889
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
8990

90-
@mpl.cbook.deprecated("3.3", alternative="QtCore.qVersion()")
91+
@_api.deprecated("3.3", alternative="QtCore.qVersion()")
9192
def is_pyqt5():
9293
return True
9394

@@ -143,7 +144,7 @@ def _isdeleted(obj): return not shiboken.isValid(obj)
143144
raise ValueError("Unexpected value for the 'backend.qt4' rcparam")
144145
QtWidgets = QtGui
145146

146-
@mpl.cbook.deprecated("3.3", alternative="QtCore.qVersion()")
147+
@_api.deprecated("3.3", alternative="QtCore.qVersion()")
147148
def is_pyqt5():
148149
return False
149150

lib/matplotlib/cbook/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
import matplotlib
3131
from matplotlib import _api, _c_internal_utils
3232
from matplotlib._api.deprecation import (
33-
deprecated, warn_deprecated, MatplotlibDeprecationWarning, mplDeprecation)
33+
warn_deprecated, MatplotlibDeprecationWarning, mplDeprecation)
34+
35+
36+
@_api.deprecated("3.4")
37+
def deprecated(*args, **kwargs):
38+
return _api.deprecated(*args, **kwargs)
3439

3540

3641
def _get_running_interactive_framework():
@@ -287,7 +292,7 @@ def __repr__(self):
287292
return "<an empty list>"
288293

289294

290-
@deprecated("3.3")
295+
@_api.deprecated("3.3")
291296
class IgnoredKeywordWarning(UserWarning):
292297
"""
293298
A class for issuing warnings about keyword arguments that will be ignored
@@ -296,7 +301,7 @@ class IgnoredKeywordWarning(UserWarning):
296301
pass
297302

298303

299-
@deprecated("3.3", alternative="normalize_kwargs")
304+
@_api.deprecated("3.3", alternative="normalize_kwargs")
300305
def local_over_kwdict(local_var, kwargs, *keys):
301306
"""
302307
Enforces the priority of a local variable over potentially conflicting
@@ -532,7 +537,7 @@ def flatten(seq, scalarp=is_scalar_or_string):
532537
yield from flatten(item, scalarp)
533538

534539

535-
@deprecated("3.3", alternative="os.path.realpath and os.stat")
540+
@_api.deprecated("3.3", alternative="os.path.realpath and os.stat")
536541
@functools.lru_cache()
537542
def get_realpath_and_stat(path):
538543
realpath = os.path.realpath(path)

0 commit comments

Comments
 (0)
0