Skip to content

Commit e7412f1

Browse files
bkalashnikovbogdandm
bkalashnikov
authored andcommitted
Fix yaml
1 parent 1435560 commit e7412f1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

json_to_models/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515

1616
try:
1717
import ruamel.yaml as yaml
18+
19+
yaml_load = yaml.YAML(typ='safe', pure=True).load
1820
except ImportError:
1921
try:
2022
import yaml
23+
yaml_load = yaml.safe_load
2124
except ImportError:
2225
yaml = None
2326

@@ -417,11 +420,11 @@ def json(path: Path) -> Union[dict, list]:
417420

418421
@staticmethod
419422
def yaml(path: Path) -> Union[dict, list]:
420-
if yaml is None:
421-
print('Yaml parser is not installed. To parse yaml files PyYaml (or ruamel.yaml) is required.')
423+
if yaml_load is None:
424+
print('Yaml parser is not installed. To parse yaml files ruamel.yaml (or PyYaml) is required.')
422425
raise ImportError('yaml')
423426
with path.open() as fp:
424-
return yaml.safe_load(fp)
427+
return yaml_load(fp)
425428

426429
@staticmethod
427430
def ini(path: Path) -> dict:

0 commit comments

Comments
 (0)