Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.
brainprep.utils.utils.coerce_to_list¶
- brainprep.utils.utils.coerce_to_list(value, expected_type)[source]¶
Coerce a value into a list when the expected type annotation indicates a list or tuple.
- Parameters:
- valueAny
The input value to be coerced.
- expected_typetype
The expected type annotation (e.g., File, List[File], Dict[str, Directory], Union[str, Directory]).
- Returns:
- typed_valueAny
The coerced value, with list converted to list.
Notes
Comma-separated strings (e.g.,
"a,b,c") are split into lists.Single non-list values are wrapped into a list.
Existing lists or tuples are returned as lists.