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
This commit is contained in:
Daniel Chalef 2025-10-29 18:46:50 -07:00
parent 5b40df724e
commit 4fe92a2b5b
2 changed files with 5 additions and 8 deletions

View file

@ -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', {})

View file

@ -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()