mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix empty files included by !include_dir_named (#108489)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
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]
|
filename = os.path.splitext(os.path.basename(fname))[0]
|
||||||
if os.path.basename(fname) == SECRET_YAML:
|
if os.path.basename(fname) == SECRET_YAML:
|
||||||
continue
|
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)
|
return _add_reference(mapping, loader, node)
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ def test_include_dir_list_recursive(
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
{"/test/first.yaml": "1", "/test/second.yaml": None},
|
{"/test/first.yaml": "1", "/test/second.yaml": None},
|
||||||
{"first": 1, "second": None},
|
{"first": 1, "second": {}},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user