Skip to content

Commit 5f65f20

Browse files
author
timhauke
committed
Refactor: Improve code readability and remove unused imports
Reformat multi-line string literals in command files for better readability and style consistency. Remove unused `Dict` type hint imports from service files. Apply minor whitespace adjustments.
1 parent b80b1e1 commit 5f65f20

File tree

9 files changed

+30
-10
lines changed

9 files changed

+30
-10
lines changed

src/commands/chaos_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _ensure_manage_guild(inter: discord.Interaction) -> Optional[str]:
3535
if not isinstance(member, discord.Member):
3636
return "Unable to resolve member."
3737
if not member.guild_permissions.manage_guild:
38-
return "You need the `Manage Server` permission."
38+
return "You need the `Manage Server` permission."
3939
return None
4040

4141
@chaos.command(name="status", description="Show recent chaos drills and schedule info.")

src/commands/connection_commands.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ async def disconnect(self, inter: discord.Interaction):
131131
player = self._find_player(self.bot, inter.guild.id)
132132

133133
if not voice_client and not player:
134-
return await inter.response.send_message(embed=factory.warning("VectoBeat is not connected."), ephemeral=True)
134+
return await inter.response.send_message(
135+
embed=factory.warning("VectoBeat is not connected."),
136+
ephemeral=True,
137+
)
135138

136139
details = []
137140
if voice_client:

src/commands/music_controls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ def _require_dj(self, inter: discord.Interaction) -> Optional[str]:
9393
mentions.append(role.mention)
9494
if mentions:
9595
roles_text = ", ".join(mentions)
96-
return f"You must have one of the DJ roles ({roles_text}) or `Manage Server` permission to use this command."
96+
return (
97+
"You must have one of the DJ roles "
98+
f"({roles_text}) or `Manage Server` permission to use this command."
99+
)
97100
return "Only configured DJ roles may use this command. Ask an admin to run `/dj add-role`."
98101

99102
def _log_dj_action(self, inter: discord.Interaction, action: str, *, details: Optional[str] = None) -> None:

src/commands/queue_commands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ def _require_dj(self, inter: discord.Interaction) -> Optional[str]:
5959
if role:
6060
mentions.append(role.mention)
6161
if mentions:
62-
return f"You must have one of the DJ roles ({', '.join(mentions)}) or `Manage Server` permission to use this command."
62+
roles = ", ".join(mentions)
63+
return (
64+
"You must have one of the DJ roles "
65+
f"({roles}) or `Manage Server` permission to use this command."
66+
)
6367
return "Only configured DJ roles may use this command. Ask an admin to run `/dj add-role`."
6468

6569
def _log_dj_action(self, inter: discord.Interaction, action: str, *, details: Optional[str] = None) -> None:

src/services/chaos_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import asyncio
88
import logging
99
import random
10-
from typing import Deque, Dict, List, Optional, Tuple
10+
from typing import Deque, List, Optional, Tuple
1111
from collections import deque
1212

1313
import discord

src/services/dj_permission_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def load(self) -> None:
4141
raw = {}
4242
for guild_id, payload in raw.items():
4343
roles = [int(role) for role in payload.get("roles", [])]
44-
audit = payload.get("audit", [])[-self.max_audit :]
44+
audit = payload.get("audit", [])[-self.max_audit:]
4545
self._configs[guild_id] = DJGuildConfig(roles=roles, audit=audit)
4646

4747
def save(self) -> None:
@@ -62,7 +62,7 @@ def config(self, guild_id: int) -> DJGuildConfig:
6262
self._configs[key] = DJGuildConfig()
6363
config = self._configs[key]
6464
if len(config.audit) > self.max_audit:
65-
config.audit = config.audit[-self.max_audit :]
65+
config.audit = config.audit[-self.max_audit:]
6666
return config
6767

6868
# ------------------------------------------------------------------ role management
@@ -121,7 +121,7 @@ def record_action(
121121
"details": details or "",
122122
}
123123
config.audit.append(entry)
124-
config.audit = config.audit[-self.max_audit :]
124+
config.audit = config.audit[-self.max_audit:]
125125
self.save()
126126

127127
def recent_actions(self, guild_id: int, limit: int = 10) -> List[Dict[str, Any]]:

src/services/metrics_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import asyncio
88
import logging
9-
from typing import Dict, Optional
9+
from typing import Optional
1010

1111
import lavalink
1212
from prometheus_client import CollectorRegistry, Counter, Gauge, start_http_server

src/services/scaling_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import Any, Dict, Optional
1212

1313
import aiohttp
14-
import lavalink
1514
from discord.ext import commands
1615

1716
from src.configs.schema import ScalingConfig

tests/test_sanity.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Lightweight smoke tests to keep the CI quality gate healthy."""
2+
3+
from src.commands.queue_commands import ms_to_clock
4+
5+
6+
def test_ms_to_clock_formats_minutes_and_seconds():
7+
assert ms_to_clock(61_000) == "1:01"
8+
9+
10+
def test_ms_to_clock_formats_hours_minutes_seconds():
11+
assert ms_to_clock(3_661_000) == "1:01:01"

0 commit comments

Comments
 (0)