Skip to content

Prepare for rcParams.copy() returning a new RcParams instance in the future #21015

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

Closed
wants to merge 1 commit into from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 7, 2021

This would then allow
rcParams.update(<previously-copied-rcParams-instance>) to not emit
a deprecation warning (by checking the type of the input) even if the
copied RcParams instance contains a deprecated rc entry, because we'll
know that it will already have gone through the validator when being set
on the copied rcParams instance.

This is a proposed fix for (some use cases of) #13118/#15781/#20249, because looking at them and at linked issues from other repos, it looks like most relevant use cases are third-parties wanting to copy the state of all rcParams at a given point, and then later restore them (something like rc_context, but where __enter__ and __exit__ may be e.g. different functions). This PR would then (together with typechecking in RcParams.update) allow them to use the normal stashed_state = rcParams.copy(); <do whatever>; rcParams.update(stashed_state) even in the presence of deprecated rcParams. (Admittedly, the whole thing is a bit abstract right now because there are no deprecated rcParams currently.)

OTOH, perhaps a solution like this would also require #11509 being fixed first, because we wouldn't want assignments to the copied rcParams instance (not the global one) to affect the actual global state.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

…future.

This would then allow
`rcParams.update(<previously-copied-rcParams-instance>)` to *not* emit
a deprecation warning (by checking the type of the input) even if the
copied RcParams instance contains a deprecated rc entry, because we'll
know that it will already have gone through the validator when being set
on the copied rcParams instance.
@anntzer
Copy link
Contributor Author

anntzer commented Sep 9, 2021

Conclusion from the dev call is to directly make the transition without deprecation (once we know that there are no side effects in validators), as returning an RcParams instance is quite close to being compatible with a plain dict.

So I'll probably just make the full transition including the suppression of warnings when update()ing from a RcParams instance in this PR.

@anntzer
Copy link
Contributor Author

anntzer commented Sep 11, 2021

Superseded by #21042.

@anntzer anntzer closed this Sep 11, 2021
@anntzer anntzer deleted the rccopy branch September 11, 2021 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants