fix(cli): use explicit re-export in __init__.py generated by adk create - #6650
Open
chelsealong wants to merge 1 commit into
Open
fix(cli): use explicit re-export in __init__.py generated by adk create#6650chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
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 google#6648
ftnext
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6648
Problem
adk creategenerates an__init__.pyfor code-based agents containing:This import is intentional — it makes the
agentmodule (and itsroot_agent) discoverable — but Ruff'sF401rule flags it as anunused import in downstream projects, since the intent isn't expressed
explicitly.
Fix
Generate an explicit re-export instead, using the redundant-alias form
that Ruff recognizes as intentional:
This preserves the existing runtime behavior while making the
re-export explicit to linters, so newly generated agent projects pass
common lint configs without suppressions.
Testing plan
Updated
test_generate_files_with_api_keyintests/unittests/cli/utils/test_cli_create.pyto assert the exactgenerated
__init__.pycontent instead of just its existence.Verified the test fails without the fix (reverted the one-line source
change while keeping the updated test):
With the fix restored:
Full
tests/unittests/clisuite also passes:pre-commit run --files src/google/adk/cli/cli_create.py tests/unittests/cli/utils/test_cli_create.pypasses cleanly (ruff, isort, pyink, addlicense, ADK compliance checks).
AI assistance disclosure
This change was drafted with AI assistance (Claude Code) and reviewed
before submission.