|
6 | 6 | import json |
7 | 7 | from collections.abc import Awaitable, MutableMapping |
8 | 8 | from enum import Enum |
9 | | -from typing import Any, Union, cast |
| 9 | +from typing import Any, Literal, Union, cast |
10 | 10 |
|
11 | 11 | from schema_salad.utils import json_dumps |
12 | 12 |
|
@@ -123,31 +123,35 @@ def evaluator( |
123 | 123 | if first_symbol_end + 1 == len(ex) and first_symbol == "null": |
124 | 124 | return None |
125 | 125 | try: |
126 | | - if first_symbol not in obj: |
127 | | - raise WorkflowException("%s is not defined" % first_symbol) |
128 | | - |
129 | | - if inspect.iscoroutinefunction(js_engine.regex_eval): |
130 | | - return asyncio.get_event_loop().run_until_complete( |
131 | | - cast( |
132 | | - Awaitable[CWLOutputType], |
| 126 | + if first_symbol in ("inputs", "self", "runtime"): |
| 127 | + symbol = cast( |
| 128 | + Literal["inputs"] | Literal["self"] | Literal["runtime"], |
| 129 | + first_symbol, |
| 130 | + ) |
| 131 | + if inspect.iscoroutinefunction(js_engine.regex_eval): |
| 132 | + return asyncio.get_event_loop().run_until_complete( |
| 133 | + cast( |
| 134 | + Awaitable[CWLOutputType], |
| 135 | + js_engine.regex_eval( |
| 136 | + first_symbol, |
| 137 | + ex[first_symbol_end:-1], |
| 138 | + cast(CWLOutputType, obj[symbol]), |
| 139 | + **kwargs, |
| 140 | + ), |
| 141 | + ) |
| 142 | + ) |
| 143 | + else: |
| 144 | + return cast( |
| 145 | + CWLOutputType, |
133 | 146 | js_engine.regex_eval( |
134 | 147 | first_symbol, |
135 | 148 | ex[first_symbol_end:-1], |
136 | | - cast(CWLOutputType, obj[first_symbol]), # type: ignore[literal-required] |
| 149 | + cast(CWLOutputType, obj[symbol]), |
137 | 150 | **kwargs, |
138 | 151 | ), |
139 | 152 | ) |
140 | | - ) |
141 | 153 | else: |
142 | | - return cast( |
143 | | - CWLOutputType, |
144 | | - js_engine.regex_eval( |
145 | | - first_symbol, |
146 | | - ex[first_symbol_end:-1], |
147 | | - cast(CWLOutputType, obj[first_symbol]), # type: ignore[literal-required] |
148 | | - **kwargs, |
149 | | - ), |
150 | | - ) |
| 154 | + raise WorkflowException(f"{first_symbol} is unexpected.") |
151 | 155 | except WorkflowException as werr: |
152 | 156 | expression_parse_exception = werr |
153 | 157 | if fullJS: |
|
0 commit comments