Skip to content

Commit bade397

Browse files
hendisantikaclaude
andcommitted
🔧 fix: remove unused variables and imports flagged by ruff
Remove unused `chat` variable in anti_spam.py, unused `settings` variable and import in check.py, and unused `Path` import in test_group_config.py. Update test patches accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 377d474 commit bade397

4 files changed

Lines changed: 15 additions & 34 deletions

File tree

src/bot/handlers/anti_spam.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ async def handle_new_user_spam(
215215
return
216216

217217
group_config = get_group_config_for_update(update)
218-
chat = update.effective_chat
219218
user = update.message.from_user
220219

221220
# Only process messages from monitored groups

src/bot/handlers/check.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from telegram.error import TimedOut
1414
from telegram.ext import ContextTypes
1515

16-
from bot.config import get_settings
1716
from bot.constants import (
1817
ADMIN_CHECK_ACTION_COMPLETE,
1918
ADMIN_CHECK_ACTION_INCOMPLETE,
@@ -248,7 +247,6 @@ async def handle_warn_callback(
248247
missing_items.append("username")
249248
missing_text = MISSING_ITEMS_SEPARATOR.join(missing_items) if missing_items else "profil"
250249

251-
settings = get_settings()
252250
registry = get_group_registry()
253251

254252
try:

tests/test_check.py

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,9 @@ async def test_warn_callback_success(
415415
mock_chat.full_name = "Test User"
416416
mock_context.bot.get_chat.return_value = mock_chat
417417

418-
with (
419-
patch("bot.handlers.check.get_settings", return_value=mock_settings),
420-
patch(
421-
"bot.handlers.check.get_group_registry",
422-
return_value=mock_registry,
423-
),
418+
with patch(
419+
"bot.handlers.check.get_group_registry",
420+
return_value=mock_registry,
424421
):
425422
await handle_warn_callback(update, mock_context)
426423

@@ -458,12 +455,9 @@ async def test_warn_callback_success_missing_photo_only(
458455
mock_chat.username = "testuser"
459456
mock_context.bot.get_chat.return_value = mock_chat
460457

461-
with (
462-
patch("bot.handlers.check.get_settings", return_value=mock_settings),
463-
patch(
464-
"bot.handlers.check.get_group_registry",
465-
return_value=mock_registry,
466-
),
458+
with patch(
459+
"bot.handlers.check.get_group_registry",
460+
return_value=mock_registry,
467461
):
468462
await handle_warn_callback(update, mock_context)
469463

@@ -533,12 +527,9 @@ async def test_warn_callback_send_message_error(
533527
mock_context.bot.get_chat.return_value = mock_chat
534528
mock_context.bot.send_message.side_effect = Exception("Failed to send")
535529

536-
with (
537-
patch("bot.handlers.check.get_settings", return_value=mock_settings),
538-
patch(
539-
"bot.handlers.check.get_group_registry",
540-
return_value=mock_registry,
541-
),
530+
with patch(
531+
"bot.handlers.check.get_group_registry",
532+
return_value=mock_registry,
542533
):
543534
await handle_warn_callback(update, mock_context)
544535

@@ -565,12 +556,9 @@ async def test_warn_callback_timeout(
565556
mock_context.bot.get_chat.return_value = mock_chat
566557
mock_context.bot.send_message.side_effect = TimedOut()
567558

568-
with (
569-
patch("bot.handlers.check.get_settings", return_value=mock_settings),
570-
patch(
571-
"bot.handlers.check.get_group_registry",
572-
return_value=mock_registry,
573-
),
559+
with patch(
560+
"bot.handlers.check.get_group_registry",
561+
return_value=mock_registry,
574562
):
575563
await handle_warn_callback(update, mock_context)
576564

@@ -596,12 +584,9 @@ async def test_warn_callback_get_chat_timeout(
596584

597585
mock_context.bot.get_chat.side_effect = TimedOut()
598586

599-
with (
600-
patch("bot.handlers.check.get_settings", return_value=mock_settings),
601-
patch(
602-
"bot.handlers.check.get_group_registry",
603-
return_value=mock_registry,
604-
),
587+
with patch(
588+
"bot.handlers.check.get_group_registry",
589+
return_value=mock_registry,
605590
):
606591
await handle_warn_callback(update, mock_context)
607592

tests/test_group_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import json
44
import tempfile
55
from datetime import timedelta
6-
from pathlib import Path
76
from unittest.mock import MagicMock, patch
87

98
import pytest

0 commit comments

Comments
 (0)