Skip to content

Commit 786ee07

Browse files
dsfacciniclaude
andcommitted
Correct framing: httpx2 is on PyPI; CI exercises the fallback because the lockfile pins httpx
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent faa5298 commit 786ee07

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,11 @@ filterwarnings = [
206206
"ignore:websockets.server.WebSocketServerProtocol is deprecated:DeprecationWarning",
207207
# pywin32 internal deprecation warning
208208
"ignore:getargs.*The 'u' format is deprecated:DeprecationWarning",
209-
# `mcp` prefers `httpx2`; HTTP surfaces warn when falling back to `httpx`. `httpx2` is
210-
# not yet on PyPI, so every HTTP-touching test would trip the warning. The dedicated
211-
# test in `tests/shared/test_httpx_shim.py` covers emission. Remove this entry once
212-
# `httpx2` is the default and the fallback is dropped.
209+
# `mcp` prefers `httpx2`; HTTP surfaces warn when falling back to `httpx`. The lockfile
210+
# pins `httpx` (not `httpx2`), so CI always exercises the fallback and every HTTP-touching
211+
# test would trip the warning. The dedicated test in `tests/shared/test_httpx_shim.py`
212+
# covers emission. Remove this entry once `httpx2` is the dependency and the fallback is
213+
# dropped.
213214
"ignore:Using `httpx` with `mcp` is deprecated:mcp.shared._httpx.MCPDeprecationWarning",
214215
]
215216

src/mcp/shared/_httpx.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
[Kludex/starlette@508023b](https://github.com/Kludex/starlette/commit/508023b488b649d97c091eb60da1d8ef3636ee06)
55
and [pydantic/pydantic-ai#5664](https://github.com/pydantic/pydantic-ai/pull/5664).
66
7-
`httpx2` is not yet on PyPI, so every install today exercises the fallback path. The warning
8-
is emitted lazily on first use (not at module import) to avoid breaking pytest's filter
9-
parser during collection. The MCP v2 cut will drop the fallback and require `httpx2`.
7+
`mcp` declares `httpx` (not `httpx2`) as a dependency, so unless the user installs `httpx2`
8+
explicitly the fallback path is exercised. The warning is emitted lazily on first use (not at
9+
module import) to avoid breaking pytest's filter parser during collection. The MCP v2 cut will
10+
drop the fallback and bump the dependency to `httpx2`.
1011
"""
1112

1213
from __future__ import annotations

tests/shared/test_httpx_shim.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ async def test_create_mcp_http_client_silent_with_httpx2(
7070
def test_shim_picks_up_httpx2_when_present(monkeypatch: pytest.MonkeyPatch) -> None:
7171
"""Aliasing `httpx2` to the installed `httpx` module exercises the preferred import path.
7272
73-
Without this test, the `import httpx2 as httpx` branch is uncovered (since `httpx2` is not
74-
yet on PyPI). Once `httpx2` is real, this test will continue to pass naturally.
73+
`mcp`'s lockfile pins `httpx` (not `httpx2`), so the `import httpx2 as httpx` branch is
74+
otherwise uncovered in CI. This test injects `httpx2` into `sys.modules` and reloads the
75+
shim to cover that branch deterministically.
7576
"""
7677
import importlib
7778
import sys

0 commit comments

Comments
 (0)