@@ -1648,6 +1648,8 @@ def is_seed(self) -> bool:
16481648 def seed_path (self ) -> Path :
16491649 seed_path = Path (self .kind .path )
16501650 if not seed_path .is_absolute ():
1651+ if self ._path is None :
1652+ raise SQLMeshError (f"Seed model '{ self .name } ' has no path" )
16511653 return self ._path .parent / seed_path
16521654 return seed_path
16531655
@@ -2022,7 +2024,7 @@ def load_sql_based_model(
20222024 expressions : t .List [exp .Expression ],
20232025 * ,
20242026 defaults : t .Optional [t .Dict [str , t .Any ]] = None ,
2025- path : Path = Path () ,
2027+ path : t . Optional [ Path ] = None ,
20262028 module_path : Path = Path (),
20272029 time_column_format : str = c .DEFAULT_TIME_COLUMN_FORMAT ,
20282030 macros : t .Optional [MacroRegistry ] = None ,
@@ -2173,6 +2175,8 @@ def load_sql_based_model(
21732175 # The name of the model will be inferred from its path relative to `models/`, if it's not explicitly specified
21742176 name = meta_fields .pop ("name" , "" )
21752177 if not name and infer_names :
2178+ if path is None :
2179+ raise ValueError (f"Model { name } must have a name" )
21762180 name = get_model_name (path )
21772181
21782182 if not name :
@@ -2251,7 +2255,7 @@ def create_seed_model(
22512255 name : TableName ,
22522256 seed_kind : SeedKind ,
22532257 * ,
2254- path : Path = Path () ,
2258+ path : t . Optional [ Path ] = None ,
22552259 module_path : Path = Path (),
22562260 ** kwargs : t .Any ,
22572261) -> Model :
@@ -2270,7 +2274,12 @@ def create_seed_model(
22702274 seed_path = module_path .joinpath (* subdirs )
22712275 seed_kind .path = str (seed_path )
22722276 elif not seed_path .is_absolute ():
2273- seed_path = path / seed_path if path .is_dir () else path .parent / seed_path
2277+ if path is None :
2278+ seed_path = seed_path
2279+ elif path .is_dir ():
2280+ seed_path = path / seed_path
2281+ else :
2282+ seed_path = path .parent / seed_path
22742283
22752284 seed = create_seed (seed_path )
22762285
@@ -2405,7 +2414,7 @@ def _create_model(
24052414 name : TableName ,
24062415 * ,
24072416 defaults : t .Optional [t .Dict [str , t .Any ]] = None ,
2408- path : Path = Path () ,
2417+ path : t . Optional [ Path ] = None ,
24092418 time_column_format : str = c .DEFAULT_TIME_COLUMN_FORMAT ,
24102419 jinja_macros : t .Optional [JinjaMacroRegistry ] = None ,
24112420 jinja_macro_references : t .Optional [t .Set [MacroReference ]] = None ,
@@ -2593,7 +2602,7 @@ def _create_model(
25932602
25942603def _split_sql_model_statements (
25952604 expressions : t .List [exp .Expression ],
2596- path : Path ,
2605+ path : t . Optional [ Path ] ,
25972606 dialect : t .Optional [str ] = None ,
25982607) -> t .Tuple [
25992608 t .Optional [exp .Expression ],
@@ -2714,7 +2723,7 @@ def _refs_to_sql(values: t.Any) -> exp.Expression:
27142723def render_meta_fields (
27152724 fields : t .Dict [str , t .Any ],
27162725 module_path : Path ,
2717- path : Path ,
2726+ path : t . Optional [ Path ] ,
27182727 jinja_macros : t .Optional [JinjaMacroRegistry ],
27192728 macros : t .Optional [MacroRegistry ],
27202729 dialect : DialectType ,
@@ -2801,7 +2810,7 @@ def render_field_value(value: t.Any) -> t.Any:
28012810def render_model_defaults (
28022811 defaults : t .Dict [str , t .Any ],
28032812 module_path : Path ,
2804- path : Path ,
2813+ path : t . Optional [ Path ] ,
28052814 jinja_macros : t .Optional [JinjaMacroRegistry ],
28062815 macros : t .Optional [MacroRegistry ],
28072816 dialect : DialectType ,
@@ -2851,7 +2860,7 @@ def parse_defaults_properties(
28512860def render_expression (
28522861 expression : exp .Expression ,
28532862 module_path : Path ,
2854- path : Path ,
2863+ path : t . Optional [ Path ] ,
28552864 jinja_macros : t .Optional [JinjaMacroRegistry ] = None ,
28562865 macros : t .Optional [MacroRegistry ] = None ,
28572866 dialect : DialectType = None ,
0 commit comments