◐ Shell
reader mode source ↗
Skip to content

MNT: Add provisional get_backend(resolve=False) flag#29039

Merged
tacaswell merged 1 commit into
matplotlib:mainfrom
timhoffm:get_backend
Oct 30, 2024
Merged

MNT: Add provisional get_backend(resolve=False) flag#29039
tacaswell merged 1 commit into
matplotlib:mainfrom
timhoffm:get_backend

Conversation

@timhoffm

@timhoffm timhoffm commented Oct 29, 2024

Copy link
Copy Markdown
Member

The default is resolve=True for now, so that it is completely backward-compatible.

The provisional introduction anticipates planned changes for the backend resolution (#26406 (comment)).

If all plays out as intended, this prolongs the range of releases for the migration: If we start deprecating rcParams._get("backend") say in 3.11, people can immediately switch to get_backend(resolve=False) and their code still runs on 3.10 without version gating.
The worst that can happen is that the introduced flag was not helpful and we remove it again, which is easy because it's provisional.

On a side-note: This also helps with a possible future default change from resolve=True to resolve=False. By making the flag available, users can choose the behavior explicitly, again without (or with lesser version gating) if they don't want to be affected by a default change.

@timhoffm timhoffm added this to the v3.10.0 milestone Oct 29, 2024
@timhoffm timhoffm force-pushed the get_backend branch 6 times, most recently from 25482d5 to 9640a95 Compare October 29, 2024 16:38
@timhoffm timhoffm force-pushed the get_backend branch 2 times, most recently from fcdf522 to d29e8b5 Compare October 29, 2024 21:28
The default is `resolve=True` for now, so that this introduction
is completely backward-compatible.

The provisional introduction anticipates planned changes for the
backend resolution (matplotlib#26406 (comment)).

If all plays out as intended, this prolongs the range of releases
for the migration: If we start deprecating `rcParams._get("backend")` say in 3.11, people can immediately switch to
`get_backend(resolve=False)` and their code still runs on 3.10
without version gating.
The worst that can happen is that the introduced flag was not
helpful and we remove it again, which is easy because it's provisional.
@tacaswell tacaswell merged commit 218a42b into matplotlib:main Oct 30, 2024
@timhoffm timhoffm deleted the get_backend branch October 30, 2024 15:46
@timhoffm

Copy link
Copy Markdown
Member Author

Note: I've intentionally not added a what's new note. People can start using this, but it's not my ambition to already push them this way by advertising the new API. As written above, this is mainly in 3.10 so that there are less version-gating issues when the API gets formally introduced in 3.11.

timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Jan 14, 2026
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.
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Jan 14, 2026
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.
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Jan 14, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants