@@ -98,7 +98,9 @@ def get_module_data_from_path(path: Path) -> ModuleData:
9898 )
9999
100100
101- def get_app_name(*, mod_data: ModuleData, app_name: Union[str, None] = None, is_factory: bool = False) -> str:
101+ def get_app_name(
102+ *, mod_data: ModuleData, app_name: Union[str, None] = None, is_factory: bool = False
103+ ) -> str:
102104 try:
103105 mod = importlib.import_module(mod_data.module_import_str)
104106 except (ImportError, ValueError) as e:
@@ -140,11 +142,16 @@ def get_app_name(*, mod_data: ModuleData, app_name: Union[str, None] = None, is_
140142 return name
141143 elif callable(name) and is_factory:
142144 return name
143- raise FastAPICLIException("Could not find FastAPI app or app factory in module, try using --app")
145+ raise FastAPICLIException(
146+ "Could not find FastAPI app or app factory in module, try using --app"
147+ )
144148
145149
146150def get_import_string(
147- *, path: Union[Path, None] = None, app_name: Union[str, None] = None, is_factory: bool = False,
151+ *,
152+ path: Union[Path, None] = None,
153+ app_name: Union[str, None] = None,
154+ is_factory: bool = False,
148155) -> str:
149156 if not path:
150157 path = get_default_path()
@@ -154,7 +161,9 @@ def get_import_string(
154161 raise FastAPICLIException(f"Path does not exist {path}")
155162 mod_data = get_module_data_from_path(path)
156163 sys.path.insert(0, str(mod_data.extra_sys_path))
157- use_app_name = get_app_name(mod_data=mod_data, app_name=app_name, is_factory=is_factory)
164+ use_app_name = get_app_name(
165+ mod_data=mod_data, app_name=app_name, is_factory=is_factory
166+ )
158167 import_example = Syntax(
159168 f"from {mod_data.module_import_str} import {use_app_name}", "python"
160169 )
0 commit comments