@@ -172,6 +172,10 @@ def get_table_classes(self, app_name: str) -> t.List[t.Type[Table]]:
172172 """
173173 Returns each Table subclass defined in the given app if it exists.
174174 Otherwise raises a ValueError.
175+
176+ :raises ValueError:
177+ If an AppConfig can't be found for the given app_name.
178+
175179 """
176180 app_config = self .get_app_config (app_name = app_name )
177181 if not app_config :
@@ -186,9 +190,12 @@ def get_table_with_name(
186190 Otherwise raises a ValueError.
187191 """
188192 app_config = self .get_app_config (app_name = app_name )
189- return app_config .get_table_with_name (
190- table_class_name = table_class_name
191- )
193+ if app_config is None :
194+ raise ValueError (f"Can't find an app_config for { app_name } " )
195+ else :
196+ return app_config .get_table_with_name (
197+ table_class_name = table_class_name
198+ )
192199
193200
194201class PiccoloConfModule (ModuleType ):
@@ -270,10 +277,8 @@ def get_piccolo_conf_module(
270277 if not module_name :
271278 module_name = DEFAULT_MODULE_NAME
272279
273- module : t .Optional [PiccoloConfModule ] = None
274-
275280 try :
276- module = import_module (module_name )
281+ module = t . cast ( PiccoloConfModule , import_module (module_name ) )
277282 except ModuleNotFoundError :
278283 if self .diagnose :
279284 colored_warning (
@@ -284,8 +289,9 @@ def get_piccolo_conf_module(
284289 level = Level .high ,
285290 )
286291 print (traceback .format_exc ())
287-
288- return module
292+ return None
293+ else :
294+ return module
289295
290296 def get_app_registry (self ) -> AppRegistry :
291297 """
0 commit comments