magicgui icon indicating copy to clipboard operation
magicgui copied to clipboard

Decide how to deal with empty string vs None

Open tlambert03 opened this issue 5 years ago • 2 comments

When generating a magicgui for skimage.filters.sato, because we don't yet try to parse docstrings for "choices" in a dropdown menu, the "mode" parameter is rendered as a plain text edit. If the user doesn't enter anything, then it gets delivered to the function as the empty string instead of None, and skimage raises RuntimeError: boundary mode not supported. We could have the standard setter convert the empty string to None ... but then the empty string is inaccessible as a value...

tlambert03 avatar Jul 13 '20 20:07 tlambert03

How do you know that it should be a string in this case? Why wouldn't it fall back to literal_eval?

jni avatar Jul 14 '20 09:07 jni

Oh that’s a good point. The reason is that the current behavior for a non-annotated argument like mode was to already use a LineEdit (but not the literal eval one). Whereas the literal eval was enabled when we DO know the type (perhaps based on the default value), but we don’t have a widget for it. (Like tuple at the moment). But maybe you’re right, we should make it a literal eval field

tlambert03 avatar Jul 14 '20 09:07 tlambert03

"nullable" ValueWidgets have been doing ok i think. while there might still be something to consider here, it hasn't come up in a long time. closing

tlambert03 avatar Oct 23 '22 13:10 tlambert03