fix: resolve linting and formatting issues for CI

- Use contextlib.suppress instead of try/except/pass (SIM105)
- Prefix unused fixture arguments with underscore (ARG002)
- Replace asyncio.TimeoutError with TimeoutError (UP041)
- Apply ruff formatting to all files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Selamy
2026-01-04 17:09:14 -05:00
co-authored by Claude Opus 4.5
parent a15086688a
commit 1f4f1fa557
31 changed files with 180 additions and 311 deletions
+9 -23
View File
@@ -80,19 +80,13 @@ class TestTradeStreamHandler:
assert handler._event_filter == "presidential-election-2024"
def test_build_subscription_message_no_filter(
self, handler: TradeStreamHandler
) -> None:
def test_build_subscription_message_no_filter(self, handler: TradeStreamHandler) -> None:
"""Test building subscription message without filters."""
msg = handler._build_subscription_message()
assert msg == {
"subscriptions": [{"topic": "activity", "type": "trades"}]
}
assert msg == {"subscriptions": [{"topic": "activity", "type": "trades"}]}
def test_build_subscription_message_with_event_filter(
self, on_trade_mock: AsyncMock
) -> None:
def test_build_subscription_message_with_event_filter(self, on_trade_mock: AsyncMock) -> None:
"""Test building subscription message with event filter."""
handler = TradeStreamHandler(
on_trade=on_trade_mock,
@@ -100,13 +94,9 @@ class TestTradeStreamHandler:
)
msg = handler._build_subscription_message()
assert msg["subscriptions"][0]["filters"] == json.dumps(
{"event_slug": "test-event"}
)
assert msg["subscriptions"][0]["filters"] == json.dumps({"event_slug": "test-event"})
def test_build_subscription_message_with_market_filter(
self, on_trade_mock: AsyncMock
) -> None:
def test_build_subscription_message_with_market_filter(self, on_trade_mock: AsyncMock) -> None:
"""Test building subscription message with market filter."""
handler = TradeStreamHandler(
on_trade=on_trade_mock,
@@ -114,9 +104,7 @@ class TestTradeStreamHandler:
)
msg = handler._build_subscription_message()
assert msg["subscriptions"][0]["filters"] == json.dumps(
{"market_slug": "test-market"}
)
assert msg["subscriptions"][0]["filters"] == json.dumps({"market_slug": "test-market"})
@pytest.mark.asyncio
async def test_handle_message_trade(
@@ -235,7 +223,7 @@ class TestTradeStreamHandler:
@pytest.mark.asyncio
async def test_connect_sends_subscription(
self, handler: TradeStreamHandler, on_state_change_mock: AsyncMock
self, handler: TradeStreamHandler, _on_state_change_mock: AsyncMock
) -> None:
"""Test that connection sends subscription message."""
mock_ws = AsyncMock()
@@ -254,9 +242,7 @@ class TestTradeStreamHandler:
assert sent_msg["subscriptions"][0]["type"] == "trades"
@pytest.mark.asyncio
async def test_cleanup_closes_websocket(
self, handler: TradeStreamHandler
) -> None:
async def test_cleanup_closes_websocket(self, handler: TradeStreamHandler) -> None:
"""Test that cleanup closes the WebSocket."""
mock_ws = AsyncMock()
mock_ws.close = AsyncMock()
@@ -333,7 +319,7 @@ class TestTradeStreamHandlerIntegration:
# Run with timeout to prevent hanging
try:
await asyncio.wait_for(handler.start(), timeout=1.0)
except asyncio.TimeoutError:
except TimeoutError:
await handler.stop()
# Verify trade was received