Skip to content
Blog

Production Python for ADK Projects: uv, ruff, and mypy Setups That Scale

A pragmatic toolchain for ADK codebases — uv for fast environments, ruff for linting and formatting, mypy for typing agents and tools — with configs tuned for agent projects.

Published on • November 25, 2026

AI Assistant

Agent projects start as scripts and end up as systems: tools calling services, callbacks mutating state, five model connectors, and a test suite that someone has to trust before every deploy. At that point the toolchain stops being cosmetic. uv keeps environments reproducible and CI fast; ruff catches the mistakes agents make most (unused state, shadowed names, wrong argument order in a tool signature); mypy type-checks the seams between your code and ADK’s typed API.

This is the setup I’d use for an ADK project that has to survive six months of feature work.

uv: environments in milliseconds

uv is an extremely fast Python package and project manager — resolver, installer, virtualenv, and script runner in one Rust binary. For an ADK project:

# install uv, then:
uv init my-adk-agent        # scaffold a project
cd my-adk-agent
uv add google-adk           # dependency + lockfile in one step
uv add --dev pytest ruff mypy httpx
uv run python -m google.adk.cli web   # run the ADK dev UI inside the env

The two features that matter most:

  • uv.lock pins everything transitively. Commit it. “Works on my machine” bugs from conflicting transitive deps disappear, and CI installs are cached to sub-second.
  • uv run removes the activate-step. Every command runs inside the project environment explicitly — no shell state, no forgotten venv.
# pyproject.toml
[project]
name = "my-adk-agent"
requires-python = ">=3.10"
dependencies = ["google-adk>=1.14"]

[dependency-groups]
dev = ["pytest", "pytest-asyncio", "ruff", "mypy", "httpx"]

For CI, uv sync --frozen --group dev guarantees the lockfile wasn’t quietly edited.

ruff: one tool for lint + format

ruff replaces flake8, isort, pyupgrade, and black in a single binary. Agent code benefits from a few specific rules — you’re constantly creating objects that are never used and functions whose signatures are the model’s API.

# pyproject.toml
[tool.ruff]
line-length = 100
target-version = "py310"

[tool.ruff.lint]
select = [
  "E", "W",      # pycodestyle
  "F",           # pyflakes — unused vars, undefined names
  "I",           # import sorting
  "UP",          # pyupgrade
  "B",           # bugbear — dangerous defaults, unsafe operations
  "ASYNC",       # async pitfalls — blocking calls in async tools
  "SIM",         # simplifications
]
ignore = ["E501"]   # line length handled by the formatter

[tool.ruff.format]
quote-style = "single"

Two selections earn their keep in agent projects:

  • ASYNC flags blocking calls inside async def tools — the classic way a single slow tool freezes the entire event loop (see timeouts and deadlines).
  • B catches mutable default arguments and other subtle bugs in tool functions that get invoked hundreds of times per run.
uv run ruff check --fix .
uv run ruff format .

mypy: type-check the seams

Full strict mode on a codebase full of untyped third-party calls is a slog. Target strictness at the boundaries instead:

# pyproject.toml
[tool.mypy]
python_version = "3.10"
plugins = []
check_untyped_defs = true
disallow_untyped_defs = true      # every function you write gets annotations
no_implicit_optional = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = "google.adk.*"
ignore_missing_imports = true     # tighten once you confirm the shipped stubs

Where typing pays off immediately in ADK code:

from typing import TypedDict

class InventoryResult(TypedDict):
    sku: str
    stock: int | None
    error: str | None

def lookup_inventory(sku: str) -> InventoryResult:
    ...

The model reads this signature to decide how to call the tool, and mypy enforces that every return path matches it — a mismatch that would otherwise surface as a runtime surprise during someone’s conversation. For Pydantic response schemas, mypy validates your schema classes before the model ever sees them (the subject of structured outputs with output_schema).

The pre-commit and CI gate

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.9.0
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.14.0
    hooks:
      - id: mypy
        additional_dependencies: [pydantic]

And in CI, the same commands with an explicit order — fast checks first:

uv sync --frozen --group dev
uv run ruff check .
uv run ruff format --check .
uv run mypy src/
uv run pytest -q

Fail the build on any of them. The whole suite should run in well under a minute on cached dependencies; that speed is precisely why uv is worth adopting.

Testing agent code specifically

# pyproject.toml
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]

Layer your tests like the system itself:

  • Unit: tools with fake clients — no network, no ADK runtime.
  • Agent: a real Agent with a stubbed model response; assert on events and state deltas.
  • Integration: InMemoryRunner end-to-end for a scripted scenario.
  • Smoke (staging): one live run against the real model, gated by an env flag.

Because storage and model access were injected rather than imported, the first three layers need zero network — which keeps CI honest and fast.

House rules that keep it working

  1. Lock and commit uv.lock. Upgrades become deliberate pull requests.
  2. Pin google-adk. It’s an active project; upgrade intentionally, read deprecations (workflow agents → graph workflows, for example).
  3. Typed tool signatures = model API. Annotate them like a public interface, because they are one.
  4. No # type: ignore without a reason. warn_unused_ignores enforces hygiene.
  5. Run the gate locally the way CI runs it. A pre-commit hook that diverges from CI is worse than none.

Where to go next

Tooling is the scaffold around the code — the code itself benefits from design patterns like pipelines and swarms, and the whole system from enterprise reliability practices. For what exactly to type, the ADK package anatomy maps every module you’ll import.

References