@@ -210,6 +210,7 @@ def check_all_types(
210210 extra_message = (
211211 "pickValue is %s" % sink .pickValue if sink .pickValue is not None else None
212212 )
213+ sink_type = type_dict [sink .id ]
213214 match sink :
214215 case cwl .WorkflowOutputParameter ():
215216 sourceName = "outputSource"
@@ -231,7 +232,10 @@ def check_all_types(
231232 srcs_of_sink += [src_dict [parm_id ]]
232233 if (
233234 _is_conditional_step (param_to_step , parm_id )
234- and sink .pickValue is not None
235+ and "null" != sink_type
236+ and isinstance (sink_type , MutableSequence )
237+ and "null" not in sink_type
238+ and sink .pickValue is None
235239 ):
236240 validation ["warning" ].append (
237241 SrcSink (
@@ -289,8 +293,9 @@ def check_all_types(
289293 for src in srcs_of_sink :
290294 check_result = check_types (
291295 type_dict [cast (str , src .id )],
292- type_dict [ sink . id ] ,
296+ sink_type ,
293297 linkMerge ,
298+ sink .pickValue ,
294299 getattr (sink , "valueFrom" , None ),
295300 )
296301 if check_result in ("warning" , "exception" ):
@@ -304,6 +309,7 @@ def check_types(
304309 srctype : Any ,
305310 sinktype : Any ,
306311 linkMerge : str | None ,
312+ pickValue : str | None = None ,
307313 valueFrom : str | None = None ,
308314) -> str :
309315 """
@@ -313,19 +319,49 @@ def check_types(
313319 """
314320 if valueFrom is not None :
315321 return "pass"
316- if linkMerge is None :
317- if can_assign_src_to_sink (srctype , sinktype , strict = True ):
318- return "pass"
319- if can_assign_src_to_sink (srctype , sinktype , strict = False ):
320- return "warning"
321- return "exception"
322- if linkMerge == "merge_nested" :
323- return check_types (
324- cwl .ArraySchema (items = srctype , type_ = "array" ), sinktype , None , None
325- )
326- if linkMerge == "merge_flattened" :
327- return check_types (merge_flatten_type (srctype ), sinktype , None , None )
328- raise ValidationException (f"Invalid value { linkMerge } for linkMerge field." )
322+ if pickValue is not None :
323+ if isinstance (srctype , cwl .ArraySchema ):
324+ match pickValue :
325+ case "all_non_null" :
326+ srctype = cwl .ArraySchema (items = srctype .items , type_ = "array" )
327+ if (
328+ isinstance (srctype .items , MutableSequence )
329+ and "null" in srctype .items
330+ ):
331+ srctype .items = [
332+ elem for elem in srctype .items if elem != "null"
333+ ]
334+ case "first_non_null" | "the_only_non_null" :
335+ if (
336+ isinstance (srctype .items , MutableSequence )
337+ and "null" in srctype .items
338+ ):
339+ srctype = [elem for elem in srctype .items if elem != "null" ]
340+ else :
341+ srctype = srctype .items
342+ case _:
343+ raise ValidationException (
344+ f"Invalid value { pickValue } for pickValue field."
345+ )
346+ match linkMerge :
347+ case None :
348+ if can_assign_src_to_sink (srctype , sinktype , strict = True ):
349+ return "pass"
350+ if can_assign_src_to_sink (srctype , sinktype , strict = False ):
351+ return "warning"
352+ return "exception"
353+ case "merge_nested" :
354+ return check_types (
355+ cwl .ArraySchema (items = srctype , type_ = "array" ),
356+ sinktype ,
357+ None ,
358+ None ,
359+ None ,
360+ )
361+ case "merge_flattened" :
362+ return check_types (merge_flatten_type (srctype ), sinktype , None , None , None )
363+ case _:
364+ raise ValidationException (f"Invalid value { linkMerge } for linkMerge field." )
329365
330366
331367def content_limit_respected_read_bytes (f : IO [bytes ]) -> bytes :
0 commit comments