77import uuid
88from collections .abc import MutableSequence , Sequence
99from contextlib import suppress
10- from typing import Any , Literal , TypeAlias , TypeVar , cast
10+ from typing import Any , cast
1111
1212from ruamel import yaml
1313from schema_salad .sourceline import SourceLine
1717import cwl_utils .parser .cwl_v1_0_utils as utils
1818from cwl_utils .errors import JavascriptException , WorkflowException
1919from cwl_utils .expression import do_eval , interpolate
20+ from cwl_utils .parser .cwl_v1_0_utils import (
21+ AnyTypeSchema ,
22+ BasicCommandInputTypeSchemas ,
23+ BasicCommandOutputTypeSchemas ,
24+ BasicInputTypeSchemas ,
25+ BasicOutputTypeSchemas ,
26+ CommandInputTypeSchemas ,
27+ CommandOutputTypeSchemas ,
28+ InputTypeSchemas ,
29+ OutputTypeSchemas ,
30+ )
2031from cwl_utils .types import (
2132 CWLDirectoryType ,
2233 CWLFileType ,
@@ -56,91 +67,6 @@ def escape_expression_field(contents: str) -> str:
5667 return contents .replace ("${" , "$/{" ).replace ("$(" , "$/(" )
5768
5869
59- BasicInputTypeSchemas : TypeAlias = (
60- cwl .InputArraySchema
61- | cwl .InputEnumSchema
62- | cwl .InputRecordSchema
63- | str
64- | Literal [
65- "null" ,
66- "boolean" ,
67- "int" ,
68- "long" ,
69- "float" ,
70- "double" ,
71- "string" ,
72- "File" ,
73- "Directory" ,
74- ]
75- )
76- InputTypeSchemas : TypeAlias = (
77- BasicInputTypeSchemas | Sequence [BasicInputTypeSchemas ] | None
78- )
79- BasicCommandInputTypeSchemas : TypeAlias = (
80- cwl .CommandInputArraySchema
81- | cwl .CommandInputEnumSchema
82- | cwl .CommandInputRecordSchema
83- | str
84- | Literal [
85- "null" ,
86- "boolean" ,
87- "int" ,
88- "long" ,
89- "float" ,
90- "double" ,
91- "string" ,
92- "File" ,
93- "Directory" ,
94- ]
95- )
96- CommandInputTypeSchemas : TypeAlias = (
97- BasicCommandInputTypeSchemas | Sequence [BasicCommandInputTypeSchemas ] | None
98- )
99- BasicOutputTypeSchemas : TypeAlias = (
100- cwl .OutputArraySchema
101- | cwl .OutputEnumSchema
102- | cwl .OutputRecordSchema
103- | str
104- | Literal [
105- "null" ,
106- "boolean" ,
107- "int" ,
108- "long" ,
109- "float" ,
110- "double" ,
111- "string" ,
112- "File" ,
113- "Directory" ,
114- ]
115- )
116- OutputTypeSchemas : TypeAlias = (
117- BasicOutputTypeSchemas | Sequence [BasicOutputTypeSchemas ] | None
118- )
119- BasicCommandOutputTypeSchemas : TypeAlias = (
120- cwl .CommandOutputArraySchema
121- | cwl .CommandOutputEnumSchema
122- | cwl .CommandOutputRecordSchema
123- | str
124- | Literal [
125- "null" ,
126- "boolean" ,
127- "int" ,
128- "long" ,
129- "float" ,
130- "double" ,
131- "string" ,
132- "File" ,
133- "Directory" ,
134- ]
135- )
136- CommandOutputTypeSchemas : TypeAlias = (
137- BasicCommandOutputTypeSchemas | Sequence [BasicCommandOutputTypeSchemas ] | None
138- )
139- AnyTypeSchema = TypeVar (
140- "AnyTypeSchema" , bound = InputTypeSchemas | CommandOutputTypeSchemas
141- )
142-
143-
14470def _clean_type_ids (
14571 cwltype : InputTypeSchemas | CommandOutputTypeSchemas ,
14672) -> None :
@@ -162,8 +88,6 @@ def _clean_type_ids(
16288 for field in cwltype .items .fields :
16389 field .name = field .name .split ("/" )[- 1 ]
16490 elif isinstance (cwltype , cwl .RecordSchema ):
165- if cwltype .name :
166- cwltype .name = cwltype .name .split ("/" )[- 1 ]
16791 if cwltype .fields :
16892 for field in cwltype .fields :
16993 field .name = field .name .split ("/" )[- 1 ]
@@ -686,7 +610,7 @@ def get_input_for_id(
686610 """Determine the CommandInputParameter for the given input name."""
687611 name = name .split ("/" )[- 1 ]
688612
689- for inp in cast (list [cwl .InputParameter ], tool .inputs ):
613+ for inp in cast (list [cwl .CommandInputParameter ], tool .inputs ):
690614 if inp .id and inp .id .split ("#" )[- 1 ].split ("/" )[- 1 ] == name :
691615 return cwl .CommandInputParameter .fromDoc (
692616 inp .save (), inp .loadingOptions .baseuri , inp .loadingOptions
0 commit comments