@@ -497,19 +497,25 @@ def snapshots(self) -> t.Dict[str, Snapshot]:
497497 return self ._snapshots
498498
499499 @property
500- def this_env (self ) -> t . Optional [ str ] :
500+ def this_env (self ) -> str :
501501 """Returns the name of the current environment in before after all."""
502- return self .locals .get ("this_env" )
502+ if "this_env" not in self .locals :
503+ raise SQLMeshError ("Environment name is not available in this context" )
504+ return self .locals ["this_env" ]
503505
504506 @property
505- def schemas (self ) -> t .Optional [ t . List [str ] ]:
507+ def schemas (self ) -> t .List [str ]:
506508 """Returns the schemas of the current environment in before after all macros."""
507- return self .locals .get ("schemas" )
509+ if "schemas" not in self .locals :
510+ raise SQLMeshError ("Schemas are not available in this context" )
511+ return self .locals ["schemas" ]
508512
509513 @property
510- def views (self ) -> t .Optional [ t . List [str ] ]:
514+ def views (self ) -> t .List [str ]:
511515 """Returns the views of the current environment in before after all macros."""
512- return self .locals .get ("views" )
516+ if "views" not in self .locals :
517+ raise SQLMeshError ("Views are not available in this context" )
518+ return self .locals ["views" ]
513519
514520 def var (self , var_name : str , default : t .Optional [t .Any ] = None ) -> t .Optional [t .Any ]:
515521 """Returns the value of the specified variable, or the default value if it doesn't exist."""
0 commit comments