Closed masatake closed 5 years ago
Thanks for your report and PR! However, it broke all tests and it needs to be fixed before merge.
Related: #98
Maybe there are two choices.
# put this block just before global variable defs.
try:
ryaml.YAML # noqa
except AttributeError:
ImportError('ruamel.yaml may be too old; no YAML class is defined')
I don't know python well. However, I think reporting ImportError is better.
anyconfig/backend/yaml/__init__.py
expects no IMPORT error.
The AttributeError
is an internal error.
The ImportError is a part of interface between anyconfig/backend/yaml/__init__.py
and ` anyconfig/backend/yaml/ruamel_yaml.py.
ruamel_yaml.py has a responsibility to report whether the backend implementation is usable or not in IMPORT error. My fix is for making ruamel_yaml.py fulfils the responsibility.
I guess that the original problem of this PR should be resolved by the commit c429c62. Could you please test the later one after that commit in the next branch?
Sorry, I have no test environment. I'm using a version of python-anyconfig distributed as a rpm package. When making a patch, I modify the installed version of code directly.
Instead of testing the latest code locally, I will make a pull request that tests the latest code on Fedora 28 environment on circle ci. Fedora 28 provides only older ruamel.yaml.
ruamel_yaml uses YAML class. However, an older version of ruamel.yaml doesn't define YAML class.
https://bitbucket.org/ruamel/yaml
If an older version is installed on a system, python-anyconfig doesn't work at all.
This change adds code verifying the existence of YAML class.
With this change, python-anyconfig chooses pyyaml as fallback yaml parser on Fedora 28, where only version 0.13 of ruamel-yaml is available.
Signed-off-by: Masatake YAMATO yamato@redhat.com