feat: AsyncColonyClient (httpx) as optional [async] extra#18
Merged
jackparnell merged 1 commit intomainfrom Apr 9, 2026
Merged
feat: AsyncColonyClient (httpx) as optional [async] extra#18jackparnell merged 1 commit intomainfrom
jackparnell merged 1 commit intomainfrom
Conversation
Adds a full async mirror of ColonyClient built on httpx.AsyncClient. Every method is a coroutine, supports `async with` for connection cleanup, and shares the same JWT refresh / 401 retry / 429 backoff behaviour as the sync client. Why: downstream packages (langchain-colony, crewai-colony, mcp server) currently fake async by wrapping the sync client in `asyncio.to_thread`. That serializes through a thread pool — `asyncio.gather` of many calls gets no real concurrency. With AsyncColonyClient, fan-out is genuinely parallel via httpx connection pooling. Packaging: - httpx is an optional dependency under the [async] extra. The sync client stays zero-dep. Importing `colony_sdk.ColonyClient` does not load httpx. - `from colony_sdk import AsyncColonyClient` lazy-imports via module __getattr__, so users who never touch async never load httpx. Internals: - Extracted `_parse_error_body` and `_build_api_error` helpers in client.py so sync and async error formatting stays in lockstep. - mypy override for httpx (optional dep, not in typecheck job). Tests: - 60 new async tests using httpx.MockTransport — every method, auth flow, 401 refresh, 429 backoff (with Retry-After), network errors, registration, lifecycle (`async with` / `aclose`). - Package coverage stays at 100% (406 / 406 statements). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
ColonistOne
added a commit
that referenced
this pull request
Apr 9, 2026
Two changes that ship together so v1.5.0 can be the first release cut
via the new automation:
1. Release workflow at .github/workflows/release.yml — triggered on
`v*` tag push. Stages:
- test: runs ruff, mypy, pytest before anything else
- build: builds wheel + sdist, refuses to proceed if
the tag version doesn't match pyproject.toml
- publish: uploads to PyPI via OIDC trusted publishing
(no API token stored anywhere — short-lived
token minted by PyPI from the GitHub Actions
OIDC identity at publish time)
- github-release: extracts the matching CHANGELOG section and
creates a GitHub Release with the wheel + sdist
attached
2. Version bump 1.4.0 → 1.5.0 in pyproject.toml and __init__.py.
3. CHANGELOG: consolidated the 1.5.0 section into a clean, ordered
summary covering everything that's landed since 1.4.0:
- AsyncColonyClient (PR #18)
- Typed error hierarchy (PR #19)
- RetryConfig + 5xx default retry (PR #20)
- py.typed + verify_webhook + Dependabot (PR #21)
- Pagination iterators (PR #23)
- Coverage + Codecov (PR #17)
- This release automation
Coverage at 100% (514/514 statements). 215 tests passing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks
ColonistOne
added a commit
that referenced
this pull request
Apr 9, 2026
Two changes that ship together so v1.5.0 can be the first release cut
via the new automation:
1. Release workflow at .github/workflows/release.yml — triggered on
`v*` tag push. Stages:
- test: runs ruff, mypy, pytest before anything else
- build: builds wheel + sdist, refuses to proceed if
the tag version doesn't match pyproject.toml
- publish: uploads to PyPI via OIDC trusted publishing
(no API token stored anywhere — short-lived
token minted by PyPI from the GitHub Actions
OIDC identity at publish time)
- github-release: extracts the matching CHANGELOG section and
creates a GitHub Release with the wheel + sdist
attached
2. Version bump 1.4.0 → 1.5.0 in pyproject.toml and __init__.py.
3. CHANGELOG: consolidated the 1.5.0 section into a clean, ordered
summary covering everything that's landed since 1.4.0:
- AsyncColonyClient (PR #18)
- Typed error hierarchy (PR #19)
- RetryConfig + 5xx default retry (PR #20)
- py.typed + verify_webhook + Dependabot (PR #21)
- Pagination iterators (PR #23)
- Coverage + Codecov (PR #17)
- This release automation
Coverage at 100% (514/514 statements). 215 tests passing.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Adds
AsyncColonyClient— a full async mirror ofColonyClientbuilt onhttpx.AsyncClient. Every method is a coroutine, supportsasync with, and shares the same JWT refresh / 401 retry / 429 backoff behaviour as the sync client.Why
Downstream packages (
langchain-colony,crewai-colony, the MCP server) currently fake async by wrapping the sync client inasyncio.to_thread. That serializes through a thread pool —asyncio.gatherof many calls gets no real concurrency. WithAsyncColonyClient, fan-out is genuinely parallel via httpx connection pooling.Packaging
httpxis an optional dependency under the[async]extra. The sync client stays zero-dep.from colony_sdk import AsyncColonyClientlazy-imports via__getattr__, so users who never touch async never load httpx.pip install colony-sdk(unchanged)pip install "colony-sdk[async]"Internals
_parse_error_bodyand_build_api_errorhelpers inclient.pyso sync and async error formatting stays in lockstep — single source of truth for the error message format.httpx(optional dep, not in the typecheck job's environment).Tests
httpx.MockTransport(no network) covering every method, the auth flow, 401 refresh, 429 backoff (withRetry-After), network errors, registration, and lifecycle (async with/aclose).Example
Test plan
pytest— 137 passed, 6 skipped, 100% coverageruff checkandruff format --checkcleanmypy src/— Success