Skip to content

Commit 55cf282

Browse files
committed
fix: address review feedback on pragma placement
- Move pragma to except line in streamable_http.py per Kludex suggestion - Remove unnecessary lax no cover from test_streamable_http.py assertions (these lines are consistently covered across all CI configurations)
1 parent da79832 commit 55cf282

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/mcp/client/streamable_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ async def handle_get_stream(self, client: httpx.AsyncClient, read_stream_writer:
200200
# Stream ended normally (server closed) - reset attempt counter
201201
attempt = 0
202202

203-
except Exception as exc:
204-
logger.debug(f"GET stream error: {exc}") # pragma: lax no cover
205-
attempt += 1 # pragma: lax no cover
203+
except Exception as exc: # pragma: no cover
204+
logger.debug(f"GET stream error: {exc}")
205+
attempt += 1
206206

207207
if attempt >= MAX_RECONNECTION_ATTEMPTS: # pragma: no cover
208208
logger.debug(f"GET stream max reconnection attempts ({MAX_RECONNECTION_ATTEMPTS}) exceeded")

tests/shared/test_streamable_http.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,18 +1303,18 @@ async def run_tool():
13031303
tg.cancel_scope.cancel()
13041304

13051305
# Verify we received exactly one notification
1306-
assert len(captured_notifications) == 1 # pragma: lax no cover
1307-
assert isinstance(captured_notifications[0], types.LoggingMessageNotification) # pragma: lax no cover
1308-
assert captured_notifications[0].params.data == "First notification before lock" # pragma: lax no cover
1306+
assert len(captured_notifications) == 1
1307+
assert isinstance(captured_notifications[0], types.LoggingMessageNotification)
1308+
assert captured_notifications[0].params.data == "First notification before lock"
13091309

13101310
# Clear notifications for the second phase
1311-
captured_notifications = [] # pragma: lax no cover
1311+
captured_notifications = []
13121312

13131313
# Now resume the session with the same mcp-session-id and protocol version
1314-
headers: dict[str, Any] = {} # pragma: lax no cover
1315-
if captured_session_id: # pragma: lax no cover
1314+
headers: dict[str, Any] = {}
1315+
if captured_session_id:
13161316
headers[MCP_SESSION_ID_HEADER] = captured_session_id
1317-
if captured_protocol_version: # pragma: lax no cover
1317+
if captured_protocol_version:
13181318
headers[MCP_PROTOCOL_VERSION_HEADER] = captured_protocol_version
13191319

13201320
async with create_mcp_http_client(headers=headers) as httpx_client:
@@ -1346,8 +1346,8 @@ async def run_tool():
13461346
# We should have received the remaining notifications
13471347
assert len(captured_notifications) == 1
13481348

1349-
assert isinstance(captured_notifications[0], types.LoggingMessageNotification) # pragma: lax no cover
1350-
assert captured_notifications[0].params.data == "Second notification after lock" # pragma: lax no cover
1349+
assert isinstance(captured_notifications[0], types.LoggingMessageNotification)
1350+
assert captured_notifications[0].params.data == "Second notification after lock"
13511351

13521352

13531353
@pytest.mark.anyio

0 commit comments

Comments
 (0)