@@ -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"
@@ -220,7 +221,7 @@ def check_all_types(
220221 case _:
221222 continue
222223 if sourceField is not None :
223- if isinstance (sourceField , MutableSequence ):
224+ if isinstance (sourceField , MutableSequence ) and len ( sourceField ) > 1 :
224225 linkMerge : str | None = sink .linkMerge or (
225226 "merge_nested" if len (sourceField ) > 1 else None
226227 )
@@ -231,23 +232,34 @@ 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 sink .pickValue is None
235236 ):
236- validation ["warning" ].append (
237- SrcSink (
238- src_dict [parm_id ],
239- sink ,
240- linkMerge ,
241- message = "Source is from conditional step, but pickValue is not used" ,
237+ src_typ = aslist (type_dict [src_dict [parm_id ].id ])
238+ if "null" not in src_typ :
239+ src_typ = ["null" ] + cast (list [Any ], src_typ )
240+ if (
241+ not isinstance (sink_type , MutableSequence )
242+ or "null" not in sink_type
243+ ):
244+ validation ["warning" ].append (
245+ SrcSink (
246+ src_dict [parm_id ],
247+ sink ,
248+ linkMerge ,
249+ message = "Source is from conditional step, but pickValue is not used" ,
250+ )
242251 )
243- )
252+ type_dict [ src_dict [ parm_id ]. id ] = src_typ
244253 if _is_all_output_method_loop_step (param_to_step , parm_id ):
245254 src_typ = type_dict [src_dict [parm_id ].id ]
246255 type_dict [src_dict [parm_id ].id ] = cwl .ArraySchema (
247256 items = src_typ , type_ = "array"
248257 )
249258 else :
250- parm_id = cast (str , sourceField )
259+ if isinstance (sourceField , MutableSequence ):
260+ parm_id = cast (str , sourceField [0 ])
261+ else :
262+ parm_id = cast (str , sourceField )
251263 if parm_id not in src_dict :
252264 raise SourceLine (sink , sourceName , ValidationException ).makeError (
253265 f"{ sourceName } not found: { parm_id } "
@@ -289,7 +301,7 @@ def check_all_types(
289301 for src in srcs_of_sink :
290302 check_result = check_types (
291303 type_dict [cast (str , src .id )],
292- type_dict [ sink . id ] ,
304+ sink_type ,
293305 linkMerge ,
294306 getattr (sink , "valueFrom" , None ),
295307 )
@@ -313,19 +325,24 @@ def check_types(
313325 """
314326 if valueFrom is not None :
315327 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." )
328+ match linkMerge :
329+ case None :
330+ if can_assign_src_to_sink (srctype , sinktype , strict = True ):
331+ return "pass"
332+ if can_assign_src_to_sink (srctype , sinktype , strict = False ):
333+ return "warning"
334+ return "exception"
335+ case "merge_nested" :
336+ return check_types (
337+ cwl .ArraySchema (items = srctype , type_ = "array" ),
338+ sinktype ,
339+ None ,
340+ None ,
341+ )
342+ case "merge_flattened" :
343+ return check_types (merge_flatten_type (srctype ), sinktype , None , None )
344+ case _:
345+ raise ValidationException (f"Invalid value { linkMerge } for linkMerge field." )
329346
330347
331348def content_limit_respected_read_bytes (f : IO [bytes ]) -> bytes :
0 commit comments