From c429c62d00d24ddda60eee6e1de196db6fcd7fa6 Mon Sep 17 00:00:00 2001 From: Satoru SATOH Date: Wed, 30 Jan 2019 16:51:59 +0900 Subject: [PATCH] fix: disable ruamel.yaml based backend if its lib is too old Disable ruamel.yaml based YAML backend if dependent ruamel.yaml library is too old and does not have the definition of ruamel.yaml.YAML class, necessary to make it works. This fix was based on the report from the pr#97 by Masatake YAMATO. --- anyconfig/backend/yaml/ruamel_yaml.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/anyconfig/backend/yaml/ruamel_yaml.py b/anyconfig/backend/yaml/ruamel_yaml.py index 4b02fab3..93ab49e2 100644 --- a/anyconfig/backend/yaml/ruamel_yaml.py +++ b/anyconfig/backend/yaml/ruamel_yaml.py @@ -44,6 +44,11 @@ from . import pyyaml +try: + ryaml.YAML # flake8: noqa +except AttributeError: + ImportError("ruamel.yaml may be too old to use!") + _YAML_INIT_KWARGS = ["typ", "pure", "plug_ins"] # kwargs for ruamel.yaml.YAML _YAML_INSTANCE_MEMBERS = ['allow_duplicate_keys', 'allow_unicode', 'block_seq_indent', 'canonical', 'composer',