diff options
| -rw-r--r-- | config_file/parsers/yaml_parser.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/config_file/parsers/yaml_parser.py b/config_file/parsers/yaml_parser.py index fc4239a..4c39582 100644 --- a/config_file/parsers/yaml_parser.py +++ b/config_file/parsers/yaml_parser.py @@ -1,3 +1,4 @@ +from io import StringIO from typing import Type from .base_parser import BaseParser @@ -17,15 +18,14 @@ class YamlParser(BaseParser): @property def decode_error(self) -> Type[Exception]: from ruamel.yaml import YAMLError - return YAMLError def loads(self, contents: str) -> dict: - from ruamel.yaml import round_trip_load - - return round_trip_load(contents) + from ruamel.yaml import YAML + return YAML().load(contents) def dumps(self, loaded_contents: dict) -> str: - from ruamel.yaml import round_trip_dump - - return round_trip_dump(loaded_contents) + from ruamel.yaml import YAML + buffer = StringIO() + YAML().dump(loaded_contents, buffer) + return buffer.getvalue() |