Skip to main content

hydroid

Finds blocking calls that run on the event loop in async FastAPI (and any asyncio) code — at any call depth, across modules, through callbacks, decorators, context managers, properties and subclass overrides — and shows the whole chain.

error[blocking-http]: `requests.api.get` blocks the event loop
  --> app/main.py:12:12 in `app.main.get_user`
   = reached from route GET /users/{user_id}: app.main.get_user (app/main.py:11)
   = blocking chain (3 calls):
       app/main.py:12:12  services.load -> app.services.load
       app/services.py:7:22  fetch -> app.repo.fetch
       app/repo.py:5:16  http_get -> requests.api.get
   = help: use an async client (`httpx.AsyncClient`, `aiohttp`) or `await asyncio.to_thread(...)`

New here? Read the usage guide. Adding it to CI, or letting a coding agent set it up: CI/CD and agent setup.

Written in Rust on top of ty's semantic model (types, imports, go-to-definition). Polar's server (1,854 files, 108k call sites) takes about as long as ty needs to type-check it the first time (~10 s on 4 vCPUs), then ~0.35 s while nothing changed: extracted facts are cached in .hydroid_cache/. HYDROID_TIMINGS=1 prints where the time goes.

Install and run

With uv (prebuilt wheels for macOS, Linux, Windows; no Rust needed):

uvx --from hydroid-cli hydroid .

To install the hydroid command permanently, run uv tool install hydroid-cli (without uv: pipx install hydroid-cli or pip install hydroid-cli), then run hydroid . anywhere.

From the source on main (builds once with a Rust toolchain, then cached): uvx --from git+https://github.com/agusmdev/hydroid hydroid .. From a clone: cargo install --path crates/hydroid. More in the guide.

hydroid path/to/project                 # finds .venv / VIRTUAL_ENV like ty
hydroid . --python .venv --format sarif > hydroid.sarif
Flag
--python PATH virtualenv or interpreter to resolve imports (default: discovered)
--follow-libs also analyze third-party function bodies
--cpu also report CPU-bound calls (bcrypt, pbkdf2, scrypt)
--strict report calls on the loop whose target is unknown, and fail on them
--exclude GLOB skip files (repeatable)
--no-cache do not read or write .hydroid_cache/
--format human|json|sarif output

Exit status: 0 clean, 1 findings (or unresolved calls with --strict), 2 error. Suppress a line with # hydroid: ignore.

Configuration in pyproject.toml (flags win):

[tool.hydroid]
python = ".venv"
exclude = ["migrations/**"]
strict = false

[[tool.hydroid.sink]]            # your own blocking functions (defining qualified names)
category = "sdk"
advice = "use the async client"
functions = ["acme.client.Client.fetch"]

CI/CD and agent setup

hydroid exits 1 when it finds blocking calls, so it can gate a build as is. On GitHub, --format sarif puts each blocking chain on the pull request through code scanning:

# .github/workflows/hydroid.yml
name: hydroid
on: [push, pull_request]
jobs:
  hydroid:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v6
      - run: uv sync                      # hydroid needs the project's dependencies installed
      # Optional: pin a version for reproducible builds, e.g. hydroid-cli==0.2.0
      - run: >-
          uvx --from hydroid-cli
          hydroid . --format sarif > hydroid.sarif || [ $? -eq 1 ]
      - uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: hydroid.sarif

|| [ $? -eq 1 ] reports findings without failing the job (exit 2, an error, still fails it); drop it and the upload step to fail the build instead.

docs/AGENT_SETUP.md has:

  • a prompt to paste into a coding agent (Claude Code, Cursor, Codex…) that installs hydroid in your repository, configures [tool.hydroid], triages the existing findings (fix, # hydroid: ignore with a reason, or report to you) and adds the CI job;
  • configs for GitLab CI, pre-commit, monorepos, projects not using uv, and other CI systems;
  • a path for adopting it on a code base with existing findings: report-only first, then gate.

How it works

  1. Facts (crates/hydroid_ty, the only crate that touches ty): every function body is walked in parallel, and each call is resolved through ty to the functions it can run, implicit calls included (with, for, properties, descriptors, operators, constructors). Callables passed as arguments, stored on instances or returned are recorded as flows. What a library does that its source does not show (stub-only stdlib, frameworks calling project code later) comes from the catalog. The facts of an unchanged project are reused from .hydroid_cache/.
  2. Analysis (crates/hydroid_core, plain graph code): "does calling f block?" is computed once per function by a backwards search from blocking functions, giving shortest witness chains. Diagnostics are the call sites in loop code (async def bodies, callbacks the loop runs, code a framework runs on the loop around an entry point) whose callee blocks. Offload APIs cut the graph. Overrides are found by class hierarchy, narrowed by what is known about the instance (or argument). Generators run when iterated, not when called.
  3. Catalog (crates/hydroid_core/catalog.toml): library knowledge as data, by defining qualified name. It covers:
    • what blocks, and what offloads or schedules on the loop;
    • what functions do with their arguments;
    • framework entry points and what the framework runs around them;
    • model hooks, observers (logging), exit stacks, running-loop probes, lazily loaded attributes, and state namespaces. Library knowledge goes here, not in the Rust code. Every table can be extended from pyproject.toml, and a test checks that every name exists in a real environment.

Sync def endpoints and dependencies are not reported: FastAPI runs them in a threadpool. The details, and what hydroid knowingly misses: docs/GUIDE.md.

Limits

Python is dynamic: calls through getattr, untyped parameters, or registries of callables filled at run time cannot always be resolved. --strict lists every one reachable on the loop (except awaited calls, assumed to run a coroutine). A call on a value typed as a Protocol or ABC resolves to the abstract method, so the real implementation can be missed. What hydroid knowingly misses, and why: docs/GUIDE.md.

Development

cargo test --workspace        # needs `uv`; syncs tests/fixtures/.venv from uv.lock
scripts/corpus.sh [names]     # Polar, mealie, lnbits, dispatch, litellm, open-webui, template

Fixture cases live in tests/fixtures/cases/*; expectations are inline comments: # expect: time.sleep via route GET /x, # expect: * (any blocking function), # expect-unresolved.

tests/adversarial/ is a suite of cases written to break hydroid, split into a training half (required to pass, by cargo test) and a held-out half that is only scored:

scripts/hillclimb/score.py --split train            # misses and false positives, per case
scripts/hillclimb/score.py --split holdout --quiet  # aggregate only: don't tune on it
scripts/hillclimb/polar_time.sh target/release/hydroid 5
uv run --with anthropic scripts/hillclimb/adversary.py --count 5   # Claude proposes new cases
scripts/hillclimb/oracle.py PROJECT report.json   # naive syntactic scan: candidate misses

ty's crates are pinned to exact versions (=0.0.15); they have no API stability promise. The bundled typeshed stubs are Apache-2.0; hydroid is MIT.

Releases: docs/RELEASING.md.

Metadata

Release files for hydroid-cli 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydroid-cli 0.3.0
File Size Uploaded Provenance Actions
hydroid_cli-0.3.0.tar.gz 163.7 kB With provenance Details for hydroid_cli-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for hydroid-cli 0.3.0
File Actions
hydroid_cli-0.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for hydroid_cli-0.3.0-py3-none-win_amd64.whl
hydroid_cli-0.3.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for hydroid_cli-0.3.0-py3-none-musllinux_1_2_x86_64.whl
hydroid_cli-0.3.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for hydroid_cli-0.3.0-py3-none-musllinux_1_2_aarch64.whl
hydroid_cli-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for hydroid_cli-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
hydroid_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for hydroid_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
hydroid_cli-0.3.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for hydroid_cli-0.3.0-py3-none-macosx_11_0_arm64.whl
hydroid_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for hydroid_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 75.2 MB

Release files / hydroid_cli-0.3.0.tar.gz

Download URL hydroid_cli-0.3.0.tar.gz
Size 163.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0d43d313a9f59da2c9d4c8bd302c637cceeaca1afd5dd2925e705d15fb917a93
BLAKE2b-256 checksum
How to use checksums
51d99d699017ae3889efbb1383ba9f83937ca3f799515cd5dd4b64e7556f04aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-win_amd64.whl

Download URL hydroid_cli-0.3.0-py3-none-win_amd64.whl
Size 11.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
077779b6ab0b8a22227ee8754e8c38e26de3cbfa25782ba8478d1c33328f156a
BLAKE2b-256 checksum
How to use checksums
e94369b3416e39f4a17cf274e3de10b4f49f46755791c707c33137a320430611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-musllinux_1_2_x86_64.whl

Download URL hydroid_cli-0.3.0-py3-none-musllinux_1_2_x86_64.whl
Size 11.1 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b8d335315b0804f89ef6054973f8d58ccec77ed706aa1aa102dc6c22dfc617e4
BLAKE2b-256 checksum
How to use checksums
95f9da89226e8435909b2347eaf1b3a7f09dea184999300a42ef0897e7fc1bf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-musllinux_1_2_aarch64.whl

Download URL hydroid_cli-0.3.0-py3-none-musllinux_1_2_aarch64.whl
Size 10.3 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
f18c8e36eac4e813e88ac0f769853be8c2d3b3f9f1e73ba959c6e56fe1e77de5
BLAKE2b-256 checksum
How to use checksums
f75ae8ca0aedaf5c077166d1955faa940bf35ea0418f9d6388f0f127b8997b18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL hydroid_cli-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 11.0 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
18cdcb47489d57c6c73538c16b36092b1e59baf5c1fa3c0aa798101753603a9c
BLAKE2b-256 checksum
How to use checksums
c975a0fcc1ef25c8703ffd38ff5ebe74589659584aa723bc65956ef23feb2937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL hydroid_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 10.4 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
7d1703eb7385e9e99d1fa3e2686ea4b81b1a83ad7753ebc65c09bbb320e88611
BLAKE2b-256 checksum
How to use checksums
c5946c568e3dcb11f71b56a2a2b357828035f9ed9233eb26d5342e56dda74d38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-macosx_11_0_arm64.whl

Download URL hydroid_cli-0.3.0-py3-none-macosx_11_0_arm64.whl
Size 10.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
44e94dbf3dd3a8c6952c1bd1b85a6d94f0042c1460101c61d397e6df85925052
BLAKE2b-256 checksum
How to use checksums
872ae58e02694399fd9f98bd701faa805f088008343a4fbb606c592c6ceb6db9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / hydroid_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl

Download URL hydroid_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl
Size 10.8 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
c8e279009d069c6052f74fb40a88b37955256d9dc442d95a9ad91a369e3568a5
BLAKE2b-256 checksum
How to use checksums
498517db5cb10942d56dfb852b2e93bb606557a22364ac1771b004aaeb874b13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for hydroid-cli 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for hydroid_cli-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page