From 4fe92a2b5b6055a2df1b7491b02d085f9ab8d3e5 Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:46:50 -0700 Subject: [PATCH] fix: Use contextlib.suppress instead of try-except-pass (SIM105) - Replace try-except-pass with contextlib.suppress in test_async_operations.py - Replace try-except-pass with contextlib.suppress in test_fixtures.py - Fixes ruff SIM105 linting errors --- mcp_server/tests/test_async_operations.py | 8 +++----- mcp_server/tests/test_fixtures.py | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mcp_server/tests/test_async_operations.py b/mcp_server/tests/test_async_operations.py index 078a920c..66b03175 100644 --- a/mcp_server/tests/test_async_operations.py +++ b/mcp_server/tests/test_async_operations.py @@ -5,6 +5,7 @@ Tests concurrent operations, queue management, and async patterns. """ import asyncio +import contextlib import json import time @@ -246,7 +247,7 @@ class TestAsyncErrorHandling: # Create a very large episode that might timeout large_content = 'x' * 1000000 # 1MB of data - try: + with contextlib.suppress(asyncio.TimeoutError): await asyncio.wait_for( session.call_tool( 'add_memory', @@ -258,11 +259,8 @@ class TestAsyncErrorHandling: 'group_id': group_id, }, ), - timeout=2.0, # Short timeout + timeout=2.0, # Short timeout - expected to timeout ) - except asyncio.TimeoutError: - # Expected timeout - pass # Verify server is still responsive after timeout status_result = await session.call_tool('get_status', {}) diff --git a/mcp_server/tests/test_fixtures.py b/mcp_server/tests/test_fixtures.py index aa639630..68284a74 100644 --- a/mcp_server/tests/test_fixtures.py +++ b/mcp_server/tests/test_fixtures.py @@ -3,6 +3,7 @@ Shared test fixtures and utilities for Graphiti MCP integration tests. """ import asyncio +import contextlib import json import os import random @@ -203,10 +204,8 @@ async def graphiti_test_client( yield session, test_group_id finally: # Cleanup: Clear test data - try: + with contextlib.suppress(Exception): await session.call_tool('clear_graph', {'group_id': test_group_id}) - except Exception: - pass # Ignore cleanup errors await session.close()