Description
EDIT: As described in the comments below, there are at least three cases to cover/fix/check:
- Forbid
arg: Optional[str] = "something"
- Do not use
Union
in type hints - Do not user
Any
in type hints
I think that a task function with signature like
def function(x: Optional[str] = "something"):
pass
should not be present in our tasks, and that Optional
arguments should default to None
. This is not based on some solid knowledge, but I'm rather thinking that it may result into unexpected behavior depending on how we end up structuring the fractal-web task-arguments interface.
This is a placeholder issue, so that once we have a more stable fractal-web feature by @rkpasia we can stress-test it with one such example (as part of the "required vs optional arguments" review). If it's well supported, nothing to add. If it's not, then we should make sure (through a test) that we never include it here in this repository.
For the record, this issue happens exactly 0 times in the current code base, so that this is not a big deal.
$ git grep Optional | grep -v typing
cellpose_segmentation.py: anisotropy: Optional[float] = None,
cellpose_segmentation.py: label_dtype: Optional[np.dtype] = None,
cellpose_segmentation.py: wavelength_id: Optional[str] = None,
cellpose_segmentation.py: channel_label: Optional[str] = None,
cellpose_segmentation.py: wavelength_id_c2: Optional[str] = None,
cellpose_segmentation.py: channel_label_c2: Optional[str] = None,
cellpose_segmentation.py: output_ROI_table: Optional[str] = None,
cellpose_segmentation.py: output_label_name: Optional[str] = None, # "organoids"
cellpose_segmentation.py: anisotropy: Optional[float] = None,
cellpose_segmentation.py: pretrained_model: Optional[str] = None,
copy_ome_zarr.py: ROI_table_names: Optional[Sequence[str]] = None,
create_ome_zarr.py: image_glob_patterns: Optional[list[str]] = None,
create_ome_zarr_multiplex.py: image_glob_patterns: Optional[list[str]] = None,
illumination_correction.py: new_component: Optional[str] = None,