Skip to content

Commit 803fa14

Browse files
committed
ci(#2484): use 'pragma: lax no cover' for timing-dependent exception catches
The two catches I touched in the previous commit (``except asyncio.CancelledError`` and ``except anyio.ClosedResourceError`` in the teardown result-collection loop) turn out to be timing-dependent: - On Windows the teardown of the background reader/writer finishes before the loop reaches ``await task``, so ``await task`` never raises CancelledError / ClosedResourceError and the branches are unreached — needs pragma. - On some Linux runs the reader/writer is still running when we cancel and await, so the branches *are* reached — strict-no-cover complained that a plain ``pragma: no cover`` was wrong there. Switched both to ``pragma: lax no cover``, which the project's coverage config already defines as the opt-out marker for exactly this case (exists on other lines in the same file, e.g. 247). It is excluded from coverage reporting but does not trip strict-no-cover when the line happens to be hit.
1 parent 3483015 commit 803fa14

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/mcp/client/stdio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def _on_done(task: asyncio.Task[None]) -> None:
158158
for task in tasks:
159159
try:
160160
await task
161-
except asyncio.CancelledError:
161+
except asyncio.CancelledError: # pragma: lax no cover - timing-dependent on teardown races
162162
pass
163-
except anyio.ClosedResourceError:
163+
except anyio.ClosedResourceError: # pragma: lax no cover - timing-dependent on teardown races
164164
pass
165165
except BaseException as exc: # noqa: BLE001
166166
if pending_exc is None: # pragma: no branch

0 commit comments

Comments
 (0)