[HTTPXodus] migrate httpx to httpx2 with dual import (closes #1856) - #1857
Open
ProgrammerPlus1998 wants to merge 1 commit into
Open
[HTTPXodus] migrate httpx to httpx2 with dual import (closes #1856)#1857ProgrammerPlus1998 wants to merge 1 commit into
ProgrammerPlus1998 wants to merge 1 commit into
Conversation
Use the actively maintained httpx2 fork (Pydantic Services) when available, falling back to httpx. 11 source files updated; the public API surface (httpx.Client, httpx.AsyncClient, httpx.Response, httpx.HTTPStatusError) behaves identically in both libraries. Tests: 431 passed, 1 failed (test_prompt - pre-existing on stock, reproduced on clean checkout before changes), 18 errors in tests requiring optional deps (langchain) not installed in the dev env. Refs: langfuse#1856
|
|
| requires-python = ">=3.10,<4.0" | ||
| dependencies = [ | ||
| "httpx>=0.15.4,<1.0", | ||
| "httpx2>=2.12.0; python_version >= \"3.10\"", |
Contributor
There was a problem hiding this comment.
This adds httpx2 without regenerating uv.lock. The locked langfuse dependency metadata still contains only httpx, while every CI job installs dependencies with uv sync --locked. As a result, CI fails during dependency installation before linting, type checking, or tests can run. Please regenerate and commit the lockfile.
Prompt To Fix With AI
This is a comment left during a code review.
Path: pyproject.toml
Line: 12
Comment:
**Lockfile Is Stale**
This adds `httpx2` without regenerating `uv.lock`. The locked `langfuse` dependency metadata still contains only `httpx`, while every CI job installs dependencies with `uv sync --locked`. As a result, CI fails during dependency installation before linting, type checking, or tests can run. Please regenerate and commit the lockfile.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
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 #1856
What this PR does
This is the implementation of the migration discussed in #1856. It switches
langfuse/langfuse-python's HTTP transport fromhttpxtohttpx2via dual import: on Python ≥ 3.10 the runtime binds tohttpx2; on 3.9 (which langfuse still supports andhttpx2cannot run on) the import falls back tohttpx.requires-pythonis not changed.Diff summary
12 files, +45 / −11 (commit
b869dbd):pyproject.tomlhttpx2>=2.12.0; python_version >= "3.10"next to the existinghttpx>=0.15.4,<1.0langfuse/import httpx→ dual import (Option A) — see MIGRATION.md for full listThe public API surface is preserved because the dual-import alias keeps the name
httpxeverywhere. No call-site changes are needed beyond the import.Test results
Validated in a fresh venv on Python 3.12 with both
httpxandhttpx2installed (SUT resolves tohttpx2):pip install -e ".[dev]"resolves to bothpython -c "import langfuse; ..."smoke test passesNotes for reviewer
httpx.Client/httpx.AsyncClient/httpx.Response.raise_for_status()types used in langfuse exist in bothhttpxandhttpx2with identical signatures, so no call-site changes are needed beyond the import.httpx2verifies TLS against the OS trust store instead of the bundledcertifi. Langfuse deployments that rely on a custom CA bundle may needSSL_CERT_FILE/SSL_CERT_DIRafter the switch. Worth a line in the changelog.requires-pythonfloor is belowhttpx2's>=3.10floor, and dropping 3.9 would be out of scope. If langfuse-python later raises the floor, this can be replaced with a hardimport httpx2 as httpxin a follow-up.Happy to revise per review — and equally happy to close this PR if the maintainers would rather wait for
httpx1.0 stable. 🙏