From 465e0520c79a74b1bf08838ebaf2806ee8b043d2 Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Tue, 29 Jul 2025 21:07:24 +0100 Subject: [PATCH] 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 --- sqlmesh/core/loader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlmesh/core/loader.py b/sqlmesh/core/loader.py index 30c74884c8..edea485d16 100644 --- a/sqlmesh/core/loader.py +++ b/sqlmesh/core/loader.py @@ -334,6 +334,10 @@ def _load_external_models( def _load(path: Path) -> t.List[Model]: try: with open(path, "r", encoding="utf-8") as file: + yaml = YAML().load(file) + # Allow empty YAML files to return an empty list + if yaml is None: + return [] return [ create_external_model( defaults=self.config.model_defaults.dict(), @@ -346,7 +350,7 @@ def _load(path: Path) -> t.List[Model]: **row, }, ) - for row in YAML().load(file.read()) + for row in yaml ] except Exception as ex: raise ConfigError(self._failed_to_load_model_error(path, ex), path)