Conversation
There was a problem hiding this comment.
Code Review
This pull request bumps the minimum supported Python version to 3.10 and migrates the HTTP client library from httpx to httpx2 across the codebase, including the core HTTP client, retry logic, messaging module, and test suite. To support this migration, a pytest configuration was added to alias httpx2 before respx is imported. The review feedback suggests avoiding pinning the httpx2 dependency to an exact version in setup.py to prevent dependency conflicts for downstream applications, recommending a compatible range instead.
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>
This branch has not been deployed
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.
Replaces the
httpx[http2] == 0.28.1dependency withhttpx2[http2] == 2.13.1, Pydantic's maintained fork ofhttpx.Its only API change is the package rename (
httpx→httpx2,httpcore→httpcore2), so the code change is mechanical: imports andhttpx.Xreferences in_http_client.py,_retry.py,_utils.py,messaging.pyand the tests. Internal helper names such ashandle_platform_error_from_httpxare 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 updated3.10–3.13+pypy3.10(was3.9–3.13+pypy3.9); lint, release and nightly jobs now use 3.10Is this ok to do now, considering that python 3.9 went EOL at 2025-10?
Test setup: respx
respx only patches the
httpxmodule (and still pulls it in as a dependency), sotests/test_retry.pywould otherwise make unmocked requests.tests/conftest.pycallshttpx2.alias_httpx()soimport httpxresolves to httpx2 and respx patches the classes the SDK uses. The respx pytest plugin is disabled viaaddopts = -p no:respxinsetup.cfg, since it importshttpxat startup before conftest can alias it; no test uses itsrespx_mockfixture.Other behaviour changes from httpx2
User-Agentchanges frompython-httpx/…topython-httpx2/…; the logger is now namedhttpx2truststoreinstead ofcertifiAI disclaimer: Created with gpt-6 astra using codex. Iterated on and reviewed by me.