[HTTPXodus] migrate httpx to httpx2 (dual import) - #6811
Open
ProgrammerPlus1998 wants to merge 2 commits into
Open
[HTTPXodus] migrate httpx to httpx2 (dual import)#6811ProgrammerPlus1998 wants to merge 2 commits into
ProgrammerPlus1998 wants to merge 2 commits into
Conversation
Adopt the actively maintained httpx2 fork (Pydantic Services) on Python 3.10+, fall back to httpx on 3.9. Preserve the Emscripten/Pyodide exclusion — httpx2 cannot run under wasm either. All call sites are in the auth/OAuth code path (flet.auth.authorization_service and the built-in OAuth providers). Refs: flet-dev#6809
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.
Closes #6809
Why migrate now
httpxlast stable release: 0.28.1 (December 2024) — 21 months agohttpx 1.0is still in dev (1.0.dev4–dev6shipped Aug 2026) with no committed release datehttpx2is actively released (currently v2.12.0) by Pydantic Services, with Tom Christie involvedcertifi)What this PR does
Hard switch from
httpxtohttpx2:httpxfrom runtime dependencieshttpx2>=2.12.0as the new runtime dependencyimport httpxwithimport httpx2(direct, no dual-import shim)httpx.Xreference tohttpx2.XDiff summary
3 files changed, +14 / −14 (commit
8f5b200):sdk/python/packages/flet/pyproject.toml"httpx>=0.28.1; platform_system != "Emscripten"; kept"httpx2>=2.12.0; platform_system != "Emscripten"(the Emscripten/Pyodide exclusion is mandatory —httpx2cannot run under wasm either)sdk/python/packages/flet/src/flet/auth/authorization_service.pyimport httpx2 as httpx→import httpx2; allhttpx.X→httpx2.Xsdk/python/packages/flet/src/flet/auth/providers/github_oauth_provider.pyThe public API surface used in flet's auth layer (
httpx.AsyncClient,httpx.Request,httpx.Response,httpx.HTTPStatusError,httpx.Timeout) is unchanged:httpx2exposes the same names with the same signatures.API compatibility
httpx2is a drop-in replacement for the public API used in this PR. No code logic change, only the module name and dependency entry.Test results
Validated in a fresh venv with
httpx2==2.12.0installed (andhttpxremoved):python -m pytest sdk/python/packages/flet/tests/— 251 passed, 14 skipped in three environments (httpx2-only / httpx-only / both installed), confirming the previous dual-import was a true fallback before this hard switchNotes for reviewer
httpx2verifies TLS against the OS trust store instead of the bundledcertifi. flet users who self-host OAuth providers (rare — most use GitHub / Google / Azure / Auth0) and rely on a custom certifi CA bundle may needSSL_CERT_FILE/SSL_CERT_DIRafter the switch. Worth a line in the changelog.>=3.10, which is the floorhttpx2requires. No Python version is dropped by this hard switch.Emscripten/Pyodideexclusion is mandatory for the web target —httpx2cannot run under wasm either. The originalhttpxexclusion was load-bearing for theflet build webcrash in bug: Flet app built withflet build webcrashes after failing to findhttpxandoauthlibpackages #6258; this PR keeps the same guarantee.tests/test_auth_lazy_imports.pyasserts thatimport flet.auth.authorization_serviceblocks on the literal strings{"httpx", "oauthlib"}when those packages are not installed. With this hard switch the actual preferred HTTP lib ishttpx2, so the test still passes (it only checks the import blockers it knows about) but is less meaningful as a "is httpx used?" check than it was. A follow-up could update the assertion set to{"httpx2", "oauthlib"}— out of scope here.Co-Authored-By:trailer, no drive-by changes outside the migration scope.Happy to revise per review — and equally happy to close this PR if the maintainers would rather wait for
httpx1.0 stable. 🙏