-
Notifications
You must be signed in to change notification settings - Fork 53
feat: Register all types in a Union when passed to return_callback #544
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
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #544 +/- ##
==========================================
+ Coverage 89.66% 89.75% +0.09%
==========================================
Files 37 37
Lines 4423 4433 +10
==========================================
+ Hits 3966 3979 +13
+ Misses 457 454 -3
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
|
cc @Czaki, if you have a moment to review, this implements option 3 from #541 (comment) |
Czaki
left a comment
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 not see documentation update, but I assume that it is connected with plan to remove return callback?
Also, in the context of napari:
Currently problem is solved in this way (main only, not released):
https://github.com/napari/napari/blob/9e911040148d232b76d768ed74ff90ac0fa6f707/napari/types.py#L145
https://github.com/napari/napari/blob/9e911040148d232b76d768ed74ff90ac0fa6f707/napari/types.py#L158
But code in magicgui does not contain deduplication of callbacks.
So I understand that After merging it there should be added if to napari codebase to check it depends on the magicgui version?
yeah, I can do that PR if you'd like? |
|
updated the docs a bit. thanks for the review @Czaki ! |
this is a good point... but i think in most cases it's going to be fine (the second one will overwrite the first one). let me double check that for you |
Yes and the whole recalculation of all attributes and double transfer to GPU memory of layer data? |
no, I don't mean the second "layer" will overwrite the first "layer", I mean the second registered callback will overwrite the first registered callback (in the type2callback map) and only a single one will actually be called at runtime |
|
buuut nope... it gets called twice. will fix |
part of a fix to #541, this makes it so that when you use
register_type(Union[...], return_callback=...), then you effectively register the callback for functions that return either the union or any type within the Union (not just the actual union object itself)