2525 CWLParameterContext ,
2626 CWLRuntimeParameterContext ,
2727 is_file_or_directory ,
28+ is_sequence ,
2829)
2930
3031
@@ -146,7 +147,7 @@ def _clean_type_ids(
146147 cwltype : InputTypeSchemas | CommandOutputTypeSchemas ,
147148) -> None :
148149 if isinstance (cwltype , cwl .ArraySchema ):
149- if isinstance (cwltype .items , Sequence ):
150+ if is_sequence (cwltype .items ):
150151 for item in cwltype .items :
151152 if hasattr (item , "id" ):
152153 item .id = item .id .split ("#" )[- 1 ]
@@ -175,7 +176,7 @@ def clean_type_ids(
175176) -> AnyTypeSchema :
176177 """Simplify type identifiers."""
177178 result = copy .deepcopy (cwltype )
178- if isinstance (result , Sequence ):
179+ if is_sequence (result ):
179180 for item in result :
180181 _clean_type_ids (item )
181182 else :
@@ -192,7 +193,7 @@ def _has_expression(string: str) -> bool:
192193
193194
194195def has_expression (field : str | Sequence [str ]) -> bool :
195- if isinstance (field , Sequence ):
196+ if is_sequence (field ):
196197 for entry in field :
197198 if _has_expression (entry ):
198199 return True
@@ -286,7 +287,7 @@ def _plain_input_schema_to_clt_input_schema(
286287def plain_input_schema_to_clt_input_schema (
287288 input_type : InputTypeSchemas ,
288289) -> CommandInputTypeSchemas :
289- if isinstance (input_type , Sequence ):
290+ if is_sequence (input_type ):
290291 return [
291292 _plain_input_schema_to_clt_input_schema (input_type_item )
292293 for input_type_item in input_type
@@ -324,7 +325,7 @@ def _plain_input_schema_to_plain_output_schema(
324325def plain_input_schema_to_plain_output_schema (
325326 input_type : InputTypeSchemas ,
326327) -> OutputTypeSchemas :
327- if isinstance (input_type , Sequence ):
328+ if is_sequence (input_type ):
328329 return [
329330 _plain_input_schema_to_plain_output_schema (input_type_item )
330331 for input_type_item in input_type
@@ -362,7 +363,7 @@ def _plain_output_type_to_clt_output_type(
362363def plain_output_type_to_clt_output_type (
363364 output_type : OutputTypeSchemas ,
364365) -> CommandOutputTypeSchemas :
365- if isinstance (output_type , Sequence ):
366+ if is_sequence (output_type ):
366367 return [
367368 _plain_output_type_to_clt_output_type (output_type_item )
368369 for output_type_item in output_type
@@ -605,11 +606,11 @@ def generate_etool_from_expr(
605606 self_type = target
606607 assert self_type is not None
607608 new_type : InputTypeSchemas
608- if isinstance (self_type , Sequence ):
609+ if is_sequence (self_type ):
609610 new_type_list : MutableSequence [BasicInputTypeSchemas ] = []
610611 for entry in self_type :
611612 clean_type = clean_type_ids (entry .type_ )
612- if isinstance (clean_type , Sequence ):
613+ if is_sequence (clean_type ):
613614 new_type_list .extend (clean_type )
614615 elif clean_type is None :
615616 pass
@@ -621,27 +622,21 @@ def generate_etool_from_expr(
621622 inputs .append (
622623 cwl .WorkflowInputParameter (
623624 id = "self" ,
624- label = self_type .label if not isinstance (self_type , list ) else None ,
625+ label = self_type .label if not is_sequence (self_type ) else None ,
625626 secondaryFiles = (
626- self_type .secondaryFiles
627- if not isinstance (self_type , list )
628- else None
627+ self_type .secondaryFiles if not is_sequence (self_type ) else None
629628 ),
630629 streamable = (
631- self_type .streamable if not isinstance (self_type , list ) else None
630+ self_type .streamable if not is_sequence (self_type ) else None
632631 ),
633- doc = self_type .doc if not isinstance (self_type , list ) else None ,
634- format = self_type .format if not isinstance (self_type , list ) else None ,
632+ doc = self_type .doc if not is_sequence (self_type ) else None ,
633+ format = ( self_type .format if not is_sequence (self_type ) else None ) ,
635634 type_ = new_type ,
636635 extension_fields = (
637- self_type .extension_fields
638- if not isinstance (self_type , list )
639- else None
636+ self_type .extension_fields if not is_sequence (self_type ) else None
640637 ),
641638 loadingOptions = (
642- self_type .loadingOptions
643- if not isinstance (self_type , list )
644- else None
639+ self_type .loadingOptions if not is_sequence (self_type ) else None
645640 ),
646641 )
647642 )
@@ -1795,7 +1790,7 @@ def traverse_CommandLineTool(
17951790 sub_wf_inputs = process_inputs_to_etool_inputs (clt )
17961791 orig_step_inputs = copy .deepcopy (step .in_ )
17971792 for orig_step_input in orig_step_inputs :
1798- if isinstance (orig_step_input .source , Sequence ):
1793+ if is_sequence (orig_step_input .source ):
17991794 new_orig_step_input_source = list (orig_step_input .source )
18001795 for index , source in enumerate (orig_step_input .source ):
18011796 new_orig_step_input_source [index ] = source .split ("#" )[
@@ -2253,7 +2248,7 @@ def traverse_step(
22532248 )
22542249 else :
22552250 scattered_source_type = utils .type_for_source (parent , source )
2256- if isinstance (scattered_source_type , list ):
2251+ if is_sequence (scattered_source_type ):
22572252 for stype in scattered_source_type :
22582253 self .append (example_input (stype .type_ ))
22592254 else :
@@ -2281,7 +2276,7 @@ def traverse_step(
22812276 source_id = source .split ("#" )[- 1 ]
22822277 input_source_id .append (source_id )
22832278 temp_type = utils .type_for_source (step .run , source_id , parent )
2284- if isinstance (temp_type , list ):
2279+ if is_sequence (temp_type ):
22852280 for ttype in temp_type :
22862281 if ttype not in source_types :
22872282 source_types .append (ttype )
@@ -2364,7 +2359,7 @@ def workflow_step_to_WorkflowInputParameters(
23642359 param = copy .deepcopy (
23652360 utils .param_for_source_id (parent , sourcenames = inp .source )
23662361 )
2367- if isinstance (param , Sequence ):
2362+ if is_sequence (param ):
23682363 for p in param :
23692364 if not p .type_ :
23702365 raise WorkflowException (
0 commit comments