@@ -1646,6 +1646,8 @@ def is_seed(self) -> bool:
16461646 def seed_path (self ) -> Path :
16471647 seed_path = Path (self .kind .path )
16481648 if not seed_path .is_absolute ():
1649+ if self ._path is None :
1650+ raise SQLMeshError (f"Seed model '{ self .name } ' has no path" )
16491651 return self ._path .parent / seed_path
16501652 return seed_path
16511653
@@ -2020,7 +2022,7 @@ def load_sql_based_model(
20202022 expressions : t .List [exp .Expression ],
20212023 * ,
20222024 defaults : t .Optional [t .Dict [str , t .Any ]] = None ,
2023- path : Path = Path () ,
2025+ path : t . Optional [ Path ] = None ,
20242026 module_path : Path = Path (),
20252027 time_column_format : str = c .DEFAULT_TIME_COLUMN_FORMAT ,
20262028 macros : t .Optional [MacroRegistry ] = None ,
@@ -2171,6 +2173,8 @@ def load_sql_based_model(
21712173 # The name of the model will be inferred from its path relative to `models/`, if it's not explicitly specified
21722174 name = meta_fields .pop ("name" , "" )
21732175 if not name and infer_names :
2176+ if path is None :
2177+ raise ValueError ("Model must have a name" , path )
21742178 name = get_model_name (path )
21752179
21762180 if not name :
@@ -2249,7 +2253,7 @@ def create_seed_model(
22492253 name : TableName ,
22502254 seed_kind : SeedKind ,
22512255 * ,
2252- path : Path = Path () ,
2256+ path : t . Optional [ Path ] = None ,
22532257 module_path : Path = Path (),
22542258 ** kwargs : t .Any ,
22552259) -> Model :
@@ -2268,7 +2272,12 @@ def create_seed_model(
22682272 seed_path = module_path .joinpath (* subdirs )
22692273 seed_kind .path = str (seed_path )
22702274 elif not seed_path .is_absolute ():
2271- seed_path = path / seed_path if path .is_dir () else path .parent / seed_path
2275+ if path is None :
2276+ seed_path = seed_path
2277+ elif path .is_dir ():
2278+ seed_path = path / seed_path
2279+ else :
2280+ seed_path = path .parent / seed_path
22722281
22732282 seed = create_seed (seed_path )
22742283
@@ -2403,7 +2412,7 @@ def _create_model(
24032412 name : TableName ,
24042413 * ,
24052414 defaults : t .Optional [t .Dict [str , t .Any ]] = None ,
2406- path : Path = Path () ,
2415+ path : t . Optional [ Path ] = None ,
24072416 time_column_format : str = c .DEFAULT_TIME_COLUMN_FORMAT ,
24082417 jinja_macros : t .Optional [JinjaMacroRegistry ] = None ,
24092418 jinja_macro_references : t .Optional [t .Set [MacroReference ]] = None ,
@@ -2588,7 +2597,7 @@ def _create_model(
25882597
25892598def _split_sql_model_statements (
25902599 expressions : t .List [exp .Expression ],
2591- path : Path ,
2600+ path : t . Optional [ Path ] ,
25922601 dialect : t .Optional [str ] = None ,
25932602) -> t .Tuple [
25942603 t .Optional [exp .Expression ],
@@ -2709,7 +2718,7 @@ def _refs_to_sql(values: t.Any) -> exp.Expression:
27092718def render_meta_fields (
27102719 fields : t .Dict [str , t .Any ],
27112720 module_path : Path ,
2712- path : Path ,
2721+ path : t . Optional [ Path ] ,
27132722 jinja_macros : t .Optional [JinjaMacroRegistry ],
27142723 macros : t .Optional [MacroRegistry ],
27152724 dialect : DialectType ,
@@ -2793,7 +2802,7 @@ def render_field_value(value: t.Any) -> t.Any:
27932802def render_model_defaults (
27942803 defaults : t .Dict [str , t .Any ],
27952804 module_path : Path ,
2796- path : Path ,
2805+ path : t . Optional [ Path ] ,
27972806 jinja_macros : t .Optional [JinjaMacroRegistry ],
27982807 macros : t .Optional [MacroRegistry ],
27992808 dialect : DialectType ,
@@ -2843,7 +2852,7 @@ def parse_defaults_properties(
28432852def render_expression (
28442853 expression : exp .Expression ,
28452854 module_path : Path ,
2846- path : Path ,
2855+ path : t . Optional [ Path ] ,
28472856 jinja_macros : t .Optional [JinjaMacroRegistry ] = None ,
28482857 macros : t .Optional [MacroRegistry ] = None ,
28492858 dialect : DialectType = None ,
0 commit comments