From 0334c9489a5cc38f83e279ccc2bfcffb587bd02b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 29 Sep 2023 12:03:35 +0200 Subject: [PATCH] Move papersize="auto" deprecation to backend_bases. This makes it easier for mplcairo (which also outputs PostScript natively) to inherit the deprecation and be able to run the matplotlib test suite both with matplotlib 3.7 (where there should be no warning) and with matplotlib 3.8 (where there should be a warning). --- 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 c07ad692451e..54e974991854 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2105,6 +2105,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 b59c571809d1..8d09fc1fe733 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -867,9 +867,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': @@ -1053,9 +1050,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]