From 188a4af7a9b78c078704643438b56212bfd4e333 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 21 Jan 2018 16:09:38 -0800 Subject: [PATCH] Deprecate the backend.qt{4,5} rcParams. 1) For the rcParams rewrite (MEP32), they may make it tricky to transform rcParams into a nested dictionary type of object, as "backend" is already the name of another (more important) rcParam. This specific issue could be solved with deprecation + renaming, but also... 2) The use of these rcParams can easily be replaced by a) first importing one of the bindings (qt_compat will ensure that the already imported binding gets used, as importing multiple bindings in the same process is a bad idea anyways), or b) setting the QT_API environment variable appropriately. --- lib/matplotlib/__init__.py | 14 +++++++++----- lib/matplotlib/rcsetup.py | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index f97a8f39c755..f76b3465b27e 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1116,8 +1116,10 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True): return config_from_file iter_params = six.iteritems(defaultParams) - config = RcParams([(key, default) for key, (default, _) in iter_params - if key not in _all_deprecated]) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", mplDeprecation) + config = RcParams([(key, default) for key, (default, _) in iter_params + if key not in _all_deprecated]) config.update(config_from_file) if config['datapath'] is None: @@ -1155,9 +1157,11 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True): rcParamsOrig = rcParams.copy() -rcParamsDefault = RcParams([(key, default) for key, (default, converter) in - six.iteritems(defaultParams) - if key not in _all_deprecated]) +with warnings.catch_warnings(): + warnings.simplefilter("ignore", mplDeprecation) + rcParamsDefault = RcParams([(key, default) for key, (default, converter) in + six.iteritems(defaultParams) + if key not in _all_deprecated]) rcParams['ps.usedistiller'] = checkdep_ps_distiller( rcParams['ps.usedistiller']) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index eafc8d4eecf7..757747430271 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -266,8 +266,20 @@ def validate_backend(s): return _validate_standard_backends(s) -validate_qt4 = ValidateInStrings('backend.qt4', ['PyQt4', 'PySide', 'PyQt4v2']) -validate_qt5 = ValidateInStrings('backend.qt5', ['PyQt5', 'PySide2']) +@deprecated("2.2", + "The backend.qt4 rcParam was deprecated in version 2.2. In order " + "to force the use of a specific Qt4 binding, either import that " + "binding first, or set the QT_API environment variable.") +def validate_qt4(s): + return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s) + + +@deprecated("2.2", + "The backend.qt5 rcParam was deprecated in version 2.2. In order " + "to force the use of a specific Qt5 binding, either import that " + "binding first, or set the QT_API environment variable.") +def validate_qt5(s): + return ValidateInStrings("backend.qt5", ['PyQt5', 'PySide2'])(s) def validate_toolbar(s):