You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
Using the example provided by ruamel.yaml for version > 0.15:
from pathlib import Path
from ruamel.yaml import YAML
yaml = YAML(typ="safe")
yaml.default_flow_style = False
data = yaml.load("abc: 1")
out = Path("/tmp/out.yaml")
yaml.dump(data, out)
Running dlint provides the following output:
$ python -m flake8 --select=DUO yaml_test.py
yaml_test.py:6:8: DUO109 improper use of "yaml" parsing function, please use "safe_*" equivalent
yaml_test.py:8:1: DUO109 improper use of "yaml" parsing function, please use "safe_*" equivalent
If that advice is followed, the script doesn't work, since ruamel.yaml no longer has those functions:
$ python yaml_test.py
Traceback (most recent call last):
File "yaml_test.py", line 6, in <module>
data = yaml.safe_load("abc: 1")
AttributeError: 'YAML' object has no attribute 'safe_load'
The text was updated successfully, but these errors were encountered:
Good catch! One of the general improvements needed in Dlint is better handling of from imports bringing names into the namespace (#1, #16). I'd say this follows a similar trend.
One quick way to fix this would be using a different variable name, e.g.
Dlint is getting confused with the variable name vs. the traditional YAML module name of yaml. Regardless, this should be fixed, so I'll track this along with other from import namespace improvements.
Using the example provided by ruamel.yaml for version > 0.15:
Running dlint provides the following output:
If that advice is followed, the script doesn't work, since
ruamel.yaml
no longer has those functions:The text was updated successfully, but these errors were encountered: