Migrate SDK HTTP stack to httpx2 - #256
Conversation
doistbot
left a comment
There was a problem hiding this comment.
This PR updates Migrate SDK HTTP stack to httpx2. No issues were flagged in the reviewed diff.
doistbot
left a comment
There was a problem hiding this comment.
This PR updates Migrate SDK HTTP stack to httpx2. No issues were flagged in the reviewed diff.
PotHix
left a comment
There was a problem hiding this comment.
Looks reasonable to me. The fact that it's under pydantic now is a plus 👍
There was a problem hiding this comment.
🔵 Needs a closer look
It changes a core dependency and the HTTP/test stack end-to-end, and correctness depends on external package/API compatibility that can’t be fully verified from the diff alone.
Pull request overview
This PR migrates the SDK’s HTTP layer from httpx to httpx2, updating both the public injected-client types and the test harness so the codebase depends on the actively maintained fork.
Changes:
- Swapped runtime dependency from
httpx>=0.28.1,<1tohttpx2>=2.0.0,<3and refreshed the lockfile. - Updated sync/async client injection points, request helpers, and raised-exception documentation to reference
httpx2types. - Routed RESPX-backed tests through the
pytest-httpx2plugin and updated docs/changelog to match.
File summaries
| File | Description |
|---|---|
| uv.lock | Updates resolved dependency graph to include httpx2/httpcore2 and adds pytest-httpx2 to dev dependencies. |
| todoist_api_python/authentication.py | Switches optional injected clients and managed client factories to httpx2 sync/async clients. |
| todoist_api_python/api.py | Migrates the sync API client’s injected-client type and docstrings to httpx2. |
| todoist_api_python/api_async.py | Migrates the async API client’s injected-client type and docstrings to httpx2. |
| todoist_api_python/_core/http_requests.py | Moves request helpers and TIMEOUT configuration to httpx2 types. |
| tests/test_http_requests.py | Updates request-helper tests to use httpx2 and catch httpx2.HTTPStatusError. |
| tests/conftest.py | Adds a respx_mock fixture that aliases the pytest-httpx2 provided mock fixture. |
| README.md | Updates migration guidance to reference httpx2 client types and exceptions. |
| pyproject.toml | Replaces httpx dependency with httpx2 and adds pytest-httpx2 to dev dependencies. |
| docs/index.md | Updates documentation to reference httpx2.AsyncClient. |
| CHANGELOG.md | Documents the breaking change and updates httpx references to httpx2. |
Review details
- Files reviewed: 10/11 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Replace
httpxwithhttpx2to improve maintenance and supply chain posture.httpx2is a fork ofhttpx0.28.1 with essentially the same public API, now under active Pydantic stewardship. Pydantic explicitly says (see the top of the README) it took over becausehttpxhad seen limited activity and a critical-path HTTP library needs timely security updates.httpxis not archived, and the author is promising a from-scratch rewrite, but they're working in private and with no ETA in sight. Plus, the maintainer closed access to issues and discussions around February 2026. Overall, a terrible look and a supply chain risk, even ifhttpxworks well today.Changes
httpxruntime dependency withhttpx2>=2.0.0,<3httpx2pytest-httpx2pluginCompatibility
This is a breaking change for callers that pass an
httpx.Clientorhttpx.AsyncClientor catchhttpxexceptions:httpxandhttpx2expose distinct classes, so those objects and exception handlers must move tohttpx2too.That said, we have yet to officially release any version with
httpx, so there is no breaking change per se. The first release with true async support would just usehttpx2.In other words, no compatibility issues—we should ship a new major soon.