Repository navigation
Feature: add httpx2 support with httpx fallback - #328
CoderJoshDK wants to merge 4 commits into
Conversation
Deprecate the use of httpx in favor of httpx2.
There was a problem hiding this comment.
Aware that this file is a bit funky. Honestly, this test can be removed IMO. But up to you.
There was a problem hiding this comment.
I think this test could be removed. Instead, running all other tests without httpx2 in the env (using httpx) seems more meaningful.
There was a problem hiding this comment.
Do you want to test like pydantic is done? I ended up having it only test 1 time in the matrix because it seems excessive to me to run it for everything. But that can be done too.
| "anyio >=3.6.1, <5.0.0", | ||
| "httpx >=0.23.0, <1.0.0", | ||
| "hishel[async,httpx] >=1.3.0, <=2.0.0", | ||
| "hishel[async,httpx] >=1.4.0, <=2.0.0", |
There was a problem hiding this comment.
Bump here because this is the first version that supports httpx2. I want to avoid a really strange case where you somehow have httpx2 but not the version of hishel that supports it and you get a super strange import error / explosion. This also makes the _httpx.py file a bit more reliable in its try-except.
|
I am working on some important $DAYJOB things today. But after work, I will do the pyproject change you wanted and look into the failing CI. Please give me any other changes you want me to tackle (if you have any) and I will do them tonight! |
Have a test run with httpx instead of httpx2
| - name: Use httpx without httpx2 | ||
| if: matrix.http-client == 'httpx' | ||
| run: uv pip uninstall httpx2 | ||
|
|
There was a problem hiding this comment.
I think this can be achieved by adding an environment variable within githubkit to force the use of httpx. FYI, like this.
| GitHubKit installs HTTPX by default to preserve compatibility with existing transports. It prefers [HTTPX2](https://pydantic.dev/docs/httpx2/) when you install it separately. The default HTTPX path remains supported, but emits a `DeprecationWarning`. To opt in, run `pip install httpx2`, then use `import httpx2` and `httpx2.*` as in the examples below. If you remain on HTTPX, use `import httpx` and `httpx.*` instead. | ||
|
|
||
| Custom timeouts, URLs, proxies, transports, and responses must come from the selected package: HTTPX2 when installed, or HTTPX on the deprecated fallback path. Objects from the two packages are not interchangeable. HTTPX2 uses the operating system's trust store by default instead of HTTPX's bundled CA certificates; its logger names are `httpx2` and `httpcore2.*`. |
There was a problem hiding this comment.
This section can be explained to the user by adding admonition block below the original paragraph.
|
I am going to be away till next week. Next week, I will come back to this. Feel free to make any commits to my PR as you see fit or wait for me to get back. |
Deprecate the use of httpx in favor of httpx2 when supplied.
Closes #321
Replaces #324
If the environment of the caller has httpx2 installed, we use that. Otherwise, we give them a deprecation warning.
In the future, httpx should be dropped and a hard cut to the
httpx2namespace should be used. This is to help avoid client mismatch.