Skip to content

Commit 7564a3b

Browse files
committed
Add missing type hints to utils,
* removed duplicate type entries in parser, * fixed test function docs
1 parent 4630416 commit 7564a3b

File tree

4 files changed

+9
-23
lines changed

4 files changed

+9
-23
lines changed

cwl_utils/inputs_schema_gen.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ def get_is_required_from_input_parameter(
238238
def generate_json_schema_property_from_input_parameter(
239239
input_parameter: WorkflowInputParameter,
240240
) -> JSONSchemaProperty:
241-
"""Given an input parameter, generate a JSON schema property.
241+
"""
242+
Given an input parameter, generate a JSON schema property.
242243
243244
:param input_parameter:
244245
:return:
@@ -319,14 +320,16 @@ def generate_definition_from_schema(schema: InputRecordSchema) -> Dict[str, Any]
319320

320321

321322
def cwl_to_jsonschema(cwl_obj: Union[Workflow, CommandLineTool]) -> Any:
322-
"""cwl_obj: A CWL Object.
323+
"""
324+
cwl_obj: A CWL Object.
323325
324326
Returns:
325327
A JSONSchema object.
326328
327329
Example:
328330
cwl_obj = load_document_by_uri(<CWL_URL>)
329331
jsonschema = cwl_to_jsonschema(cwl_inputs)
332+
330333
"""
331334
# Initialise the schema from the workflow input json schema template
332335
with open(JSON_TEMPLATE_PATH, "r") as template_h:
@@ -559,7 +562,8 @@ def main() -> None:
559562

560563

561564
def get_cwl_url(url: str) -> str:
562-
"""Conform to uri format.
565+
"""
566+
Conform to uri format.
563567
564568
If no scheme, then assert is a local file path and exists
565569
if scheme is file, then assert is a local file path and exists

cwl_utils/parser/__init__.py

-18
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,12 @@
2121
InputParameter = Union[
2222
cwl_v1_0.InputParameter, cwl_v1_1.InputParameter, cwl_v1_2.InputParameter
2323
]
24-
"""Type union for a CWL v1.x InputParameter object."""
25-
InputArraySchema = Union[
26-
cwl_v1_0.InputArraySchema,
27-
cwl_v1_1.InputArraySchema,
28-
cwl_v1_2.InputArraySchema,
29-
]
30-
"""Type union for a CWL v1.x InputArraySchema object."""
31-
InputEnumSchema = Union[
32-
cwl_v1_0.InputEnumSchema,
33-
cwl_v1_1.InputEnumSchema,
34-
cwl_v1_2.InputEnumSchema,
35-
]
3624
"""Type union for a CWL v1.x InputEnumSchema object."""
3725
InputRecordField = Union[
3826
cwl_v1_0.InputRecordField,
3927
cwl_v1_1.InputRecordField,
4028
cwl_v1_2.InputRecordField,
4129
]
42-
"""Type union for a CWL v1.x InputRecordField object."""
43-
InputRecordSchema = Union[
44-
cwl_v1_0.InputRecordSchema,
45-
cwl_v1_1.InputRecordSchema,
46-
cwl_v1_2.InputRecordSchema,
47-
]
4830
"""Type union for a CWL v1.x InputRecordSchema object."""
4931
OutputParameter = Union[
5032
cwl_v1_0.OutputParameter, cwl_v1_1.OutputParameter, cwl_v1_2.OutputParameter

cwl_utils/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from collections.abc import MutableMapping, MutableSequence
1212
from copy import deepcopy
1313
from io import StringIO
14-
from typing import Any, Optional, Union
14+
from typing import Any, Optional, Union, Dict, List
1515

1616
from ruamel.yaml.main import YAML
1717
from ruamel.yaml.parser import ParserError

tests/test_inputs_schema_gen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_cwl_inputs_to_jsonschema(test_param: Dict[str, str]) -> None:
7979

8080

8181
def test_cwl_inputs_to_jsonschema_fails() -> None:
82-
"""Compare tool schema of param 1 against input schema of param 2"""
82+
"""Compare tool schema of param 1 against input schema of param 2."""
8383
tool_url = TEST_PARAMS[0]["tool_url"]
8484
input_url = TEST_PARAMS[3]["input_url"]
8585

0 commit comments

Comments
 (0)