Skip to content

Commit b94a40e

Browse files
committed
feat: allow empty external models file
- before you would get an error saying None is non-iterable - was just slightly confusing when you first create the file in vscode and we show a confusing error
1 parent 5ccd57e commit b94a40e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sqlmesh/core/loader.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ def _load_external_models(
334334
def _load(path: Path) -> t.List[Model]:
335335
try:
336336
with open(path, "r", encoding="utf-8") as file:
337+
yaml = YAML().load(file)
338+
# Allow empty YAML files to return an empty list
339+
if yaml is None:
340+
return []
337341
return [
338342
create_external_model(
339343
defaults=self.config.model_defaults.dict(),
@@ -346,7 +350,7 @@ def _load(path: Path) -> t.List[Model]:
346350
**row,
347351
},
348352
)
349-
for row in YAML().load(file.read())
353+
for row in yaml
350354
]
351355
except Exception as ex:
352356
raise ConfigError(self._failed_to_load_model_error(path, ex), path)

0 commit comments

Comments
 (0)