Skip to content

Commit bad0a6e

Browse files
BabyChrist666claude
andcommitted
Fix remaining pre-commit issues and add missing branch coverage
- Remove unused Union import in win32/utilities.py, use | syntax - Add test for get_ipython() returning None (covers 43->52 branch) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49e2546 commit bad0a6e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/mcp/os/win32/utilities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import subprocess
66
import sys
77
from pathlib import Path
8-
from typing import BinaryIO, TextIO, Union, cast
8+
from typing import BinaryIO, TextIO, cast
99

1010
import anyio
1111
from anyio import to_thread
@@ -137,7 +137,7 @@ async def create_windows_process(
137137
command: str,
138138
args: list[str],
139139
env: dict[str, str] | None = None,
140-
errlog: Union[TextIO, int, None] = sys.stderr,
140+
errlog: TextIO | int | None = sys.stderr,
141141
cwd: Path | str | None = None,
142142
) -> Process | FallbackProcess:
143143
"""Creates a subprocess in a Windows-compatible way with Job Object support.
@@ -196,7 +196,7 @@ async def _create_windows_fallback_process(
196196
command: str,
197197
args: list[str],
198198
env: dict[str, str] | None = None,
199-
errlog: Union[TextIO, int, None] = sys.stderr,
199+
errlog: TextIO | int | None = sys.stderr,
200200
cwd: Path | str | None = None,
201201
) -> FallbackProcess:
202202
"""Create a subprocess using subprocess.Popen as a fallback when anyio fails.

tests/client/test_stdio.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,15 @@ def test_jupyter_detection_non_notebook_ipython(self):
740740
result = _is_jupyter_environment()
741741
assert result is False
742742

743+
def test_jupyter_detection_ipython_returns_none(self):
744+
"""Test that _is_jupyter_environment returns False when get_ipython() returns None."""
745+
mock_ipython_module = MagicMock()
746+
mock_ipython_module.get_ipython = MagicMock(return_value=None)
747+
748+
with patch.dict("sys.modules", {"IPython": mock_ipython_module}):
749+
result = _is_jupyter_environment()
750+
assert result is False
751+
743752
@pytest.mark.anyio
744753
async def test_stderr_reader_jupyter_mode(self):
745754
"""Test that stderr is captured and printed in Jupyter mode."""

0 commit comments

Comments
 (0)