-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add plugin_manager
module for global singleton convenience
#164
Conversation
Codecov Report
@@ Coverage Diff @@
## main #164 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 26 27 +1
Lines 1730 1770 +40
=========================================
+ Hits 1730 1770 +40
Continue to review full report at Codecov.
|
I'm not a big fan of using |
I'm not married to |
root namespace scares me too 👻 |
Will merge this tommorrow with new module name. Unless @nclack you think we shouldn’t have it at all? (You never commented on that) |
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.
I do like the idea of the global plugin_manager
instance.
@@ -471,9 +484,17 @@ def iter_compatible_readers( | |||
def iter_compatible_writers( | |||
self, layer_types: Sequence[str] | |||
) -> Iterator[WriterContribution]: | |||
"""Iterate over compatible WriterContributions given a sequence of layer_types. |
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.
love all the improved docstrings!
pm
module for global singleton convenience plugin_manager
module for global singleton convenience
Inspired by some conversations with @kne42 at the hackathon, this PR adds a new module that serves as a convenience for accessing public methods on the global
PluginManager.instance()
singleton.Everything is lazy, so importing the module does nothing to instantiate the singleton. I avoided fully autogenerating the module so as to retain type hinting and basic docs (though the full docstrings with parameters will remain in the actual PluginManager methods).
This would make a lot of the lines in
napari/plugins/_npe2.py
and elsewhere simpler. for example:The only downside is that the
pm.py
module needs to be kept manually updated (but there's a test to let us know when we need to).thoughts @kne42, @nclack?