Match the shortened stdio comment style from #3329 · maisymylod/python-sdk@d90f7dc · GitHub
Skip to content

Commit d90f7dc

Browse files
committed
Match the shortened stdio comment style from modelcontextprotocol#3329
The comment sweep in modelcontextprotocol#3329 landed after this branch was opened, so the docstrings and comments added here were still written in the older, longer style. Bring them into line, and take main's one-line docstring for test_server_stderr_output_reaches_the_errlog_file. Comments only, no behaviour change.
1 parent 2241674 commit d90f7dc

3 files changed

Lines changed: 17 additions & 49 deletions

File tree

‎src/mcp/client/stdio.py‎

Lines changed: 9 additions & 18 deletions

‎tests/client/test_stdio.py‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,7 @@ async def feed_stderr(self, data: bytes) -> None:
196196
await self._stderr_send.send(data)
197197

198198
def close_stderr(self) -> None:
199-
"""End the fake process's stderr, as the kernel does when it dies.
200-
201-
Closes both ends: unlike stdout, stderr goes unread whenever errlog owns a
202-
descriptor, so nothing else would ever release the read end.
203-
"""
199+
"""End the fake process's stderr, closing both ends since stderr often goes unread."""
204200
self._stderr_send.close()
205201
self.stderr.close()
206202

@@ -1021,19 +1017,15 @@ def write(self, s: str, /) -> int:
10211017
async def test_a_closed_errlog_stops_stderr_forwarding_without_failing_the_session(
10221018
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
10231019
) -> None:
1024-
"""Losing the log sink mid-session costs the diagnostics, never the session.
1025-
1026-
A notebook cell that finishes closes the stream underneath the forwarder; the
1027-
server's own traffic has to survive that.
1028-
"""
1020+
"""Losing the log sink mid-session costs the diagnostics, never the session."""
10291021
errlog = _UnwritableErrlog()
10301022
process = FakeProcess(on_stdin_close=lambda: process.exit(0))
10311023
install_fake_process(monkeypatch, process)
10321024
ping = JSONRPCRequest(jsonrpc="2.0", id=1, method="ping")
10331025

10341026
with caplog.at_level(logging.DEBUG, logger="mcp.client.stdio"):
10351027
with anyio.fail_after(5):
1036-
# no branch: coverage mis-traces the exit arcs of a nested `async with` on 3.14.
1028+
# Coverage mis-traces nested `async with` exit arcs on Python 3.11+.
10371029
async with stdio_client(FAKE_PARAMS, errlog=cast(TextIO, errlog)) as (read_stream, _): # pragma: no branch
10381030
await process.feed_stderr(b"server diagnostics no one will read\n")
10391031
await errlog.attempted.wait()
@@ -1050,11 +1042,7 @@ async def test_a_closed_errlog_stops_stderr_forwarding_without_failing_the_sessi
10501042
async def test_a_stderr_pipe_dying_with_the_server_ends_forwarding_quietly(
10511043
monkeypatch: pytest.MonkeyPatch,
10521044
) -> None:
1053-
"""A stderr pipe torn down with the process is shutdown noise, not an error.
1054-
1055-
The proactor loop reports a hard-killed pipe as a reset rather than EOF, which
1056-
must not propagate out of the transport.
1057-
"""
1045+
"""A stderr pipe torn down with the process is shutdown noise, not an error."""
10581046
errlog = StringIO()
10591047
process = FakeProcess(
10601048
on_stdin_close=lambda: process.exit(0),

‎tests/transports/stdio/test_lifecycle.py‎

Lines changed: 4 additions & 15 deletions

0 commit comments

Comments
 (0)