Skip to content

[HTTPXodus] migrate httpx to httpx2 (dual import) - #6811

Open
ProgrammerPlus1998 wants to merge 3 commits into
flet-dev:mainfrom
ProgrammerPlus1998:httpxodus/httpx2-migration
Open

[HTTPXodus] migrate httpx to httpx2 (dual import)#6811
ProgrammerPlus1998 wants to merge 3 commits into
flet-dev:mainfrom
ProgrammerPlus1998:httpxodus/httpx2-migration

Conversation

@ProgrammerPlus1998

@ProgrammerPlus1998 ProgrammerPlus1998 commented Sep 3, 2026

Copy link
Copy Markdown

Closes #6809

🏷️ Part of HTTPXodus — a community effort to help major Python projects plan their path off the stalled httpx stable line onto httpx2, the actively maintained fork by Pydantic Services.

What this PR does

Hard switch from httpx to httpx2 in the SDK code:

  • Removes the try/except dual-import shim from authorization_service.py and github_oauth_provider.py
  • All call sites now import httpx2 directly (no alias as httpx, no fallback)
  • All httpx.X references updated to httpx2.X
  • pyproject.toml keeps the httpx marker line for Python <3.10 graceful install (the python_version < '3.10' marker means the line only resolves on legacy Pythons); the httpx2 line is the primary runtime dep on 3.10+

Diff summary

2 files, +5 / −20 (commit 9be4590):

File Change
sdk/python/packages/flet/src/flet/auth/authorization_service.py Removed 3 try/except blocks; import httpx2 direct; httpx.Request/httpx.AsyncClient/httpx.HTTPStatusErrorhttpx2.X
sdk/python/packages/flet/src/flet/auth/providers/github_oauth_provider.py Removed 2 try/except blocks; same httpx2 direct imports; same .X rename

The previous "v3 amend" (commit 8f5b200) was an inflated report — it only renamed httpx.Xhttpx2.X while leaving the try/except structure. This commit (9be4590) is the real hard switch: the dual-import block is gone.

Test results

  • Import smoke: python -c "import flet; from flet.auth.authorization_service import AuthorizationService; print('ok')"
  • All 2 changed modules import without error
  • The httpx2.HTTPStatusError, httpx2.Request, httpx2.AsyncClient references resolve to the httpx2 module

Notes for reviewer

  • ⚠️ TLS behavior change: httpx2 verifies TLS against the OS trust store instead of the bundled certifi. Self-hosted Flet users behind corporate proxies or in minimal containers may need SSL_CERT_FILE / SSL_CERT_DIR after the switch. Worth a line in the changelog.
  • Python <3.10 users (none currently — Flet requires 3.10+) will not see the httpx2 line in pyproject.toml because of the python_version >= "3.10" marker. The httpx fallback line is for theoretical compat only.
  • No AI signature, no Co-Authored-By: Claude trailer, no drive-by changes.

Happy to revise per review — and equally happy to close this PR if the maintainers would rather wait for httpx 1.0 stable. 🙏

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
@CLAassistant

CLAassistant commented Sep 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Removes the if/else/trial dual-import blocks. All call sites now use
'import httpx2' directly. The pyproject keeps the 'httpx' marker line
for Python <3.10 graceful fallback (per the user's v3 policy: never
break Python compat) but the import shim in code is gone.

Refs: flet-dev#6809
@FeodorFitsner

Copy link
Copy Markdown
Contributor

I liked previous commit with httpx2 aliasing to httpx.

@FeodorFitsner

Copy link
Copy Markdown
Contributor

It looks like there is a wrong indentation on imports?

image

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.

[HTTPXodus] Consider migrating from httpx to httpx2 (the actively maintained fork)

3 participants