Skip to content

Commit 39a940b

Browse files
BabyChrist666claude
andcommitted
Fix pyright errors: unused variables and __class__ assignment
- Prefix unused stream variables with _ to satisfy reportUnusedVariable - Use real classes instead of MagicMock __class__ assignment for IPython mocks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4b199bc commit 39a940b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tests/client/test_stdio.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ async def test_stderr_captured_in_process(self):
665665

666666
# The stdio_client should handle this without hanging
667667
with anyio.move_on_after(3.0) as cancel_scope:
668-
async with stdio_client(server_params) as (read_stream, write_stream):
668+
async with stdio_client(server_params) as (_read_stream, _write_stream):
669669
await anyio.sleep(0.5) # Give process time to write and exit
670670

671671
assert not cancel_scope.cancelled_caught, "stdio_client should not hang on stderr output"
@@ -696,45 +696,45 @@ async def test_stderr_with_continuous_output(self):
696696

697697
# The client should handle continuous stderr without blocking
698698
with anyio.move_on_after(5.0) as cancel_scope:
699-
async with stdio_client(server_params) as (read_stream, write_stream):
699+
async with stdio_client(server_params) as (_read_stream, _write_stream):
700700
await anyio.sleep(1.0) # Wait for stderr output
701701

702702
assert not cancel_scope.cancelled_caught, "stdio_client should handle continuous stderr output"
703703

704704
def test_jupyter_detection_ipkernel_app(self):
705705
"""Test that _is_jupyter_environment returns True for IPKernelApp config."""
706-
mock_ipython_instance = MagicMock()
707-
mock_ipython_instance.config = {"IPKernelApp": {}}
708-
mock_ipython_instance.__class__ = type("TerminalInteractiveShell", (), {})
706+
707+
class FakeIPython:
708+
config = {"IPKernelApp": {}}
709709

710710
mock_ipython_module = MagicMock()
711-
mock_ipython_module.get_ipython = MagicMock(return_value=mock_ipython_instance)
711+
mock_ipython_module.get_ipython = MagicMock(return_value=FakeIPython())
712712

713713
with patch.dict("sys.modules", {"IPython": mock_ipython_module}):
714714
result = _is_jupyter_environment()
715715
assert result is True
716716

717717
def test_jupyter_detection_zmq_shell(self):
718718
"""Test that _is_jupyter_environment returns True for ZMQInteractiveShell."""
719-
mock_ipython_instance = MagicMock()
720-
mock_ipython_instance.config = {}
721-
mock_ipython_instance.__class__ = type("ZMQInteractiveShell", (), {})
719+
720+
class ZMQInteractiveShell:
721+
config: dict[str, object] = {}
722722

723723
mock_ipython_module = MagicMock()
724-
mock_ipython_module.get_ipython = MagicMock(return_value=mock_ipython_instance)
724+
mock_ipython_module.get_ipython = MagicMock(return_value=ZMQInteractiveShell())
725725

726726
with patch.dict("sys.modules", {"IPython": mock_ipython_module}):
727727
result = _is_jupyter_environment()
728728
assert result is True
729729

730730
def test_jupyter_detection_non_notebook_ipython(self):
731731
"""Test that _is_jupyter_environment returns False for plain IPython terminal."""
732-
mock_ipython_instance = MagicMock()
733-
mock_ipython_instance.config = {}
734-
mock_ipython_instance.__class__ = type("TerminalInteractiveShell", (), {})
732+
733+
class TerminalInteractiveShell:
734+
config: dict[str, object] = {}
735735

736736
mock_ipython_module = MagicMock()
737-
mock_ipython_module.get_ipython = MagicMock(return_value=mock_ipython_instance)
737+
mock_ipython_module.get_ipython = MagicMock(return_value=TerminalInteractiveShell())
738738

739739
with patch.dict("sys.modules", {"IPython": mock_ipython_module}):
740740
result = _is_jupyter_environment()
@@ -770,8 +770,8 @@ async def test_stderr_reader_jupyter_mode(self):
770770
with patch("mcp.client.stdio._is_jupyter_environment", return_value=True):
771771
with anyio.move_on_after(5.0) as cancel_scope:
772772
async with stdio_client(server_params) as ( # pragma: no branch
773-
read_stream,
774-
write_stream,
773+
_read_stream,
774+
_write_stream,
775775
):
776776
await anyio.sleep(1.0)
777777

@@ -802,8 +802,8 @@ async def test_stderr_reader_jupyter_mode_continuous(self):
802802
with patch("mcp.client.stdio._is_jupyter_environment", return_value=True):
803803
with anyio.move_on_after(5.0) as cancel_scope:
804804
async with stdio_client(server_params) as ( # pragma: no branch
805-
read_stream,
806-
write_stream,
805+
_read_stream,
806+
_write_stream,
807807
):
808808
await anyio.sleep(1.0)
809809

0 commit comments

Comments
 (0)