Skip to content

Add support for httpx2 - #239

Open
Klavionik wants to merge 2 commits into
Colin-b:developfrom
Klavionik:add_httpx2_support
Open

Add support for httpx2#239
Klavionik wants to merge 2 commits into
Colin-b:developfrom
Klavionik:add_httpx2_support

Conversation

@Klavionik

Copy link
Copy Markdown

Hey! I'm trying to add support for the httpx2 package, following the guidelines from the authors.

This PR allows users of the package to seamlessly migrate their application and test code from httpx, just by updating the package. Users who have no intentions to migrate will be fine as well: the added _compat.py module tries to use httpx2 first, but falls back to httpx.

This is a highly anticipated change I assume, so I'm looking forward for a review and any comments/suggestions are very welcome.

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

Comment thread pyproject.toml
]
dependencies = [
"httpx==0.28.*",
"httpx2==2.*",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps it's worth doing this as an extra?

Comment thread pytest_httpx/_compat.py
Comment on lines +22 to +24
"pytest-httpx requires the httpx2 package to be installed.\n"
"You can install it with:\n"
" $ pip install httpx2\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this choice up to the user and not talk about the need, because migration does not happen so quickly.

"Neither `httpx2` nor the legacy `httpx` package is installed.\n"
"Install `httpx2` with:\n"
"    $ pip install httpx2\n"

@bagowix

bagowix commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@Colin-b Hi! Could we prioritize this, if possible, please?

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.

2 participants