From 3d63aefcfe080a05806c7c62fa9699fa84097180 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 8 Feb 2022 19:58:03 +0000 Subject: [PATCH] Use yaml.safe_load instead of yaml.load PyYAML 6.0 [requires](https://github.com/yaml/pyyaml/pull/561) a Loader argument to be passed to yaml.load. We could pass yaml.SafeLoader, or simply use the yaml.safe_load method instead. This PR opts to do the latter for simplicity. The previous default loader was yaml.Loader, and as such this PR changes the behaviour to yaml.SafeLoader. I don't think this has any actual repurcussions on the data that we're loading in however. https://msg.pyyaml.org/load has more details, and even recommends that FullLoader no longer be used. --- scripts/check-event-schema-examples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-event-schema-examples.py b/scripts/check-event-schema-examples.py index 0eca7abf99d..e5261c879b3 100755 --- a/scripts/check-event-schema-examples.py +++ b/scripts/check-event-schema-examples.py @@ -55,7 +55,7 @@ def load_file(path): else: # We have to assume it's YAML because some of the YAML examples # do not have file extensions. - return yaml.load(f) + return yaml.safe_load(f) def resolve_references(path, schema): @@ -84,7 +84,7 @@ def check_example_file(examplepath, schemapath): example = resolve_references(examplepath, json.load(f)) with open(schemapath) as f: - schema = yaml.load(f) + schema = yaml.safe_load(f) fileurl = "file://" + os.path.abspath(schemapath) schema["id"] = fileurl