Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate NavigationToolbar2._init_toolbar. #17111

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

Merged
merged 1 commit into from
Apr 30, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Apr 12, 2020

As argued elsewhere, a customization point which requires third-party
libraries to override a private method is awkward from the PoV of
documentation and of required API stability. In fact _init_toolbar is
not needed as a customization point; third-party libraries can simply
override __init__ and call super().__init__ as appropriate.

Moreover, requiring that _init_toolbar be overridden is actually
overkill, e.g. for test_backend_bases.py::test_interactive_zoom:
there, the base class NavigationToolbar2 is perfectly suitable -- see
change there.

In order to let third-parties write code that supports both pre- and
post-deprecation versions of mpl, allow them to keep a fully empty
_init_toolbar (an override is required by earlier versions of mpl)
without triggering a deprecation warning.


Note that git(hub) may show the diff a bit weirdly, but for the GUI backend implementations, this is basically just moving the body of _init_toolbar into __init__ (it's just that git instead shows that as the code between __init__ and _init_toolbar moving down.)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.3.0 milestone Apr 12, 2020
@anntzer
Copy link
Contributor Author

anntzer commented Apr 20, 2020

rebased

As argued elsewhere, a customization point which requires third-party
libraries to override a private method is awkward from the PoV of
documentation and of required API stability.  In fact _init_toolbar is
not needed as a customization point; third-party libraries can simply
override `__init__` and call `super().__init__` as appropriate.

Moreover, *requiring* that `_init_toolbar` be overridden is actually
overkill, e.g. for `test_backend_bases.py::test_interactive_zoom`:
there, the base class NavigationToolbar2 is perfectly suitable -- see
change there.

In order to let third-parties write code that supports both pre- and
post-deprecation versions of mpl, allow them to keep a fully empty
`_init_toolbar` (an override is required by earlier versions of mpl)
without triggering a deprecation warning.
@anntzer
Copy link
Contributor Author

anntzer commented Apr 29, 2020

Rebased to take advantage of the new _deprecate_method_override.

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to make an extra effort to get many testers in case there is something subtle broken here.

@tacaswell tacaswell merged commit 200380e into matplotlib:master Apr 30, 2020
@anntzer anntzer deleted the init_toolbar branch April 30, 2020 20:33
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