@@ -1638,6 +1638,8 @@ def is_seed(self) -> bool:
16381638 def seed_path (self ) -> Path :
16391639 seed_path = Path (self .kind .path )
16401640 if not seed_path .is_absolute ():
1641+ if self ._path is None :
1642+ raise SQLMeshError (f"Seed model '{ self .name } ' has no path" )
16411643 return self ._path .parent / seed_path
16421644 return seed_path
16431645
@@ -2003,7 +2005,7 @@ def load_sql_based_model(
20032005 expressions : t .List [exp .Expression ],
20042006 * ,
20052007 defaults : t .Optional [t .Dict [str , t .Any ]] = None ,
2006- path : Path = Path () ,
2008+ path : t . Optional [ Path ] = None ,
20072009 module_path : Path = Path (),
20082010 time_column_format : str = c .DEFAULT_TIME_COLUMN_FORMAT ,
20092011 macros : t .Optional [MacroRegistry ] = None ,
@@ -2153,6 +2155,8 @@ def load_sql_based_model(
21532155 # The name of the model will be inferred from its path relative to `models/`, if it's not explicitly specified
21542156 name = meta_fields .pop ("name" , "" )
21552157 if not name and infer_names :
2158+ if path is None :
2159+ raise ValueError ("Model must have a name" , path )
21562160 name = get_model_name (path )
21572161
21582162 if not name :
@@ -2230,7 +2234,7 @@ def create_seed_model(
22302234 name : TableName ,
22312235 seed_kind : SeedKind ,
22322236 * ,
2233- path : Path = Path () ,
2237+ path : t . Optional [ Path ] = None ,
22342238 module_path : Path = Path (),
22352239 ** kwargs : t .Any ,
22362240) -> Model :
@@ -2249,7 +2253,12 @@ def create_seed_model(
22492253 seed_path = module_path .joinpath (* subdirs )
22502254 seed_kind .path = str (seed_path )
22512255 elif not seed_path .is_absolute ():
2252- seed_path = path / seed_path if path .is_dir () else path .parent / seed_path
2256+ if path is None :
2257+ seed_path = seed_path
2258+ elif path .is_dir ():
2259+ seed_path = path / seed_path
2260+ else :
2261+ seed_path = path .parent / seed_path
22532262
22542263 seed = create_seed (seed_path )
22552264
@@ -2384,7 +2393,7 @@ def _create_model(
23842393 name : TableName ,
23852394 * ,
23862395 defaults : t .Optional [t .Dict [str , t .Any ]] = None ,
2387- path : Path = Path () ,
2396+ path : t . Optional [ Path ] = None ,
23882397 time_column_format : str = c .DEFAULT_TIME_COLUMN_FORMAT ,
23892398 jinja_macros : t .Optional [JinjaMacroRegistry ] = None ,
23902399 jinja_macro_references : t .Optional [t .Set [MacroReference ]] = None ,
@@ -2553,7 +2562,7 @@ def _create_model(
25532562
25542563def _split_sql_model_statements (
25552564 expressions : t .List [exp .Expression ],
2556- path : Path ,
2565+ path : t . Optional [ Path ] ,
25572566 dialect : t .Optional [str ] = None ,
25582567) -> t .Tuple [
25592568 t .Optional [exp .Expression ],
@@ -2674,7 +2683,7 @@ def _refs_to_sql(values: t.Any) -> exp.Expression:
26742683def render_meta_fields (
26752684 fields : t .Dict [str , t .Any ],
26762685 module_path : Path ,
2677- path : Path ,
2686+ path : t . Optional [ Path ] ,
26782687 jinja_macros : t .Optional [JinjaMacroRegistry ],
26792688 macros : t .Optional [MacroRegistry ],
26802689 dialect : DialectType ,
@@ -2758,7 +2767,7 @@ def render_field_value(value: t.Any) -> t.Any:
27582767def render_model_defaults (
27592768 defaults : t .Dict [str , t .Any ],
27602769 module_path : Path ,
2761- path : Path ,
2770+ path : t . Optional [ Path ] ,
27622771 jinja_macros : t .Optional [JinjaMacroRegistry ],
27632772 macros : t .Optional [MacroRegistry ],
27642773 dialect : DialectType ,
@@ -2808,7 +2817,7 @@ def parse_defaults_properties(
28082817def render_expression (
28092818 expression : exp .Expression ,
28102819 module_path : Path ,
2811- path : Path ,
2820+ path : t . Optional [ Path ] ,
28122821 jinja_macros : t .Optional [JinjaMacroRegistry ] = None ,
28132822 macros : t .Optional [MacroRegistry ] = None ,
28142823 dialect : DialectType = None ,
0 commit comments