From ed7089701c4ab589e18a3fab1e09b1153aa9eeab Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Mon, 2 Oct 2023 16:01:09 -0500 Subject: [PATCH] Backport PR #26959: Move papersize="auto" deprecation to backend_bases. --- lib/matplotlib/backend_bases.py | 6 ++++++ lib/matplotlib/backends/backend_ps.py | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 9c7fa97d23b6..958b6e0e1c21 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2123,6 +2123,12 @@ def print_figure( if dpi == 'figure': dpi = getattr(self.figure, '_original_dpi', self.figure.dpi) + if kwargs.get("papertype") == 'auto': + # When deprecation elapses, remove backend_ps._get_papertype & its callers. + _api.warn_deprecated( + "3.8", name="papertype='auto'", addendum="Pass an explicit paper type, " + "'figure', or omit the *papertype* argument entirely.") + # Remove the figure manager, if any, to avoid resizing the GUI widget. with cbook._setattr_cm(self, manager=None), \ self._switch_canvas_and_return_print_method(format, backend) \ diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index a757bcf8d3be..2f9faa0ef6da 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -872,9 +872,6 @@ def _print_figure( # find the appropriate papertype width, height = self.figure.get_size_inches() if papertype == 'auto': - _api.warn_deprecated("3.8", name="papertype='auto'", - addendum="Pass an explicit paper type, 'figure', or " - "omit the *papertype* argument entirely.") papertype = _get_papertype(*orientation.swap_if_landscape((width, height))) if is_eps or papertype == 'figure': @@ -1058,9 +1055,6 @@ def _print_figure_tex( self.figure.get_size_inches()) else: if papertype == 'auto': - _api.warn_deprecated("3.8", name="papertype='auto'", - addendum="Pass an explicit paper type, or " - "omit the *papertype* argument entirely.") papertype = _get_papertype(width, height) paper_width, paper_height = papersize[papertype]