| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Mirrors Kludex/starlette@508023b and pydantic/pydantic-ai#5664: prefer `httpx2` at import time and fall back to `httpx` with an `MCPDeprecationWarning` emitted lazily on first use of an HTTP-touching surface (`create_mcp_http_client`, `OAuthClientProvider`, `HttpResource`). The v2-cut PR will drop the fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…se the lockfile pins `httpx` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I think we don't need the emit warning function. Just the: # mcp.shared._httpx
try:
import httpx2 as httpx
except ImportError:
import httpx
# emit the warning here.In other modules: from mcp.shared._httpx import httpxIf I'm wrong, and it does emit multiple warnings, we can just have a boolean: # mcp.shared._httpx
_displayed_deprecation = False
try:
import httpx2 as httpx
except ImportError:
import httpx
if not _displayed_deprecation:
# emit the warning here. |
Sorry, something went wrong.
…zy helper Module-level `warnings.warn(...)` inside the `except ImportError` branch fires once per process via Python's module cache — no flag or helper function needed. `MCPDeprecationWarning` moves to `mcp.shared._warnings` so the class symbol exists independently of the shim, and the pytest `filterwarnings` entry matches on the message string only. Naming the category would force pytest's filter parser to import `mcp.shared._warnings`, which cascades through `mcp/__init__.py` and triggers the very warning we're filtering (the pydantic-ai pitfall). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
David's AICA here: Adopted in 3de2aa1 — warnings.warn now fires from the except ImportError branch at module-import time, no flag, no helper function. Two adjustments fell out of trying your snippet here:
Net diff: −107 lines, +75. Full suite green (1177 passed, 100% branch coverage). I left a short comment on the _warnings.py class docstring explaining why it lives separately, since the reasoning is non-obvious from the structure alone. |
Sorry, something went wrong.
There was a problem hiding this comment.
Don't we have an _exceptions.py module? If we do, we should put this there.
Sorry, something went wrong.
There was a problem hiding this comment.
yeahp that turned out to be the case
Sorry, something went wrong.
Drops the dedicated _warnings.py — the side-effect-free-module constraint that justified it is moot now that the filter matches by message only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| Subclasses `UserWarning` (not `DeprecationWarning`) so it is visible by default — | ||
| `DeprecationWarning` is silenced at the Python level for non-`__main__` callers. | ||
| """ |
There was a problem hiding this comment.
I think it should say the same thing as the starlette one, so we have the reference as why we have this.
Sorry, something went wrong.
There was a problem hiding this comment.
Check how we test integrations in logfire. It's a bit more cleaner than this.
Sorry, something went wrong.
…tch.dict style
Test diff: -33 / +12. Replaces the bespoke `builtins.__import__` monkeypatch with
`mock.patch.dict('sys.modules', {'httpx2': None | <fake>})` + `importlib.reload`,
matching `logfire/tests/otel_integrations/test_httpx.py::test_missing_opentelemetry_dependency`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for the PR. This has since landed via #2972. Closing as part of a general backlog cleanup following the v2 release. If this is still relevant against v2, feel free to reopen. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
David's AICA here:
Mirrors Kludex/starlette@508023b and the matching pydantic/pydantic-ai#5664: prefer httpx2 at import time, fall back to httpx with an MCPDeprecationWarning emitted on first use of an HTTP-touching surface. The v2-cut PR will drop the httpx fallback. CC @Kludex.
Summary
httpx>=0.27.1,<1.0.0 in pyproject.toml is left as-is. httpx2 exists on PyPI (v2.2.0), but mcp doesn't declare it as a dependency and the lockfile only pins httpx, so users who want the new package install it explicitly. The eventual v2-cut PR will bump the dependency to httpx2 and remove the shim entirely.
Out of scope (intentional)
Test plan
🤖 Generated with Claude Code