fix(cli): optional cli_main type for both with/without fastapi[standard] so pre-commit passes in CI

Made-with: Cursor
This commit is contained in:
essentiaMarco 2026-03-15 17:30:20 -07:00
parent c046d33b27
commit 948972625d
1 changed files with 6 additions and 3 deletions

View File

@ -1,12 +1,15 @@
from collections.abc import Callable
cli_main: Callable[[], None] | None = None
try:
from fastapi_cli.cli import main as cli_main # type: ignore[import-not-found]
from fastapi_cli.cli import main as cli_main
except ImportError: # pragma: no cover
cli_main = None
pass
def main() -> None:
if not cli_main:
if cli_main is None:
message = 'To use the fastapi command, please install "fastapi[standard]":\n\n\tpip install "fastapi[standard]"\n'
print(message)
raise RuntimeError(message) # noqa: B904