From 8540e92dc15d2447095dad45c9d0a7750df129f4 Mon Sep 17 00:00:00 2001 From: chelsealong Date: Sat, 8 Aug 2026 11:10:29 +0000 Subject: [PATCH] fix(cli): use explicit re-export in __init__.py generated by adk create Ruff's F401 flags `from . import agent` as an unused import even though the import is intentional to make the agent module discoverable. Use the redundant-alias form `from . import agent as agent`, which Ruff recognizes as an explicit re-export, so generated projects pass common lint configs without extra suppressions. Fixes #6648 --- src/google/adk/cli/cli_create.py | 2 +- tests/unittests/cli/utils/test_cli_create.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/google/adk/cli/cli_create.py b/src/google/adk/cli/cli_create.py index 3e5a5b0ed9b..9d3f0118807 100644 --- a/src/google/adk/cli/cli_create.py +++ b/src/google/adk/cli/cli_create.py @@ -23,7 +23,7 @@ from .utils import _onboarding _INIT_PY_TEMPLATE = """\ -from . import agent +from . import agent as agent """ _AGENT_PY_TEMPLATE = """\ diff --git a/tests/unittests/cli/utils/test_cli_create.py b/tests/unittests/cli/utils/test_cli_create.py index 98e0a92f889..bcb45218fe9 100644 --- a/tests/unittests/cli/utils/test_cli_create.py +++ b/tests/unittests/cli/utils/test_cli_create.py @@ -71,7 +71,9 @@ def test_generate_files_with_api_key(agent_folder: Path) -> None: assert "GOOGLE_GENAI_USE_ENTERPRISE=0" in env_content assert (agent_folder / ".gitignore").read_text() == ".env\n" assert (agent_folder / "agent.py").exists() - assert (agent_folder / "__init__.py").exists() + assert ( + agent_folder / "__init__.py" + ).read_text() == "from . import agent as agent\n" def test_generate_files_with_gcp(agent_folder: Path) -> None: