Skip to content

Commit 7e92025

Browse files
committed
MNT: Deprecate rcParams._get("backend")
since 3.10 we have the official API `matplotlib.get_backend (auto_select=False)`. No problems have been reported and matplotlib-inline is using it https://github .com/ipython/matplotlib-inline/pull/38. Therefore, I remove the provisional status from the auto-select flag. Additionally, I deprecate the API rcParams._get('backend'), which the above is replacing. It seems that `rcParams._get("backend")` is not used anywhere publically, but let's still be defensive and deprecate. https://github.com/search?q=%2F%5C._get%5C%28%5B%22%27%5Dbackend%5B%22%27%5D%5C%29%2F+language%3APython+NOT+is%3Afork+NOT+path%3A**%2Fmatplotlib%2F**+NOT+path%3A**%2Fsite-packages**+NOT+path%3A**%2Fpyplot.py&type=code This is working towards matplotlib#26406. Follow-up to matplotlib#29039.
1 parent a5cc230 commit 7e92025

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
``rcParams._get("backend")``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
``rcParams._get("backend")`` is deprecated. Instead, use the public API
5+
``matplotlib.get_backend(auto_select=False)`` to retrieve the current
6+
backend without triggering backend resolution. This API is available since
7+
Matplotlib 3.10.

lib/matplotlib/__init__.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ def _get(self, key):
712712
713713
:meta public:
714714
"""
715+
if key == "backend":
716+
_api.warn_deprecated(
717+
"rcParams._get('backend') is deprecated since Matplotlib 3.11. "
718+
"Use matplotlib.get_backend(auto_select=False) instead, which is "
719+
"available since Matplotlib 3.10.",
720+
)
715721
return dict.__getitem__(self, key)
716722

717723
def _update_raw(self, other_params):
@@ -1278,23 +1284,14 @@ def get_backend(*, auto_select=True):
12781284
12791285
.. versionadded:: 3.10
12801286
1281-
.. admonition:: Provisional
1282-
1283-
The *auto_select* flag is provisional. It may be changed or removed
1284-
without prior warning.
1285-
12861287
See Also
12871288
--------
12881289
matplotlib.use
12891290
"""
12901291
if auto_select:
12911292
return rcParams['backend']
12921293
else:
1293-
backend = rcParams._get('backend')
1294-
if backend is rcsetup._auto_backend_sentinel:
1295-
return None
1296-
else:
1297-
return backend
1294+
return rcParams._get_backend_or_none()
12981295

12991296

13001297
def interactive(b):

0 commit comments

Comments
 (0)