Files
google--adk-python/.agents/skills/adk-style/references/imports.md
T
wehub-resource-sync ec2b666284
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:25:13 +08:00

1.2 KiB

Imports Style Guide

General Rules

  • Source code (src/): Use relative imports. from ..agents.llm_agent import LlmAgent
  • Tests (tests/): Use absolute imports. from google.adk.agents.llm_agent import LlmAgent
  • Import from module: Import from the module file, not from __init__.py. from ..agents.llm_agent import LlmAgent (not from ..agents import LlmAgent)
  • CLI package (cli/):
    • Treat as an external package.
    • Use relative imports for files within the cli/ package.
    • Use absolute imports for files outside of the cli/ package.
    • Dependency Direction: Only cli/ can import from the rest of the codebase. The other codebase must STRICTLY NOT import from cli/.

TYPE_CHECKING Imports

Use TYPE_CHECKING for imports needed only by type hints to avoid circular imports at runtime:

from __future__ import annotations
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from ..agents.invocation_context import InvocationContext

This works because from __future__ import annotations makes all annotations strings (deferred evaluation), so the import is never needed at runtime.