Migrate HTTP client from httpx to httpx2 #25
Labels
No labels
bug
contribution welcome
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
marvin8/zaojun#25
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
httpx has seen limited upstream activity. Pydantic's fork httpx2 (v2.4.0) provides a maintained path forward with the same API surface, including HTTP/2 and zstd support.
This replaces
httpx[http2]~=0.28.1withhttpx2[http2]~=2.4.0and updates all import sites in the source and test layers.Exploration findings
Current usage in
src/zaojun/__init__.py:import httpx(line 16)httpx.AsyncClientin 5 type annotations and 1 context managerhttpx.HTTPStatusErrorandhttpx.RequestErrorin one exception handler (line 983)Test layer:
tests/test_get_latest_pypi_version.pyandtests/test_vulns.py: usehttpx_mockfixture frompytest-httpx, which is pinned tohttpx==0.28.*tests/test_check_dependency.py: usesAsyncMockdirectly, only needsfrom httpx import HTTPStatusErrorupdatedPlan of attack
pyproject.tomlpytest group (pytest-httpx→pytest-httpx2~=1.0.0), migrate all three test files tohttpx2imports and the respx-backedhttpx2_mockfixture. Tests fail because the implementation still importshttpx.httpx[http2]~=0.28.1→httpx2[http2]~=2.4.0) and replace allhttpxreferences insrc/zaojun/__init__.py. Full suite passes.Note:
pytest-httpx2is a thin respx wrapper; if its transport patching doesn't intercept httpx2 calls, the fallback is a hand-writtenhttpx2.AsyncBaseTransportmock.