Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Move required_interactive_framework to canvas class.#14521

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ivanov merged 1 commit intomatplotlib:masterfromanntzer:rif
Aug 19, 2019

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedJun 10, 2019
edited
Loading

In mpl 3.0, the required_interactive_framework attribute was added to
backend modules. However, it is sometimes required to access it from a
canvasinstance (e.g. in _fix_ipython_backend2gui), but the pattern
sys.modules[cls.__module__].required_interactive_framework is brittle
(e.g. it is broken by third-party subclasses).

Instead it makes more sense to put the attribute on the canvas class;
one can easily and robustly go from the backend module to the canvas
class by accessing the FigureCanvas attribute.

xrefhttps://gitter.im/matplotlib/matplotlib?at=5ced522cef853135c83ae7d6,#14426.

Milestoned as 3.2 as the API is still quite new so the earlier we fix it, the better.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 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

In mpl 3.0, the required_interactive_framework attribute was added tobackend modules.  However, it is sometimes required to access it from acanvas *instance* (e.g. in _fix_ipython_backend2gui), but the pattern`sys.modules[cls.__module__].required_interactive_framework` is brittle(e.g. it is broken by third-party subclasses).Instead it makes more sense to put the attribute on the canvas class;one can easily and robustly go from the backend module to the canvasclass by accessing the FigureCanvas attribute.
@tacaswell
Copy link
Member

Should we leave it in both places? That doesn't break any API but it does risk them getting out of sync. Other than than 👍.

Unfortunately, module level__getattr__ is py37+ ...

@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelJun 15, 2019
@anntzer
Copy link
ContributorAuthor

Assuming we want to make it easier to define 3rd-party backends, requiring to have it only in a single place is clearly better...

@tacaswell
Copy link
Member

Do we have any guess on how many people we are going to break with this? Trying to search for the use of this, it seems a zillion people have put up repos which include their virtual environments (https://github.com/search?q=required_interactive_framework&type=Code fromhttps://github.com/search?l=Python&q=class+_BackendQT4Agg%28_BackendQT5Agg%29%3A&type=Code it looks like there are 3k+ vendored versions of mpl on github that is .... something...).

The problem with this is API change is that there is (currently) no clean way to warn it and it is an immediateAttributeError. I don't think it is worth the effort of making this even more complicated by sub-classingModule, so for now just export it from theCanvas to the module and in the future use module__getattr__ to either make it a mirror or deprecate it.

Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

I have reservations about removingrequired_interactive_framework at the module level. Enough to not "approve", but not enough to block merging.

@anntzer
Copy link
ContributorAuthor

required_interactive_framework is very recent: it was only added in 3.0 (in#11520), so September 2018. Most likely, it is only used by people writing cross-backend code, so likely libraries; but how many people are there writing libraries that already require mpl3.0+? It is also quite difficult to use correctly right now (as seen by the dance withcls.__module__ that this removes, which does not even handle subclasses correctly).

Currently you have milestoned 3.2 for September 2019, so let's assume it will come out at some point before the end of the year. Py3.6 was released late december 2019 so 3.2 will almost certainly still support it, so we wouldn't be able to put in a proper deprecation before mpl3.3 at the earliest (say by mid-to-early 2020), which means the attribute will have another 6-9 months to pick up more users who will be affected by its removal.

In other words the choice is between affecting a smaller number of users right now, and a potentially larger number next year.

@tacaswell
Copy link
Member

I am convinced that this is likely not actually used and safe to pull the band-aid off.

@ivanovivanov merged commit8fad359 intomatplotlib:masterAug 19, 2019
@anntzeranntzer deleted the rif branchAugust 19, 2019 19:28
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v3.2.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@tacaswell@ivanov

[8]ページ先頭

©2009-2025 Movatter.jp