-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
MNT: Deprecate rcParams._get("backend") #30963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
timhoffm
wants to merge
1
commit into
matplotlib:main
Choose a base branch
from
timhoffm:deprecate-_get_backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21
−12
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ``rcParams._get("backend")`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| ``rcParams._get("backend")`` is deprecated. Instead, use the public API | ||
| ``matplotlib.get_backend(auto_select=False)`` to retrieve the current | ||
| backend without triggering backend resolution. This API is available since | ||
| Matplotlib 3.10. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -712,6 +712,14 @@ def _get(self, key): | |
|
|
||
| :meta public: | ||
| """ | ||
| if key == "backend": | ||
| _api.warn_deprecated( | ||
| "rcParams._get('backend') is deprecated since Matplotlib 3.11. " | ||
| "Use matplotlib.get_backend(auto_select=False) instead, which is " | ||
| "available since Matplotlib 3.10.", | ||
| ) | ||
| # TODO: When removing this, also remove the suppression context in | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is "this"? The comment is in an odd spot to decide if it's the |
||
| # RcParams.copy | ||
| return dict.__getitem__(self, key) | ||
|
|
||
| def _update_raw(self, other_params): | ||
|
|
@@ -813,8 +821,11 @@ def find_all(self, pattern): | |
| def copy(self): | ||
| """Copy this RcParams instance.""" | ||
| rccopy = self.__class__() | ||
| for k in self: # Skip deprecations and revalidation. | ||
| rccopy._set(k, self._get(k)) | ||
| with _api.suppress_matplotlib_deprecation_warning(): | ||
| # the suppression context is specifically for _get("backend"). This | ||
| # can be removed again, when "backend" is not a valid rcParam anymore. | ||
| for k in self: # Skip deprecations and revalidation. | ||
| rccopy._set(k, self._get(k)) | ||
| return rccopy | ||
|
|
||
|
|
||
|
|
@@ -1278,23 +1289,14 @@ def get_backend(*, auto_select=True): | |
|
|
||
| .. versionadded:: 3.10 | ||
|
|
||
| .. admonition:: Provisional | ||
|
|
||
| The *auto_select* flag is provisional. It may be changed or removed | ||
| without prior warning. | ||
|
|
||
| See Also | ||
| -------- | ||
| matplotlib.use | ||
| """ | ||
| if auto_select: | ||
| return rcParams['backend'] | ||
| else: | ||
| backend = rcParams._get('backend') | ||
| if backend is rcsetup._auto_backend_sentinel: | ||
| return None | ||
| else: | ||
| return backend | ||
| return rcParams._get_backend_or_none() | ||
|
|
||
|
|
||
| def interactive(b): | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first arg is
since, not the fullmessage.