Skip to content
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

Consider deprecating return_callback feature of register_type #543

Open
tlambert03 opened this issue Mar 7, 2023 · 2 comments
Open

Consider deprecating return_callback feature of register_type #543

tlambert03 opened this issue Mar 7, 2023 · 2 comments

Comments

@tlambert03
Copy link
Member

tlambert03 commented Mar 7, 2023

In retrospect, I think the return_callback option to register_type was probably an overreach of scope for magicgui in the first place. While it definitely allows some cool behavior in napari, this sort of magical processing of the return value seems better suited to in-n-out, or perhaps implemented directly in napari for this specific use case of adding something to the viewer with a callback connection:

# napari instantiates the widget somewhere
wdg = some_factory()

# connect callback:
if satisfies_some_condition(wdg.return_annotation):
    wdg.called.connect(_mgui.add_layer_data_to_viewer)

# add it to the viewer
viewer.window.add_dock_widget(wdg)

that will definitely require a gradual deprecation, but as I think about the complexities of processing return annotation types (e.g. do we support subtypes? etc...) i think it's probably better to remove that feature rather than elaborate upon it

Originally posted by @tlambert03 in #541 (comment)

@Czaki
Copy link
Contributor

Czaki commented Mar 7, 2023

I have strong worries that many people outside napari may depend on this magic. Maybe some of us should try to search GitHub against the usage of return_callback. As it allows to split implementation of the function with handling its output in one line of user code.

@tlambert03
Copy link
Member Author

I have strong worries that many people outside napari may depend on this magic

yep, if this happens at all, it absolutely won't happen "quickly". It would be a multi-version deprecation warning, with a clear alternative. From a quick search, I can only find napari and magic-class using the return_callback argument to register_type.

cc @hanjinliu

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

No branches or pull requests

2 participants