.agents/skills/adk-style/references/typing.md
Any: Use specific types or Generic whenever possible. Avoid Any as it bypasses type checking.from __future__ import annotations is present, use bare type names (e.g., list[str] instead of "list[str]").from __future__ import annotations: Every source file must include this immediately after the license header, before any other imports. This enables forward-referencing classes without quotes (PEP 563).Optional[X] vs X | NoneThe codebase uses both styles. Follow this convention:
workflow/): Prefer X | None — it is more concise and modern.Use abstract types from collections.abc for function parameter annotations. This accepts the widest range of inputs while remaining type-safe. Use concrete types for return annotations to give callers the most useful information.
Use * to force keyword-only arguments on functions with multiple parameters of the same type, or where argument order is error-prone. This is a widely used pattern in ADK (16+ files).
When to use *:
__init__) with 2+ non-self parametersstr or int parametersNever use mutable default arguments. Use None as a sentinel and initialize in the function body. This is a well-followed pattern throughout ADK.
This applies to list, dict, set, and any other mutable type.
isinstance()Use isinstance() for runtime type discrimination when handling polymorphic inputs. This is pervasive in ADK (700+ usages). Prefer exhaustive if/elif chains with a clear fallback.
Guidelines:
else branch that raises TypeError or handles the unknown case.isinstance(x, SomeType) over type(x) is SomeType — it handles subclasses correctly.isinstance(x, (TypeA, TypeB)).