From db0cf656fc2af97867c16971c8c96a5a77adb8bc Mon Sep 17 00:00:00 2001 From: Waket Zheng Date: Wed, 26 Feb 2025 17:27:05 +0800 Subject: [PATCH] chore: show friendly message when config missing 'apps' section --- aerich/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aerich/cli.py b/aerich/cli.py index 3f30e64..53170da 100644 --- a/aerich/cli.py +++ b/aerich/cli.py @@ -63,7 +63,10 @@ async def cli(ctx: Context, config, app) -> None: add_src_path(src_folder) tortoise_config = get_tortoise_config(ctx, tortoise_orm) if not app: - apps_config = cast(dict, tortoise_config.get("apps")) + try: + apps_config = cast(dict, tortoise_config["apps"]) + except KeyError: + raise UsageError('Config must define "apps" section') app = list(apps_config.keys())[0] command = Command(tortoise_config=tortoise_config, app=app, location=location) ctx.obj["command"] = command