Skip to content

feat!: Migrate from httpx to httpx2 and drop Python 3.9 - #1

Closed
fornwall wants to merge 1 commit into
mainfrom
httpx2
Closed

fornwall wants to merge 1 commit into
mainfrom
httpx2

Conversation

@fornwall

@fornwall fornwall commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Replaces the httpx[http2] == 0.28.1 dependency with httpx2[http2] == 2.13.1, Pydantic's maintained fork of httpx.

Its only API change is the package rename (httpx → httpx2, httpcore → httpcore2), so the code change is mechanical: imports and httpx.X references in _http_client.py, _retry.py, _utils.py, messaging.py and the tests. Internal helper names such as handle_platform_error_from_httpx are unchanged.

Breaking: Python 3.9 dropped

httpx2 requires Python >= 3.10 (it dropped 3.9 in 2.1.0), so:

  • setup.py: python_requires='>=3.10', version guard and classifiers updated
  • CI matrix: 3.10–3.13 + pypy3.10 (was 3.9–3.13 + pypy3.9); lint, release and nightly jobs now use 3.10
  • README / CONTRIBUTING updated

Is this ok to do now, considering that python 3.9 went EOL at 2025-10?

Test setup: respx

respx only patches the httpx module (and still pulls it in as a dependency), so tests/test_retry.py would otherwise make unmocked requests. tests/conftest.py calls httpx2.alias_httpx() so import httpx resolves to httpx2 and respx patches the classes the SDK uses. The respx pytest plugin is disabled via addopts = -p no:respx in setup.cfg, since it imports httpx at startup before conftest can alias it; no test uses its respx_mock fixture.

Other behaviour changes from httpx2

  • User-Agent changes from python-httpx/… to python-httpx2/…; the logger is now named httpx2
  • TLS verification uses the OS trust store via truststore instead of certifi

Replace httpx with httpx2, update imports and documentation, and alias httpx in tests so RESPX mocks intercept requests. Disable the RESPX pytest plugin to ensure aliasing happens before import.

Update packaging, CI workflows, and documentation to require Python 3.10 or newer.

BREAKING CHANGE: Python 3.9 is no longer supported.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant