-
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 DynamicPlugin object/context for ease of testing & dynamic plugin creation #128
Conversation
Codecov Report
@@ Coverage Diff @@
## main #128 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 23 24 +1
Lines 1355 1483 +128
==========================================
+ Hits 1355 1483 +128
Continue to review full report at Codecov.
|
Co-authored-by: Nathan Clack <nclack@gmail.com>
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.
This is pretty interesting as a way of dynamically adding a plugin. I wonder if you think it'll be useful outside of testing?
I do! This PR started as a |
perhaps |
ok to merge if I change name to DynamicPlugin @nclack ? |
Yes. Meant to approve before anyway. |
was starting to work on some stuff over in napari/napari#4015 and realized we need a better way to inject temporary functionality into a test plugin manager. This adds a
DynamicPlugin
context manager that controls a manifest, and allows you to register commands with decorators:it will handle creation of a command, and the corresponding contribution type, and inject it into the plugin manifest and reindex. The decorator takes all the same parameters that the corresponding contribution would take:
it cleans up after itself when leaving the context
edit: this also modifies a small amount of logic on the unregistering/deactivation of plugins in general, specifically around unregistering their commands