datalad / datalad-gooey

A graphical user interface for DataLad (datalad.org)
https://docs.datalad.org/projects/gooey
Other
4 stars 6 forks source link

More accurate handling of `nargs=*|+` #363

Closed mih closed 1 year ago

mih commented 1 year ago

This is a three part change:

(1) parameters with nargs=* or nargs=+ take a sequence of values. However, datalad is (almost?) universally implemented to also accept a single item in such cases. Internally values are fed to EnsureList() rather than exposing this fact as a proper constraint. Here we turn such nargs settings in an explicit

EnsureIterableOf(list, constraint) | constraint

alternative constrain specification.

(2) The first change makes it necessary to avoid duplicating parameter input widgets in such cases, because MultiValueWidget is capable of accepting a single item, making a dedicated single item input for the exact same data type superfluous (and ugly). Here we look for this case when generating input widgets, and we discard the single-item input in favor of the multi-value input.

(3) Both changes combined make it possible for MultiValueWidget to stop bypassing a parameter constraint, and actuall "set" values properly, rather then merely showing them in the input widget.