Fix empty files included by !include_dir_named (#108489)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>pull/108508/head
parent
a3619e544e
commit
1cb5bbf865
|
@ -359,7 +359,12 @@ def _include_dir_named_yaml(loader: LoaderType, node: yaml.nodes.Node) -> NodeDi
|
|||
filename = os.path.splitext(os.path.basename(fname))[0]
|
||||
if os.path.basename(fname) == SECRET_YAML:
|
||||
continue
|
||||
mapping[filename] = load_yaml(fname, loader.secrets)
|
||||
loaded_yaml = load_yaml(fname, loader.secrets)
|
||||
if loaded_yaml is None:
|
||||
# Special case, an empty file included by !include_dir_named is treated
|
||||
# as an empty dictionary
|
||||
loaded_yaml = NodeDictClass()
|
||||
mapping[filename] = loaded_yaml
|
||||
return _add_reference(mapping, loader, node)
|
||||
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ def test_include_dir_list_recursive(
|
|||
),
|
||||
(
|
||||
{"/test/first.yaml": "1", "/test/second.yaml": None},
|
||||
{"first": 1, "second": None},
|
||||
{"first": 1, "second": {}},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue