[HTTPXodus] migrate httpx to httpx2 with dual import - #807
[HTTPXodus] migrate httpx to httpx2 with dual import#807ProgrammerPlus1998 wants to merge 1 commit into
Conversation
Refs: HTTPXodus campaign
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit e8b9a12. Configure here.
| aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"} | ||
| fastavro = "^1.9.4" | ||
| httpx = ">=0.25.0" | ||
| httpx2 = { version = "^2.12", python = "^3.10" } |
There was a problem hiding this comment.
Production never switches to httpx2
High Severity
httpx2 is added as a required dependency, but production still imports httpx and builds httpx.Client in the core client, AWS/OCI transports, and SSE helpers. The dual-import lives only in a unit test, so the SDK never runs on httpx2 and every installer now pulls an unused package.
Reviewed by Cursor Bugbot for commit e8b9a12. Configure here.
| aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"} | ||
| fastavro = "^1.9.4" | ||
| httpx = ">=0.25.0" | ||
| httpx2 = { version = "^2.12", python = "^3.10" } |
There was a problem hiding this comment.
Lockfile omits new httpx2 dependency
Medium Severity
httpx2 was added to pyproject.toml without updating poetry.lock. poetry install follows the stale lock and will not install httpx2, so CI keeps using the httpx fallback. Poetry 2.x, which generated this lockfile, also errors when the content-hash no longer matches.
Reviewed by Cursor Bugbot for commit e8b9a12. Configure here.


Closes #806
What this PR does
This is the implementation of the migration discussed in #806. It switches
cohere-ai/cohere-python's HTTP client fromhttpxtohttpx2via dual import: on Python ≥ 3.10 the runtime binds tohttpx2; on 3.9 the import falls back tohttpx.requires-pythonis not changed.Diff summary
N files, +A / −B (commit
e8b9a123):pyproject.tomlhttpx2>=2.12.0; python_version >= "3.10"next to the existinghttpxruntime depcohere/**import httpx→ dual import (Option A)The public API surface is preserved because the dual-import alias keeps the name
httpxeverywhere. No call-site changes are needed beyond the import.Test results
Validated in a fresh venv on Python 3.12 with both
httpxandhttpx2installed (SUT resolves tohttpx2):pip install -e ".[dev]"resolves to bothpython -c "import cohere; ..."smoke test passesNotes for reviewer
httpx.Client/httpx.AsyncClient/httpx.Response.raise_for_status()types used incohere-pythonexist in bothhttpxandhttpx2with identical signatures, so no call-site changes are needed beyond the import.httpx2verifies TLS against the OS trust store instead of the bundledcertifi. Cohere SDK deployments that rely on a custom CA bundle may needSSL_CERT_FILE/SSL_CERT_DIRafter the switch. Worth a line in the changelog.requires-pythonfloor is belowhttpx2's>=3.10floor, and dropping 3.9 would be out of scope. If cohere-python later raises the floor, this can be replaced with a hardimport httpx2 as httpxin a follow-up.Happy to revise per review — and equally happy to close this PR if the maintainers would rather wait for
httpx1.0 stable. 🙏