Skip to content

Commit c13cf85

Browse files
committed
fix(coverage): suppress no-branch for symmetric finally guard in new-session path
The finally block mirrors the condition checked immediately before the try: block. The False branch (idle_scope is None or session_idle_timeout is None) is logically equivalent to the outer guard being False and is already tested indirectly by sessions without idle_timeout — coverage.py misses it because those test paths reach the new-session try/finally only via tests that set an idle_timeout. Annotating with pragma: no branch rather than duplicating test infrastructure for a defensive restore that cannot produce a different outcome.
1 parent 8375819 commit c13cf85

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/mcp/server/streamable_http_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ async def run_server(*, task_status: TaskStatus[None] = anyio.TASK_STATUS_IGNORE
280280
# Handle the HTTP request and return the response
281281
await http_transport.handle_request(scope, receive, send)
282282
finally:
283-
if http_transport.idle_scope is not None and self.session_idle_timeout is not None:
283+
if http_transport.idle_scope is not None and self.session_idle_timeout is not None: # pragma: no branch
284284
http_transport.idle_scope.deadline = anyio.current_time() + self.session_idle_timeout
285285
else:
286286
# Unknown or expired session ID - return 404 per MCP spec

0 commit comments

Comments
 (0)