Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8549a5b

Browse filesBrowse files
committed
FIX: re-jigger deprecation of rcParams using machinery in __init__
1 parent 5ee9553 commit 8549a5b
Copy full SHA for 8549a5b

File tree

Expand file treeCollapse file tree

4 files changed

+27
-21
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+27
-21
lines changed

‎doc/api/api_changes/2018-02-04-AL.rst

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Deprecation of qt binding rcparams
2+
``````````````````````````````````
3+
4+
The :rc:`backend.qt4` and :rc:`backend.qt5` rcParams were deprecated
5+
in version 2.2. In order to force the use of a specific Qt binding,
6+
either import that binding first, or set the ``QT_API`` environment
7+
variable.

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+14-3Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,10 @@ def gen_candidates():
848848
_obsolete_set = {'plugins.directory', 'text.dvipnghack'}
849849

850850
# The following may use a value of None to suppress the warning.
851-
_deprecated_set = {'axes.hold'} # do NOT include in _all_deprecated
851+
# do NOT include in _all_deprecated
852+
_deprecated_set = {'axes.hold',
853+
'backend.qt4',
854+
'backend.qt5'}
852855

853856
_all_deprecated = set(itertools.chain(
854857
_deprecated_ignore_map, _deprecated_map, _obsolete_set))
@@ -872,6 +875,10 @@ class RcParams(MutableMapping, dict):
872875
msg_depr_ignore = "%s is deprecated and ignored. Use %s instead."
873876
msg_obsolete = ("%s is obsolete. Please remove it from your matplotlibrc "
874877
"and/or style files.")
878+
msg_backend_obsolete = ("The {} rcParam was deprecated in version 2.2. In"
879+
" order to force the use of a specific Qt binding,"
880+
" either import that binding first, or set the "
881+
"QT_API environment variable.")
875882

876883
# validate values on the way in
877884
def __init__(self, *args, **kwargs):
@@ -886,8 +893,12 @@ def __setitem__(self, key, val):
886893
key = alt_key
887894
val = alt_val(val)
888895
elif key in _deprecated_set and val is not None:
889-
warnings.warn(self.msg_depr_set % key,
890-
mplDeprecation)
896+
if key.startswith('backend'):
897+
warnings.warn(self.msg_backend_obsolete.format(key),
898+
mplDeprecation)
899+
else:
900+
warnings.warn(self.msg_depr_set % key,
901+
mplDeprecation)
891902
elif key in _deprecated_ignore_map:
892903
alt = _deprecated_ignore_map[key]
893904
warnings.warn(self.msg_depr_ignore % (key, alt),

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@
8383
if QT_API is None:
8484
# No ETS environment or incompatible so use rcParams.
8585
if rcParams['backend'] == 'Qt5Agg':
86-
QT_API = rcParams['backend.qt5']
86+
QT_API = QT_API_PYQT5
8787
elif rcParams['backend'] == 'Qt4Agg':
88-
QT_API = rcParams['backend.qt4']
88+
QT_API = QT_API_PYQT
8989
else:
9090
# A non-Qt backend was specified, no version of the Qt
9191
# bindings is imported, but we still got here because a Qt
9292
# related file was imported. This is allowed, fall back to Qt5
9393
# using which ever binding the rparams ask for.
9494
_fallback_to_qt4 = True
95-
QT_API = rcParams['backend.qt5']
95+
QT_API = QT_API_PYQT5
9696

9797
# We will define an appropriate wrapper for the differing versions
9898
# of file dialog.
@@ -142,7 +142,7 @@
142142
except ImportError:
143143
if _fallback_to_qt4:
144144
# fell through, tried PyQt5, failed fall back to PyQt4
145-
QT_API = rcParams['backend.qt4']
145+
QT_API = QT_API_PYQT
146146
QT_RC_MAJOR_VERSION = 4
147147
else:
148148
raise

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+2-14Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -268,25 +268,13 @@ def validate_backend(s):
268268

269269
def validate_qt4(s):
270270
if s is None:
271-
# return a reasonable default for deprecation period
272-
return 'PyQt4'
273-
cbook.warn_deprecated(
274-
"2.2",
275-
"The backend.qt4 rcParam was deprecated in version 2.2. In order "
276-
"to force the use of a specific Qt4 binding, either import that "
277-
"binding first, or set the QT_API environment variable.")
271+
return None
278272
return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s)
279273

280274

281275
def validate_qt5(s):
282276
if s is None:
283-
# return a reasonable default for deprecation period
284-
return 'PyQt5'
285-
cbook.warn_deprecated(
286-
"2.2",
287-
"The backend.qt5 rcParam was deprecated in version 2.2. In order "
288-
"to force the use of a specific Qt5 binding, either import that "
289-
"binding first, or set the QT_API environment variable.")
277+
return None
290278
return ValidateInStrings("backend.qt5", ['PyQt5', 'PySide2'])(s)
291279

292280

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.