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)