Skip to content

Commit edddbc8

Browse files
committed
make cwlformat optional
1 parent 3586771 commit edddbc8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

cwl_utils/graph_split.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020
from typing import (
2121
IO,
2222
Any,
23+
Callable,
2324
cast,
2425
)
2526

26-
from cwlformat.formatter import stringify_dict
27+
try:
28+
stringify_dict: Callable[[dict[str, Any]], str] | None
29+
from cwlformat.formatter import stringify_dict
30+
except ImportError:
31+
stringify_dict = None
2732
from ruamel.yaml.main import YAML
2833
from ruamel.yaml.representer import RoundTripRepresenter
2934
from schema_salad.sourceline import SourceLine, add_lc_filename
@@ -288,6 +293,10 @@ def yaml_dump(
288293
) -> None:
289294
"""Output object as YAML."""
290295
if pretty:
296+
if not stringify_dict:
297+
raise RuntimeError(
298+
"yaml_dump(pretty=True) requires cwlformat to be installed."
299+
)
291300
output_handle.write(stringify_dict(entry))
292301
return
293302
yaml = YAML(typ="rt", pure=True)

0 commit comments

Comments
 (0)