File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from 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
2732from ruamel .yaml .main import YAML
2833from ruamel .yaml .representer import RoundTripRepresenter
2934from 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 )
You can’t perform that action at this time.
0 commit comments