Skip to content

Commit 3c75842

Browse files
authored
Better logic for empty yaml files (#3574)
1 parent de871c3 commit 3c75842

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/cfnlint/decode/cfn_yaml.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from yaml.resolver import Resolver
1818
from yaml.scanner import Scanner
1919

20+
from cfnlint.decode.mark import Mark
2021
from cfnlint.decode.node import dict_node, list_node, str_node
2122
from cfnlint.rules import Match
2223
from cfnlint.rules.errors import ParseError
@@ -291,7 +292,7 @@ def loads(yaml_string, fname=None):
291292
template = loader.get_single_data()
292293
# Convert an empty file to an empty dict
293294
if template is None:
294-
template = {}
295+
template = dict_node({}, Mark(0, 0), Mark(0, 0))
295296

296297
return template
297298

test/unit/module/decode/test_decode.py

+4
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,7 @@ def test_decode_yaml_null_key(self):
138138
"""
139139
)
140140
self.assertEqual(str(e.exception), err_msg)
141+
142+
def test_decode_yaml_empty(self):
143+
template = cfnlint.decode.cfn_yaml.loads("")
144+
self.assertEqual(template, {})

0 commit comments

Comments
 (0)