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
+7 -21
View File
@@ -75,9 +75,7 @@ class TestDiscordChannel:
@pytest.mark.asyncio
async def test_send_success(self, sample_alert: FormattedAlert) -> None:
"""Test successful Discord message send."""
channel = DiscordChannel(
webhook_url="https://discord.com/api/webhooks/123/abc"
)
channel = DiscordChannel(webhook_url="https://discord.com/api/webhooks/123/abc")
with patch("httpx.AsyncClient") as mock_client_class:
mock_response = MagicMock()
@@ -310,9 +308,7 @@ class TestAlertDispatcher:
mock_telegram_channel: MagicMock,
) -> None:
"""Test dispatcher initialization."""
dispatcher = AlertDispatcher(
channels=[mock_discord_channel, mock_telegram_channel]
)
dispatcher = AlertDispatcher(channels=[mock_discord_channel, mock_telegram_channel])
assert len(dispatcher.channels) == 2
assert "discord" in dispatcher._circuit_state
assert "telegram" in dispatcher._circuit_state
@@ -325,9 +321,7 @@ class TestAlertDispatcher:
mock_telegram_channel: MagicMock,
) -> None:
"""Test successful dispatch to all channels."""
dispatcher = AlertDispatcher(
channels=[mock_discord_channel, mock_telegram_channel]
)
dispatcher = AlertDispatcher(channels=[mock_discord_channel, mock_telegram_channel])
result = await dispatcher.dispatch(sample_alert)
@@ -345,9 +339,7 @@ class TestAlertDispatcher:
"""Test dispatch with one channel failing."""
mock_telegram_channel.send.return_value = False
dispatcher = AlertDispatcher(
channels=[mock_discord_channel, mock_telegram_channel]
)
dispatcher = AlertDispatcher(channels=[mock_discord_channel, mock_telegram_channel])
result = await dispatcher.dispatch(sample_alert)
@@ -357,9 +349,7 @@ class TestAlertDispatcher:
assert result.channel_results["telegram"] is False
@pytest.mark.asyncio
async def test_dispatch_no_channels(
self, sample_alert: FormattedAlert
) -> None:
async def test_dispatch_no_channels(self, sample_alert: FormattedAlert) -> None:
"""Test dispatch with no channels configured."""
dispatcher = AlertDispatcher(channels=[])
@@ -435,9 +425,7 @@ class TestAlertDispatcher:
# Now succeed
mock_discord_channel.send.return_value = True
# Force half-open by resetting last_failure to past
dispatcher._circuit_state["discord"].last_failure_time = datetime(
2020, 1, 1, tzinfo=UTC
)
dispatcher._circuit_state["discord"].last_failure_time = datetime(2020, 1, 1, tzinfo=UTC)
result = await dispatcher.dispatch(sample_alert)
@@ -465,9 +453,7 @@ class TestAlertDispatcher:
mock_telegram_channel: MagicMock,
) -> None:
"""Test getting circuit status."""
dispatcher = AlertDispatcher(
channels=[mock_discord_channel, mock_telegram_channel]
)
dispatcher = AlertDispatcher(channels=[mock_discord_channel, mock_telegram_channel])
status = dispatcher.get_circuit_status()