Skip to content

Commit 5b98439

Browse files
committed
style(stdio): format imports and wrap long lines for ruff compliance
1 parent 2f26efd commit 5b98439

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/mcp/client/stdio/win32.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import sys
88
from pathlib import Path
9-
from typing import IO, TextIO
9+
from typing import BinaryIO, TextIO, cast
1010

1111
import anyio
1212
from anyio import to_thread
@@ -58,18 +58,27 @@ class DummyProcess:
5858

5959
def __init__(self, popen_obj: subprocess.Popen[bytes]):
6060
self.popen: subprocess.Popen[bytes] = popen_obj
61-
self.stdin_raw: IO[bytes] | None = popen_obj.stdin
62-
self.stdout_raw: IO[bytes] | None = popen_obj.stdout
63-
self.stderr: IO[bytes] | None = popen_obj.stderr
61+
self.stdin_raw = popen_obj.stdin # type: ignore[assignment]
62+
self.stdout_raw = popen_obj.stdout # type: ignore[assignment]
63+
self.stderr = popen_obj.stderr # type: ignore[assignment]
6464

65-
self.stdin = FileWriteStream(self.stdin_raw) if self.stdin_raw else None
66-
self.stdout = FileReadStream(self.stdout_raw) if self.stdout_raw else None
65+
self.stdin = (
66+
FileWriteStream(cast(BinaryIO, self.stdin_raw)) if self.stdin_raw else None
67+
)
68+
self.stdout = (
69+
FileReadStream(cast(BinaryIO, self.stdout_raw)) if self.stdout_raw else None
70+
)
6771

6872
async def __aenter__(self):
6973
"""Support async context manager entry."""
7074
return self
7175

72-
async def __aexit__(self, exc_type, exc_val, exc_tb):
76+
async def __aexit__(
77+
self,
78+
exc_type: BaseException | None,
79+
exc_val: BaseException | None,
80+
exc_tb: object | None,
81+
) -> None:
7382
"""Terminate and wait on process exit inside a thread."""
7483
self.popen.terminate()
7584
await to_thread.run_sync(self.popen.wait)
@@ -122,11 +131,7 @@ async def create_windows_process(
122131
env=env,
123132
cwd=cwd,
124133
bufsize=0, # Unbuffered output
125-
creationflags=(
126-
subprocess.CREATE_NO_WINDOW
127-
if hasattr(subprocess, "CREATE_NO_WINDOW")
128-
else 0
129-
),
134+
creationflags = getattr(subprocess, "CREATE_NO_WINDOW", 0),
130135
)
131136
return DummyProcess(popen_obj)
132137

0 commit comments

Comments
 (0)