From f64fee8d2e693fde3ff386131774e372553a1f09 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 20 Feb 2026 11:35:04 -0600 Subject: [PATCH] fix: remove 226 unused imports across the codebase (closes #33) Ran `ruff check --select F401 --fix` to auto-remove 221 unused imports, manually removed 4 unused `import discord` from package __init__.py files, and fixed test import for DISAPPOINTMENT_TIERS to reference canonical location. Co-Authored-By: Claude Opus 4.6 --- bot.py | 2 +- commands/admin/__init__.py | 20 +-- commands/admin/league_management.py | 3 +- commands/admin/users.py | 3 +- commands/custom_commands/main.py | 5 +- commands/dice/rolls.py | 3 - commands/draft/list.py | 1 - commands/examples/enhanced_player.py | 4 +- commands/gameplay/scorebug.py | 4 +- commands/help/main.py | 3 +- commands/injuries/management.py | 3 - commands/league/__init__.py | 20 +-- commands/league/info.py | 4 - commands/league/standings.py | 1 - commands/profile/images.py | 2 +- commands/soak/giphy_service.py | 1 - commands/teams/__init__.py | 20 +-- commands/teams/info.py | 2 - commands/teams/roster.py | 6 +- commands/transactions/__init__.py | 28 ++-- commands/transactions/dropadd.py | 3 +- commands/transactions/ilmove.py | 1 - commands/transactions/trade.py | 1 - .../transactions/trade_channel_tracker.py | 1 - commands/utilities/charts.py | 2 +- commands/utilities/weather.py | 2 +- models/custom_command.py | 2 +- models/draft_list.py | 2 +- models/draft_pick.py | 4 +- models/injury.py | 2 +- models/trade.py | 3 +- models/transaction.py | 2 +- services/base_service.py | 1 - services/custom_commands_service.py | 3 +- services/decision_service.py | 1 - services/draft_list_service.py | 2 - services/draft_pick_service.py | 1 - services/draft_service.py | 1 - services/draft_sheet_service.py | 1 - services/help_commands_service.py | 1 - services/injury_service.py | 1 - services/roster_service.py | 1 - services/schedule_service.py | 2 - services/scorebug_service.py | 2 +- services/standings_service.py | 1 - services/stats_service.py | 4 +- services/trade_builder.py | 6 +- services/transaction_builder.py | 5 +- services/transaction_service.py | 3 +- tasks/custom_command_cleanup.py | 4 +- tasks/draft_monitor.py | 5 - tasks/live_scorebug_tracker.py | 3 +- tests/conftest.py | 6 +- tests/factories.py | 4 +- tests/test_api_client.py | 1 - tests/test_commands_charts.py | 5 +- tests/test_commands_dice.py | 2 +- tests/test_commands_dropadd.py | 4 - tests/test_commands_profile_images.py | 2 - tests/test_commands_soak.py | 128 +++++++++--------- tests/test_commands_teams_branding.py | 1 - tests/test_commands_voice.py | 2 - tests/test_config.py | 1 - tests/test_constants.py | 1 - tests/test_dropadd_integration.py | 5 +- tests/test_models.py | 1 - tests/test_models_trade.py | 1 - tests/test_models_transaction.py | 3 - tests/test_services_base_service.py | 1 - tests/test_services_custom_commands.py | 12 +- tests/test_services_draft_sheet.py | 3 +- tests/test_services_help_commands.py | 2 +- tests/test_services_injury.py | 2 +- tests/test_services_league_service.py | 1 - tests/test_services_trade_builder.py | 2 +- tests/test_services_transaction.py | 3 +- tests/test_services_transaction_builder.py | 2 - tests/test_tasks_custom_command_cleanup.py | 3 - tests/test_tasks_transaction_freeze.py | 3 +- tests/test_transactions_integration.py | 1 - tests/test_utils_decorators.py | 4 +- tests/test_utils_helpers.py | 1 - tests/test_utils_logging.py | 1 - tests/test_utils_scorebug_helpers.py | 1 - tests/test_views_custom_commands.py | 7 +- tests/test_views_injury_modals.py | 4 +- tests/test_views_transaction_embed.py | 5 +- utils/autocomplete.py | 2 +- utils/helpers.py | 1 - utils/injury_log.py | 3 +- utils/random_gen.py | 2 +- utils/scorebug_helpers.py | 1 - utils/transaction_logging.py | 1 - views/base.py | 4 +- views/common.py | 5 +- views/custom_commands.py | 4 +- views/draft_views.py | 2 - views/embeds.py | 2 +- views/help_commands.py | 6 +- views/modals.py | 4 +- views/players.py | 2 - views/trade_embed.py | 2 +- views/transaction_embed.py | 3 - 103 files changed, 183 insertions(+), 294 deletions(-) diff --git a/bot.py b/bot.py index 1bcd26f..ca1c07e 100644 --- a/bot.py +++ b/bot.py @@ -18,7 +18,7 @@ from config import get_config from exceptions import BotException from api.client import get_global_client, cleanup_global_client from utils.random_gen import STARTUP_WATCHING, random_from_list -from views.embeds import EmbedTemplate, EmbedColors +from views.embeds import EmbedTemplate def setup_logging(): diff --git a/commands/admin/__init__.py b/commands/admin/__init__.py index 4ab3e0c..6628542 100644 --- a/commands/admin/__init__.py +++ b/commands/admin/__init__.py @@ -3,23 +3,23 @@ Admin command package for Discord Bot v2.0 Contains administrative commands for league management. """ + import logging from typing import List, Tuple, Type -import discord from discord.ext import commands from .management import AdminCommands from .users import UserManagementCommands from .league_management import LeagueManagementCommands -logger = logging.getLogger(f'{__name__}.setup_admin') +logger = logging.getLogger(f"{__name__}.setup_admin") async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]: """ Set up admin command modules. - + Returns: Tuple of (successful_loads, failed_loads, failed_modules) """ @@ -28,11 +28,11 @@ async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]: ("UserManagementCommands", UserManagementCommands), ("LeagueManagementCommands", LeagueManagementCommands), ] - + successful = 0 failed = 0 failed_modules = [] - + for cog_name, cog_class in admin_cogs: try: await bot.add_cog(cog_class(bot)) @@ -42,13 +42,15 @@ async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]: logger.error(f"❌ Failed to load admin command module {cog_name}: {e}") failed += 1 failed_modules.append(cog_name) - + # Log summary if failed == 0: logger.info(f"🎉 All {successful} admin command modules loaded successfully") else: - logger.warning(f"⚠️ Admin commands loaded with issues: {successful} successful, {failed} failed") + logger.warning( + f"⚠️ Admin commands loaded with issues: {successful} successful, {failed} failed" + ) if failed_modules: logger.warning(f"Failed modules: {', '.join(failed_modules)}") - - return successful, failed, failed_modules \ No newline at end of file + + return successful, failed, failed_modules diff --git a/commands/admin/league_management.py b/commands/admin/league_management.py index 2f24f9e..68947d4 100644 --- a/commands/admin/league_management.py +++ b/commands/admin/league_management.py @@ -10,11 +10,10 @@ import discord from discord.ext import commands from discord import app_commands -from config import get_config from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.permissions import league_admin_only -from views.embeds import EmbedColors, EmbedTemplate +from views.embeds import EmbedTemplate from services.league_service import league_service from services.transaction_service import transaction_service from tasks.transaction_freeze import resolve_contested_transactions diff --git a/commands/admin/users.py b/commands/admin/users.py index 65520bf..665c40e 100644 --- a/commands/admin/users.py +++ b/commands/admin/users.py @@ -4,8 +4,7 @@ Admin User Management Commands User-focused administrative commands for moderation and user management. """ from typing import Optional, Union -import asyncio -from datetime import datetime, timedelta +from datetime import timedelta import discord from discord.ext import commands diff --git a/commands/custom_commands/main.py b/commands/custom_commands/main.py index fe942c9..e72130f 100644 --- a/commands/custom_commands/main.py +++ b/commands/custom_commands/main.py @@ -10,9 +10,7 @@ from discord.ext import commands from services.custom_commands_service import ( custom_commands_service, - CustomCommandNotFoundError, - CustomCommandExistsError, - CustomCommandPermissionError + CustomCommandNotFoundError ) from models.custom_command import CustomCommandSearchFilters from utils.logging import get_contextual_logger @@ -28,7 +26,6 @@ from views.custom_commands import ( CustomCommandSearchModal, SingleCommandManagementView ) -from exceptions import BotException class CustomCommandsCommands(commands.Cog): diff --git a/commands/dice/rolls.py b/commands/dice/rolls.py index 0935005..b974cbe 100644 --- a/commands/dice/rolls.py +++ b/commands/dice/rolls.py @@ -4,14 +4,11 @@ Dice Rolling Commands Implements slash commands for dice rolling functionality required for gameplay. """ import random -from typing import Optional import discord from discord.ext import commands -from models.team import Team from services.team_service import team_service -from utils import team_utils from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.team_utils import get_user_major_league_team diff --git a/commands/draft/list.py b/commands/draft/list.py index 42cc376..5ced610 100644 --- a/commands/draft/list.py +++ b/commands/draft/list.py @@ -6,7 +6,6 @@ Manage team auto-draft queue (draft board). from typing import List, Optional import discord -from discord import app_commands from discord.ext import commands from config import get_config diff --git a/commands/examples/enhanced_player.py b/commands/examples/enhanced_player.py index 693b510..30b4143 100644 --- a/commands/examples/enhanced_player.py +++ b/commands/examples/enhanced_player.py @@ -14,7 +14,6 @@ from services.player_service import player_service from models.player import Player from utils.logging import get_contextual_logger from utils.decorators import logged_command -from exceptions import BotException # Import our new view components from views import ( @@ -24,8 +23,7 @@ from views import ( PlayerSelectionView, DetailedInfoView, SearchResultsView, - PlayerSearchModal, - PaginationView + PlayerSearchModal ) diff --git a/commands/gameplay/scorebug.py b/commands/gameplay/scorebug.py index 8030a2a..24b996a 100644 --- a/commands/gameplay/scorebug.py +++ b/commands/gameplay/scorebug.py @@ -7,13 +7,13 @@ import discord from discord.ext import commands from discord import app_commands -from services.scorebug_service import ScorebugData, ScorebugService +from services.scorebug_service import ScorebugService from services.team_service import team_service from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.permissions import league_only from utils.scorebug_helpers import create_scorebug_embed -from views.embeds import EmbedTemplate, EmbedColors +from views.embeds import EmbedTemplate from exceptions import SheetsException from .scorecard_tracker import ScorecardTracker diff --git a/commands/help/main.py b/commands/help/main.py index f0bde14..ebfbf66 100644 --- a/commands/help/main.py +++ b/commands/help/main.py @@ -17,7 +17,7 @@ from services.help_commands_service import ( from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.permissions import league_admin_only -from views.embeds import EmbedTemplate, EmbedColors +from views.embeds import EmbedTemplate from views.help_commands import ( HelpCommandCreateModal, HelpCommandEditModal, @@ -25,7 +25,6 @@ from views.help_commands import ( HelpCommandListView, create_help_topic_embed ) -from exceptions import BotException async def help_topic_autocomplete( diff --git a/commands/injuries/management.py b/commands/injuries/management.py index 9e9fb4b..cf030dd 100644 --- a/commands/injuries/management.py +++ b/commands/injuries/management.py @@ -18,9 +18,6 @@ from discord import app_commands from discord.ext import commands from config import get_config -from models.current import Current -from models.injury import Injury -from models.player import Player from models.team import RosterType from services.player_service import player_service from services.injury_service import injury_service diff --git a/commands/league/__init__.py b/commands/league/__init__.py index a674b5c..f234141 100644 --- a/commands/league/__init__.py +++ b/commands/league/__init__.py @@ -3,10 +3,10 @@ League command package for Discord Bot v2.0 Provides league-wide slash commands for standings and current state. """ + import logging from typing import List, Tuple, Type -import discord from discord.ext import commands from .info import LeagueInfoCommands @@ -14,13 +14,13 @@ from .standings import StandingsCommands from .schedule import ScheduleCommands from .submit_scorecard import SubmitScorecardCommands -logger = logging.getLogger(f'{__name__}.setup_league') +logger = logging.getLogger(f"{__name__}.setup_league") async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]: """ Set up league command modules. - + Returns: Tuple of (successful_loads, failed_loads, failed_modules) """ @@ -30,11 +30,11 @@ async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]: ("ScheduleCommands", ScheduleCommands), ("SubmitScorecardCommands", SubmitScorecardCommands), ] - + successful = 0 failed = 0 failed_modules = [] - + for cog_name, cog_class in league_cogs: try: await bot.add_cog(cog_class(bot)) @@ -44,13 +44,15 @@ async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]: logger.error(f"❌ Failed to load league command module {cog_name}: {e}") failed += 1 failed_modules.append(cog_name) - + # Log summary if failed == 0: logger.info(f"🎉 All {successful} league command modules loaded successfully") else: - logger.warning(f"⚠️ League commands loaded with issues: {successful} successful, {failed} failed") + logger.warning( + f"⚠️ League commands loaded with issues: {successful} successful, {failed} failed" + ) if failed_modules: logger.warning(f"Failed modules: {', '.join(failed_modules)}") - - return successful, failed, failed_modules \ No newline at end of file + + return successful, failed, failed_modules diff --git a/commands/league/info.py b/commands/league/info.py index f5d4a78..ccd5f92 100644 --- a/commands/league/info.py +++ b/commands/league/info.py @@ -1,17 +1,13 @@ """ League information commands for Discord Bot v2.0 """ -import logging -from typing import Optional import discord from discord.ext import commands from services import league_service -from config import get_config from utils.logging import get_contextual_logger from utils.decorators import logged_command -from exceptions import BotException from utils.permissions import requires_team from views.embeds import EmbedTemplate diff --git a/commands/league/standings.py b/commands/league/standings.py index 799b3f1..0bd255f 100644 --- a/commands/league/standings.py +++ b/commands/league/standings.py @@ -9,7 +9,6 @@ import discord from discord.ext import commands from config import get_config -from models.team import Team from services.standings_service import standings_service from utils.logging import get_contextual_logger from utils.decorators import logged_command diff --git a/commands/profile/images.py b/commands/profile/images.py index a3308b4..ae89e20 100644 --- a/commands/profile/images.py +++ b/commands/profile/images.py @@ -4,7 +4,7 @@ Player Image Management Commands Allows users to update player fancy card and headshot images for players on teams they own. Admins can update any player's images. """ -from typing import Optional, List, Tuple +from typing import List, Tuple import asyncio import aiohttp diff --git a/commands/soak/giphy_service.py b/commands/soak/giphy_service.py index 6b3fcca..5cb5390 100644 --- a/commands/soak/giphy_service.py +++ b/commands/soak/giphy_service.py @@ -9,7 +9,6 @@ All new code should import from services.giphy_service instead. from services import giphy_service # Re-export tier configuration for backwards compatibility -from services.giphy_service import DISAPPOINTMENT_TIERS def get_tier_for_seconds(seconds_elapsed): diff --git a/commands/teams/__init__.py b/commands/teams/__init__.py index a062c44..7e1b593 100644 --- a/commands/teams/__init__.py +++ b/commands/teams/__init__.py @@ -3,23 +3,23 @@ Team command package for Discord Bot v2.0 Provides team-related slash commands for the SBA league. """ + import logging from typing import List, Tuple, Type -import discord from discord.ext import commands from .info import TeamInfoCommands from .roster import TeamRosterCommands from .branding import BrandingCommands -logger = logging.getLogger(f'{__name__}.setup_teams') +logger = logging.getLogger(f"{__name__}.setup_teams") async def setup_teams(bot: commands.Bot) -> Tuple[int, int, List[str]]: """ Set up team command modules. - + Returns: Tuple of (successful_loads, failed_loads, failed_modules) """ @@ -28,11 +28,11 @@ async def setup_teams(bot: commands.Bot) -> Tuple[int, int, List[str]]: ("TeamRosterCommands", TeamRosterCommands), ("BrandingCommands", BrandingCommands), ] - + successful = 0 failed = 0 failed_modules = [] - + for cog_name, cog_class in team_cogs: try: await bot.add_cog(cog_class(bot)) @@ -42,13 +42,15 @@ async def setup_teams(bot: commands.Bot) -> Tuple[int, int, List[str]]: logger.error(f"❌ Failed to load team command module {cog_name}: {e}") failed += 1 failed_modules.append(cog_name) - + # Log summary if failed == 0: logger.info(f"🎉 All {successful} team command modules loaded successfully") else: - logger.warning(f"⚠️ Team commands loaded with issues: {successful} successful, {failed} failed") + logger.warning( + f"⚠️ Team commands loaded with issues: {successful} successful, {failed} failed" + ) if failed_modules: logger.warning(f"Failed modules: {', '.join(failed_modules)}") - - return successful, failed, failed_modules \ No newline at end of file + + return successful, failed, failed_modules diff --git a/commands/teams/info.py b/commands/teams/info.py index dde01f3..012edff 100644 --- a/commands/teams/info.py +++ b/commands/teams/info.py @@ -1,7 +1,6 @@ """ Team information commands for Discord Bot v2.0 """ -import logging from typing import Optional from config import get_config @@ -12,7 +11,6 @@ from services import team_service, player_service from models.team import RosterType, Team from utils.logging import get_contextual_logger from utils.decorators import logged_command -from exceptions import BotException from views.embeds import EmbedTemplate, EmbedColors from views.base import PaginationView diff --git a/commands/teams/roster.py b/commands/teams/roster.py index ce7b7e3..1acbddc 100644 --- a/commands/teams/roster.py +++ b/commands/teams/roster.py @@ -1,19 +1,17 @@ """ Team roster commands for Discord Bot v2.0 """ -import logging -from typing import Optional, Dict, Any, List +from typing import Dict, Any, List import discord from discord.ext import commands from config import get_config from models.player import Player -from services import team_service, player_service +from services import team_service from models.team import Team from utils.logging import get_contextual_logger from utils.decorators import logged_command -from exceptions import BotException from utils.permissions import requires_team from views.embeds import EmbedTemplate, EmbedColors diff --git a/commands/transactions/__init__.py b/commands/transactions/__init__.py index ed46747..05e18fb 100644 --- a/commands/transactions/__init__.py +++ b/commands/transactions/__init__.py @@ -3,10 +3,10 @@ Transaction command package for Discord Bot v2.0 Contains transaction management commands for league operations. """ + import logging from typing import List, Tuple, Type -import discord from discord.ext import commands from .management import TransactionCommands @@ -14,13 +14,13 @@ from .dropadd import DropAddCommands from .trade import TradeCommands from .ilmove import ILMoveCommands -logger = logging.getLogger(f'{__name__}.setup_transactions') +logger = logging.getLogger(f"{__name__}.setup_transactions") async def setup_transactions(bot: commands.Bot) -> Tuple[int, int, List[str]]: """ Set up transaction command modules. - + Returns: Tuple of (successful_loads, failed_loads, failed_modules) """ @@ -30,27 +30,33 @@ async def setup_transactions(bot: commands.Bot) -> Tuple[int, int, List[str]]: ("TradeCommands", TradeCommands), ("ILMoveCommands", ILMoveCommands), ] - + successful = 0 failed = 0 failed_modules = [] - + for cog_name, cog_class in transaction_cogs: try: await bot.add_cog(cog_class(bot)) logger.info(f"✅ Loaded transaction command module: {cog_name}") successful += 1 except Exception as e: - logger.error(f"❌ Failed to load transaction command module {cog_name}: {e}") + logger.error( + f"❌ Failed to load transaction command module {cog_name}: {e}" + ) failed += 1 failed_modules.append(cog_name) - + # Log summary if failed == 0: - logger.info(f"🎉 All {successful} transaction command modules loaded successfully") + logger.info( + f"🎉 All {successful} transaction command modules loaded successfully" + ) else: - logger.warning(f"⚠️ Transaction commands loaded with issues: {successful} successful, {failed} failed") + logger.warning( + f"⚠️ Transaction commands loaded with issues: {successful} successful, {failed} failed" + ) if failed_modules: logger.warning(f"Failed modules: {', '.join(failed_modules)}") - - return successful, failed, failed_modules \ No newline at end of file + + return successful, failed, failed_modules diff --git a/commands/transactions/dropadd.py b/commands/transactions/dropadd.py index 4fa5df9..3225949 100644 --- a/commands/transactions/dropadd.py +++ b/commands/transactions/dropadd.py @@ -3,7 +3,7 @@ Modern /dropadd Command Interactive transaction builder with real-time validation and elegant UX. """ -from typing import Optional, List +from typing import Optional import discord from discord.ext import commands @@ -24,7 +24,6 @@ from services.transaction_builder import ( clear_transaction_builder ) from services.player_service import player_service -from services.team_service import team_service from views.transaction_embed import TransactionEmbedView, create_transaction_embed diff --git a/commands/transactions/ilmove.py b/commands/transactions/ilmove.py index f801906..eb5821f 100644 --- a/commands/transactions/ilmove.py +++ b/commands/transactions/ilmove.py @@ -29,7 +29,6 @@ from services.transaction_builder import ( ) from services.player_service import player_service from services.team_service import team_service -from services.league_service import league_service from views.transaction_embed import TransactionEmbedView, create_transaction_embed diff --git a/commands/transactions/trade.py b/commands/transactions/trade.py index 52e0faa..f937152 100644 --- a/commands/transactions/trade.py +++ b/commands/transactions/trade.py @@ -16,7 +16,6 @@ from utils.autocomplete import player_autocomplete, major_league_team_autocomple from utils.team_utils import validate_user_has_team, get_team_by_abbrev_with_validation from services.trade_builder import ( - TradeBuilder, get_trade_builder, get_trade_builder_by_team, clear_trade_builder, diff --git a/commands/transactions/trade_channel_tracker.py b/commands/transactions/trade_channel_tracker.py index 58b6ff3..f3d34c3 100644 --- a/commands/transactions/trade_channel_tracker.py +++ b/commands/transactions/trade_channel_tracker.py @@ -4,7 +4,6 @@ Trade Channel Tracker Provides persistent tracking of bot-created trade discussion channels using JSON file storage. """ import json -import logging from datetime import datetime, UTC from pathlib import Path from typing import Dict, List, Optional, Any diff --git a/commands/utilities/charts.py b/commands/utilities/charts.py index e3b1b9c..d19b487 100644 --- a/commands/utilities/charts.py +++ b/commands/utilities/charts.py @@ -12,7 +12,7 @@ from typing import List, Optional from config import get_config from utils.decorators import logged_command from utils.logging import get_contextual_logger, set_discord_context -from services.chart_service import get_chart_service, Chart +from services.chart_service import get_chart_service from views.embeds import EmbedTemplate, EmbedColors from exceptions import BotException diff --git a/commands/utilities/weather.py b/commands/utilities/weather.py index ba3bbbe..38a75e3 100644 --- a/commands/utilities/weather.py +++ b/commands/utilities/weather.py @@ -4,7 +4,7 @@ Weather command for Discord Bot v2.0 Provides ballpark weather checks with dice rolls for gameplay. """ import random -from typing import Optional, Tuple +from typing import Optional import discord from discord.ext import commands diff --git a/models/custom_command.py b/models/custom_command.py index ac8602b..a65b3b2 100644 --- a/models/custom_command.py +++ b/models/custom_command.py @@ -4,7 +4,7 @@ Custom Command models for Discord Bot v2.0 Modern Pydantic models for the custom command system with full type safety. """ from datetime import datetime -from typing import Optional, Dict, Any +from typing import Optional import re from pydantic import BaseModel, Field, field_validator diff --git a/models/draft_list.py b/models/draft_list.py index 709675e..a7dc4ca 100644 --- a/models/draft_list.py +++ b/models/draft_list.py @@ -3,7 +3,7 @@ Draft preference list model Represents team draft board rankings and preferences. """ -from typing import Optional, Dict, Any +from typing import Dict, Any from pydantic import Field from models.base import SBABaseModel diff --git a/models/draft_pick.py b/models/draft_pick.py index 948fb3a..3529eab 100644 --- a/models/draft_pick.py +++ b/models/draft_pick.py @@ -9,8 +9,8 @@ When the API short_output=false, these fields contain full Team/Player objects. When short_output=true (or default), they contain integer IDs. We use Pydantic aliases to handle both cases. """ -from typing import Optional, Any, Dict, Union -from pydantic import Field, field_validator, model_validator +from typing import Optional, Any, Dict +from pydantic import Field from models.base import SBABaseModel from models.team import Team diff --git a/models/injury.py b/models/injury.py index 53455e4..f8194cd 100644 --- a/models/injury.py +++ b/models/injury.py @@ -3,7 +3,7 @@ Injury model for tracking player injuries Represents an injury record with game timeline and status information. """ -from typing import Optional, Any, Dict +from typing import Any from pydantic import Field, model_validator from models.base import SBABaseModel diff --git a/models/trade.py b/models/trade.py index 1bce54e..d250c34 100644 --- a/models/trade.py +++ b/models/trade.py @@ -3,11 +3,10 @@ Trade-specific data models for multi-team transactions. Extends the base transaction system to support trades between multiple teams. """ -from typing import List, Optional, Dict, Set +from typing import List, Optional from dataclasses import dataclass from enum import Enum -from models.player import Player from models.team import Team, RosterType from services.transaction_builder import TransactionMove diff --git a/models/transaction.py b/models/transaction.py index e50defd..e0c6fea 100644 --- a/models/transaction.py +++ b/models/transaction.py @@ -3,7 +3,7 @@ Transaction models for SBA transaction management Represents transactions and player moves based on actual API structure. """ -from typing import Optional, List +from typing import List from pydantic import Field from models.base import SBABaseModel diff --git a/services/base_service.py b/services/base_service.py index e1677b3..e919e6b 100644 --- a/services/base_service.py +++ b/services/base_service.py @@ -5,7 +5,6 @@ Provides common CRUD operations and error handling for all data services. """ import logging import hashlib -import json from typing import Optional, Type, TypeVar, Generic, Dict, Any, List, Tuple from api.client import get_global_client, APIClient diff --git a/services/custom_commands_service.py b/services/custom_commands_service.py index 13c5b2a..ff8cf11 100644 --- a/services/custom_commands_service.py +++ b/services/custom_commands_service.py @@ -3,10 +3,9 @@ Custom Commands Service for Discord Bot v2.0 Modern async service layer for managing custom commands with full type safety. """ -import asyncio import math from datetime import datetime, timedelta -from typing import Optional, List, Dict, Any, Tuple +from typing import Optional, List, Any, Tuple from utils.logging import get_contextual_logger from models.custom_command import ( diff --git a/services/decision_service.py b/services/decision_service.py index cf6a2cc..e101d0e 100644 --- a/services/decision_service.py +++ b/services/decision_service.py @@ -7,7 +7,6 @@ from typing import List, Dict, Any, Optional, Tuple from utils.logging import get_contextual_logger from api.client import get_global_client -from models.decision import Decision from models.player import Player from exceptions import APIException diff --git a/services/draft_list_service.py b/services/draft_list_service.py index 47f2dd1..2a7017d 100644 --- a/services/draft_list_service.py +++ b/services/draft_list_service.py @@ -8,7 +8,6 @@ from typing import Optional, List from services.base_service import BaseService from models.draft_list import DraftList -from exceptions import APIException logger = logging.getLogger(f'{__name__}.DraftListService') @@ -46,7 +45,6 @@ class DraftListService(BaseService[DraftList]): Returns: Tuple of (items list, total count) """ - from typing import Any, Dict, List, Tuple if isinstance(data, list): return data, len(data) diff --git a/services/draft_pick_service.py b/services/draft_pick_service.py index fecd61c..8327855 100644 --- a/services/draft_pick_service.py +++ b/services/draft_pick_service.py @@ -8,7 +8,6 @@ from typing import Optional, List from services.base_service import BaseService from models.draft_pick import DraftPick -from exceptions import APIException logger = logging.getLogger(f'{__name__}.DraftPickService') diff --git a/services/draft_service.py b/services/draft_service.py index 991334a..e8450cd 100644 --- a/services/draft_service.py +++ b/services/draft_service.py @@ -9,7 +9,6 @@ from datetime import datetime, timedelta from services.base_service import BaseService from models.draft_data import DraftData -from exceptions import APIException logger = logging.getLogger(f'{__name__}.DraftService') diff --git a/services/draft_sheet_service.py b/services/draft_sheet_service.py index ba8d320..fa28f66 100644 --- a/services/draft_sheet_service.py +++ b/services/draft_sheet_service.py @@ -8,7 +8,6 @@ import asyncio from typing import List, Optional, Tuple from config import get_config -from exceptions import SheetsException from services.sheets_service import SheetsService from utils.logging import get_contextual_logger diff --git a/services/help_commands_service.py b/services/help_commands_service.py index 1543ed0..473adb6 100644 --- a/services/help_commands_service.py +++ b/services/help_commands_service.py @@ -5,7 +5,6 @@ Modern async service layer for managing help commands with full type safety. Allows admins and help editors to create custom help topics for league documentation, resources, FAQs, links, and guides. """ -import math from typing import Optional, List from utils.logging import get_contextual_logger diff --git a/services/injury_service.py b/services/injury_service.py index 1b379aa..555a7a5 100644 --- a/services/injury_service.py +++ b/services/injury_service.py @@ -8,7 +8,6 @@ from typing import Optional, List from services.base_service import BaseService from models.injury import Injury -from exceptions import APIException logger = logging.getLogger(f'{__name__}.InjuryService') diff --git a/services/roster_service.py b/services/roster_service.py index de03731..9ee7648 100644 --- a/services/roster_service.py +++ b/services/roster_service.py @@ -7,7 +7,6 @@ Handles roster operations and validation. import logging from typing import Optional, List, Dict -from services.base_service import BaseService from models.roster import TeamRoster from models.player import Player from models.transaction import RosterValidation diff --git a/services/schedule_service.py b/services/schedule_service.py index a8bf406..c537239 100644 --- a/services/schedule_service.py +++ b/services/schedule_service.py @@ -6,9 +6,7 @@ Handles game schedule and results retrieval and processing. import logging from typing import Optional, List, Dict, Tuple -from services.base_service import BaseService from models.game import Game -from exceptions import APIException logger = logging.getLogger(f'{__name__}.ScheduleService') diff --git a/services/scorebug_service.py b/services/scorebug_service.py index 0c6f3f5..cac00ee 100644 --- a/services/scorebug_service.py +++ b/services/scorebug_service.py @@ -4,7 +4,7 @@ Scorebug Service Handles reading live game data from Google Sheets scorecards for real-time score displays. """ import asyncio -from typing import Dict, List, Any, Optional +from typing import Dict, Any, Optional import pygsheets from utils.logging import get_contextual_logger diff --git a/services/standings_service.py b/services/standings_service.py index 1d71bf2..af3b164 100644 --- a/services/standings_service.py +++ b/services/standings_service.py @@ -6,7 +6,6 @@ Handles team standings retrieval and processing. import logging from typing import Optional, List, Dict -from services.base_service import BaseService from models.standings import TeamStandings from exceptions import APIException diff --git a/services/stats_service.py b/services/stats_service.py index 54eb38d..323c956 100644 --- a/services/stats_service.py +++ b/services/stats_service.py @@ -4,12 +4,10 @@ Statistics service for Discord Bot v2.0 Handles batting and pitching statistics retrieval and processing. """ import logging -from typing import Optional, List +from typing import Optional -from services.base_service import BaseService from models.batting_stats import BattingStats from models.pitching_stats import PitchingStats -from exceptions import APIException logger = logging.getLogger(f'{__name__}.StatsService') diff --git a/services/trade_builder.py b/services/trade_builder.py index 6550ffe..879959f 100644 --- a/services/trade_builder.py +++ b/services/trade_builder.py @@ -4,18 +4,16 @@ Trade Builder Service Extends the TransactionBuilder to support multi-team trades and player exchanges. """ import logging -from typing import Dict, List, Optional, Set, Tuple +from typing import Dict, List, Optional, Set from datetime import datetime, timezone import uuid from config import get_config -from models.trade import Trade, TradeParticipant, TradeMove, TradeStatus +from models.trade import Trade, TradeMove, TradeStatus from models.team import Team, RosterType from models.player import Player from services.transaction_builder import TransactionBuilder, RosterValidationResult, TransactionMove from services.team_service import team_service -from services.roster_service import roster_service -from services.league_service import league_service logger = logging.getLogger(f'{__name__}.TradeBuilder') diff --git a/services/transaction_builder.py b/services/transaction_builder.py index 2993f7c..ffa4927 100644 --- a/services/transaction_builder.py +++ b/services/transaction_builder.py @@ -4,8 +4,7 @@ Transaction Builder Service Handles the complex logic for building multi-move transactions interactively. """ import logging -from typing import Dict, List, Optional, Tuple, Set -from enum import Enum +from typing import Dict, List, Optional from dataclasses import dataclass from datetime import datetime, timezone @@ -14,8 +13,6 @@ from models.transaction import Transaction from models.team import Team from models.player import Player from models.roster import TeamRoster -from services.player_service import player_service -from services.team_service import team_service from services.roster_service import roster_service from services.transaction_service import transaction_service from services.league_service import league_service diff --git a/services/transaction_service.py b/services/transaction_service.py index 4d103d8..44e2a01 100644 --- a/services/transaction_service.py +++ b/services/transaction_service.py @@ -4,12 +4,11 @@ Transaction service for Discord Bot v2.0 Handles transaction CRUD operations and business logic. """ import logging -from typing import Optional, List, Tuple +from typing import Optional, List from datetime import datetime, UTC from services.base_service import BaseService from models.transaction import Transaction, RosterValidation -from models.roster import TeamRoster from exceptions import APIException logger = logging.getLogger(f'{__name__}.TransactionService') diff --git a/tasks/custom_command_cleanup.py b/tasks/custom_command_cleanup.py index 87af4ec..78734e1 100644 --- a/tasks/custom_command_cleanup.py +++ b/tasks/custom_command_cleanup.py @@ -5,7 +5,7 @@ Modern automated cleanup system with better notifications and logging. """ import asyncio from datetime import datetime, timedelta, UTC -from typing import Dict, List, Optional +from typing import Dict, List import discord from discord.ext import commands, tasks @@ -13,7 +13,7 @@ from discord.ext import commands, tasks from services.custom_commands_service import custom_commands_service from models.custom_command import CustomCommand from utils.logging import get_contextual_logger -from views.embeds import EmbedTemplate, EmbedColors +from views.embeds import EmbedTemplate from config import get_config diff --git a/tasks/draft_monitor.py b/tasks/draft_monitor.py index aa5e7a1..1edc4af 100644 --- a/tasks/draft_monitor.py +++ b/tasks/draft_monitor.py @@ -4,9 +4,7 @@ Draft Monitor Task for Discord Bot v2.0 Automated background task for draft timer monitoring, warnings, and auto-draft. Self-terminates when draft timer is disabled to conserve resources. """ -import asyncio from datetime import datetime -from typing import Optional import discord from discord.ext import commands, tasks @@ -15,12 +13,9 @@ from services.draft_service import draft_service from services.draft_pick_service import draft_pick_service from services.draft_list_service import draft_list_service from services.draft_sheet_service import get_draft_sheet_service -from services.player_service import player_service -from services.team_service import team_service from services.roster_service import roster_service from utils.logging import get_contextual_logger from utils.helpers import get_team_salary_cap -from views.embeds import EmbedTemplate, EmbedColors from views.draft_views import create_on_clock_announcement_embed from config import get_config diff --git a/tasks/live_scorebug_tracker.py b/tasks/live_scorebug_tracker.py index 2885434..5f76269 100644 --- a/tasks/live_scorebug_tracker.py +++ b/tasks/live_scorebug_tracker.py @@ -4,7 +4,7 @@ Live Scorebug Tracker Background task that monitors published scorecards and updates live score displays. """ import asyncio -from typing import List, Optional +from typing import List import discord from discord.ext import tasks, commands @@ -16,7 +16,6 @@ from services.scorebug_service import ScorebugData, ScorebugService from services.team_service import team_service from commands.gameplay.scorecard_tracker import ScorecardTracker from commands.voice.tracker import VoiceChannelTracker -from views.embeds import EmbedTemplate, EmbedColors from config import get_config from exceptions import SheetsException diff --git a/tests/conftest.py b/tests/conftest.py index 3083dd0..c389d9e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,7 @@ Pytest configuration and fixtures for Discord Bot v2.0 tests. This file provides test isolation and shared fixtures. """ + import asyncio import os import pytest @@ -27,12 +28,14 @@ def reset_singleton_state(): # Reset transaction builder caches try: from services.transaction_builder import _transaction_builders + _transaction_builders.clear() except ImportError: pass try: from services.trade_builder import _trade_builders, _team_to_trade_key + _trade_builders.clear() _team_to_trade_key.clear() except ImportError: @@ -40,8 +43,9 @@ def reset_singleton_state(): # Reset config singleton to ensure clean state try: - from config import _config + from config import _config # noqa: F401 import config as cfg + cfg._config = None except (ImportError, AttributeError): pass diff --git a/tests/factories.py b/tests/factories.py index 84b6658..8cdbd89 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -5,10 +5,10 @@ Provides factory functions to create test instances of models with sensible defa This eliminates the need for ad-hoc fixture creation and makes tests resilient to model changes. """ -from typing import Optional, Dict, Any +from typing import Optional from models.player import Player -from models.team import Team, RosterType +from models.team import Team from models.transaction import Transaction from models.game import Game from models.current import Current diff --git a/tests/test_api_client.py b/tests/test_api_client.py index c16693b..14edf0f 100644 --- a/tests/test_api_client.py +++ b/tests/test_api_client.py @@ -3,7 +3,6 @@ API client tests using aioresponses for clean HTTP mocking """ import pytest import asyncio -import aiohttp from unittest.mock import MagicMock, patch from aioresponses import aioresponses diff --git a/tests/test_commands_charts.py b/tests/test_commands_charts.py index bc3c2e8..0cf0648 100644 --- a/tests/test_commands_charts.py +++ b/tests/test_commands_charts.py @@ -6,13 +6,12 @@ import json import tempfile from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch -from discord import app_commands from commands.utilities.charts import ( ChartCommands, ChartManageGroup, ChartCategoryGroup, - chart_autocomplete, category_autocomplete + chart_autocomplete ) -from services.chart_service import ChartService, Chart, get_chart_service +from services.chart_service import ChartService, Chart from exceptions import BotException diff --git a/tests/test_commands_dice.py b/tests/test_commands_dice.py index b8701a9..839bf34 100644 --- a/tests/test_commands_dice.py +++ b/tests/test_commands_dice.py @@ -9,7 +9,7 @@ import discord from discord.ext import commands from commands.dice.rolls import DiceRollCommands -from utils.dice_utils import DiceRoll, parse_and_roll_multiple_dice, parse_and_roll_single_dice +from utils.dice_utils import DiceRoll, parse_and_roll_multiple_dice class TestDiceRollCommands: diff --git a/tests/test_commands_dropadd.py b/tests/test_commands_dropadd.py index ce5376e..d1f7e37 100644 --- a/tests/test_commands_dropadd.py +++ b/tests/test_commands_dropadd.py @@ -6,14 +6,10 @@ Validates the Discord command interface, autocomplete, and user interactions. import pytest from unittest.mock import AsyncMock, MagicMock, patch -import discord -from discord import app_commands from commands.transactions.dropadd import DropAddCommands from services.transaction_builder import TransactionBuilder from models.team import RosterType -from models.team import Team -from models.player import Player from tests.factories import PlayerFactory, TeamFactory diff --git a/tests/test_commands_profile_images.py b/tests/test_commands_profile_images.py index 4d3b905..9a12f08 100644 --- a/tests/test_commands_profile_images.py +++ b/tests/test_commands_profile_images.py @@ -15,8 +15,6 @@ from commands.profile.images import ( can_edit_player_image, ImageCommands ) -from models.player import Player -from models.team import Team from tests.factories import PlayerFactory, TeamFactory diff --git a/tests/test_commands_soak.py b/tests/test_commands_soak.py index 71dcaef..445e01a 100644 --- a/tests/test_commands_soak.py +++ b/tests/test_commands_soak.py @@ -7,12 +7,11 @@ Tests cover: - Message listener (detection logic) - Info command (response formatting) """ + import pytest import json import re -from datetime import datetime, timedelta, UTC -from pathlib import Path -from unittest.mock import AsyncMock, MagicMock, patch, mock_open +from datetime import datetime, UTC from aioresponses import aioresponses # Import modules to test @@ -21,15 +20,16 @@ from commands.soak.giphy_service import ( get_random_phrase_for_tier, get_tier_description, get_disappointment_gif, - DISAPPOINTMENT_TIERS ) +from services.giphy_service import DISAPPOINTMENT_TIERS from commands.soak.tracker import SoakTracker + # Listener uses simple string matching: ' soak' in msg_text.lower() # Define helper function that mimics the listener's detection logic def soak_detected(text: str) -> bool: """Check if soak mention is detected using listener's logic.""" - return ' soak' in text.lower() + return " soak" in text.lower() class TestGiphyService: @@ -38,78 +38,78 @@ class TestGiphyService: def test_tier_determination_first_ever(self): """Test tier determination for first ever soak.""" tier = get_tier_for_seconds(None) - assert tier == 'first_ever' + assert tier == "first_ever" def test_tier_determination_maximum_disappointment(self): """Test tier 1: 0-30 minutes (maximum disappointment).""" # 15 minutes tier = get_tier_for_seconds(900) - assert tier == 'tier_1' + assert tier == "tier_1" # 30 minutes (boundary) tier = get_tier_for_seconds(1800) - assert tier == 'tier_1' + assert tier == "tier_1" def test_tier_determination_severe_disappointment(self): """Test tier 2: 30min-2hrs (severe disappointment).""" # 1 hour tier = get_tier_for_seconds(3600) - assert tier == 'tier_2' + assert tier == "tier_2" # 2 hours (boundary) tier = get_tier_for_seconds(7200) - assert tier == 'tier_2' + assert tier == "tier_2" def test_tier_determination_strong_disappointment(self): """Test tier 3: 2-6 hours (strong disappointment).""" # 4 hours tier = get_tier_for_seconds(14400) - assert tier == 'tier_3' + assert tier == "tier_3" # 6 hours (boundary) tier = get_tier_for_seconds(21600) - assert tier == 'tier_3' + assert tier == "tier_3" def test_tier_determination_moderate_disappointment(self): """Test tier 4: 6-24 hours (moderate disappointment).""" # 12 hours tier = get_tier_for_seconds(43200) - assert tier == 'tier_4' + assert tier == "tier_4" # 24 hours (boundary) tier = get_tier_for_seconds(86400) - assert tier == 'tier_4' + assert tier == "tier_4" def test_tier_determination_mild_disappointment(self): """Test tier 5: 1-7 days (mild disappointment).""" # 3 days tier = get_tier_for_seconds(259200) - assert tier == 'tier_5' + assert tier == "tier_5" # 7 days (boundary) tier = get_tier_for_seconds(604800) - assert tier == 'tier_5' + assert tier == "tier_5" def test_tier_determination_minimal_disappointment(self): """Test tier 6: 7+ days (minimal disappointment).""" # 10 days tier = get_tier_for_seconds(864000) - assert tier == 'tier_6' + assert tier == "tier_6" # 30 days tier = get_tier_for_seconds(2592000) - assert tier == 'tier_6' + assert tier == "tier_6" def test_random_phrase_selection(self): """Test that random phrase selection returns valid phrases.""" for tier_key in DISAPPOINTMENT_TIERS.keys(): phrase = get_random_phrase_for_tier(tier_key) - assert phrase in DISAPPOINTMENT_TIERS[tier_key]['phrases'] + assert phrase in DISAPPOINTMENT_TIERS[tier_key]["phrases"] def test_tier_description_retrieval(self): """Test tier description retrieval.""" - assert get_tier_description('tier_1') == "Maximum Disappointment" - assert get_tier_description('first_ever') == "The Beginning" + assert get_tier_description("tier_1") == "Maximum Disappointment" + assert get_tier_description("first_ever") == "The Beginning" @pytest.mark.asyncio async def test_get_disappointment_gif_success(self): @@ -122,22 +122,22 @@ class TestGiphyService: # Mock successful Giphy response with correct response structure # The service looks for data.images.original.url, not data.url m.get( - re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'), + re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"), payload={ - 'data': { - 'images': { - 'original': { - 'url': 'https://media.giphy.com/media/test123/giphy.gif' + "data": { + "images": { + "original": { + "url": "https://media.giphy.com/media/test123/giphy.gif" } }, - 'title': 'Disappointed Reaction' + "title": "Disappointed Reaction", } }, - status=200 + status=200, ) - gif_url = await get_disappointment_gif('tier_1') - assert gif_url == 'https://media.giphy.com/media/test123/giphy.gif' + gif_url = await get_disappointment_gif("tier_1") + assert gif_url == "https://media.giphy.com/media/test123/giphy.gif" @pytest.mark.asyncio async def test_get_disappointment_gif_filters_trump(self): @@ -151,37 +151,37 @@ class TestGiphyService: # First response is Trump GIF (should be filtered) # Uses correct response structure with images.original.url m.get( - re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'), + re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"), payload={ - 'data': { - 'images': { - 'original': { - 'url': 'https://media.giphy.com/media/trump123/giphy.gif' + "data": { + "images": { + "original": { + "url": "https://media.giphy.com/media/trump123/giphy.gif" } }, - 'title': 'Donald Trump Disappointed' + "title": "Donald Trump Disappointed", } }, - status=200 + status=200, ) # Second response is acceptable m.get( - re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'), + re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"), payload={ - 'data': { - 'images': { - 'original': { - 'url': 'https://media.giphy.com/media/good456/giphy.gif' + "data": { + "images": { + "original": { + "url": "https://media.giphy.com/media/good456/giphy.gif" } }, - 'title': 'Disappointed Reaction' + "title": "Disappointed Reaction", } }, - status=200 + status=200, ) - gif_url = await get_disappointment_gif('tier_1') - assert gif_url == 'https://media.giphy.com/media/good456/giphy.gif' + gif_url = await get_disappointment_gif("tier_1") + assert gif_url == "https://media.giphy.com/media/good456/giphy.gif" @pytest.mark.asyncio async def test_get_disappointment_gif_api_failure(self): @@ -189,12 +189,12 @@ class TestGiphyService: with aioresponses() as m: # Mock API failure for all requests m.get( - re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'), + re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"), status=500, - repeat=True + repeat=True, ) - gif_url = await get_disappointment_gif('tier_1') + gif_url = await get_disappointment_gif("tier_1") assert gif_url is None @@ -224,13 +224,13 @@ class TestSoakTracker: "username": "testuser", "display_name": "Test User", "channel_id": "456", - "message_id": "789" + "message_id": "789", }, "total_count": 5, - "history": [] + "history": [], } - with open(temp_tracker_file, 'w') as f: + with open(temp_tracker_file, "w") as f: json.dump(existing_data, f) tracker = SoakTracker(temp_tracker_file) @@ -247,15 +247,15 @@ class TestSoakTracker: username="testuser", display_name="Test User", channel_id=789012, - message_id=345678 + message_id=345678, ) assert tracker.get_soak_count() == 1 last_soak = tracker.get_last_soak() assert last_soak is not None - assert last_soak['user_id'] == '123456' - assert last_soak['username'] == 'testuser' + assert last_soak["user_id"] == "123456" + assert last_soak["username"] == "testuser" def test_record_multiple_soaks(self, temp_tracker_file): """Test recording multiple soaks maintains history.""" @@ -268,7 +268,7 @@ class TestSoakTracker: username=f"user{i}", display_name=f"User {i}", channel_id=100, - message_id=200 + i + message_id=200 + i, ) assert tracker.get_soak_count() == 3 @@ -276,8 +276,8 @@ class TestSoakTracker: history = tracker.get_history() assert len(history) == 3 # History should be newest first - assert history[0]['user_id'] == '2' - assert history[2]['user_id'] == '0' + assert history[0]["user_id"] == "2" + assert history[2]["user_id"] == "0" def test_get_time_since_last_soak(self, temp_tracker_file): """Test time calculation since last soak.""" @@ -292,7 +292,7 @@ class TestSoakTracker: username="test", display_name="Test", channel_id=456, - message_id=789 + message_id=789, ) # Time since should be very small (just recorded) @@ -311,7 +311,7 @@ class TestSoakTracker: username=f"user{i}", display_name=f"User {i}", channel_id=100, - message_id=200 + i + message_id=200 + i, ) history = tracker.get_history(limit=9999) @@ -380,5 +380,9 @@ class TestInfoCommand: channel_id = 987654321 message_id = 111222333 - expected_url = f"https://discord.com/channels/{guild_id}/{channel_id}/{message_id}" - assert expected_url == "https://discord.com/channels/123456789/987654321/111222333" + expected_url = ( + f"https://discord.com/channels/{guild_id}/{channel_id}/{message_id}" + ) + assert ( + expected_url == "https://discord.com/channels/123456789/987654321/111222333" + ) diff --git a/tests/test_commands_teams_branding.py b/tests/test_commands_teams_branding.py index acb9eec..abf068c 100644 --- a/tests/test_commands_teams_branding.py +++ b/tests/test_commands_teams_branding.py @@ -14,7 +14,6 @@ from commands.teams.branding import ( BrandingCommands ) from models.team import Team -from tests.factories import TeamFactory class TestHexColorValidation: diff --git a/tests/test_commands_voice.py b/tests/test_commands_voice.py index bb1d708..b860e01 100644 --- a/tests/test_commands_voice.py +++ b/tests/test_commands_voice.py @@ -3,8 +3,6 @@ Tests for voice channel commands Validates voice channel creation, cleanup, and migration message functionality. """ -import asyncio -import json import tempfile from datetime import datetime, timedelta, UTC from pathlib import Path diff --git a/tests/test_config.py b/tests/test_config.py index 5258ca0..a90115a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -8,7 +8,6 @@ import pytest from unittest.mock import patch from config import BotConfig -from exceptions import ConfigurationException class TestBotConfig: diff --git a/tests/test_constants.py b/tests/test_constants.py index e95de44..0026692 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -3,7 +3,6 @@ Tests for application configuration Validates that config values have sensible defaults. """ -import pytest from config import get_config, PITCHER_POSITIONS, POSITION_FIELDERS, ALL_POSITIONS diff --git a/tests/test_dropadd_integration.py b/tests/test_dropadd_integration.py index f81626b..0140e2a 100644 --- a/tests/test_dropadd_integration.py +++ b/tests/test_dropadd_integration.py @@ -6,18 +6,15 @@ Tests complete workflows from command invocation through transaction submission. import pytest from unittest.mock import AsyncMock, MagicMock, patch -from datetime import datetime from commands.transactions.dropadd import DropAddCommands from services.transaction_builder import ( - TransactionBuilder, TransactionMove, get_transaction_builder, clear_transaction_builder, ) from models.team import RosterType -from views.transaction_embed import TransactionEmbedView, SubmitConfirmationModal -from models.team import Team +from views.transaction_embed import SubmitConfirmationModal from models.player import Player from models.roster import TeamRoster from models.transaction import Transaction diff --git a/tests/test_models.py b/tests/test_models.py index 34f734a..bf85351 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -4,7 +4,6 @@ Tests for SBA data models Validates model creation, validation, and business logic. """ import pytest -from datetime import datetime from models import Team, Player, Current, DraftPick, DraftData, DraftList diff --git a/tests/test_models_trade.py b/tests/test_models_trade.py index d9a1798..2c66419 100644 --- a/tests/test_models_trade.py +++ b/tests/test_models_trade.py @@ -4,7 +4,6 @@ Tests for trade-specific models. Tests the Trade, TradeParticipant, and TradeMove models to ensure proper validation and behavior for multi-team trades. """ -import pytest from unittest.mock import MagicMock from models.trade import Trade, TradeParticipant, TradeMove, TradeStatus diff --git a/tests/test_models_transaction.py b/tests/test_models_transaction.py index 224245b..aa44b75 100644 --- a/tests/test_models_transaction.py +++ b/tests/test_models_transaction.py @@ -5,11 +5,8 @@ Validates transaction model creation, validation, and business logic. """ import pytest import copy -from datetime import datetime from models.transaction import Transaction, RosterValidation -from models.player import Player -from models.team import Team class TestTransaction: diff --git a/tests/test_services_base_service.py b/tests/test_services_base_service.py index ca90b6c..4ef6602 100644 --- a/tests/test_services_base_service.py +++ b/tests/test_services_base_service.py @@ -6,7 +6,6 @@ from unittest.mock import AsyncMock from services.base_service import BaseService from models.base import SBABaseModel -from exceptions import APIException class MockModel(SBABaseModel): diff --git a/tests/test_services_custom_commands.py b/tests/test_services_custom_commands.py index 5296002..2b9da87 100644 --- a/tests/test_services_custom_commands.py +++ b/tests/test_services_custom_commands.py @@ -4,23 +4,17 @@ Tests for Custom Commands Service in Discord Bot v2.0 Fixed version with proper mocking following established patterns. """ import pytest -import asyncio from datetime import datetime, timedelta, timezone -from unittest.mock import AsyncMock, MagicMock, patch -from typing import List +from unittest.mock import AsyncMock from services.custom_commands_service import ( CustomCommandsService, CustomCommandNotFoundError, - CustomCommandExistsError, - CustomCommandPermissionError + CustomCommandExistsError ) from models.custom_command import ( CustomCommand, - CustomCommandCreator, - CustomCommandSearchFilters, - CustomCommandSearchResult, - CustomCommandStats + CustomCommandCreator ) diff --git a/tests/test_services_draft_sheet.py b/tests/test_services_draft_sheet.py index 96478fe..bc87b0d 100644 --- a/tests/test_services_draft_sheet.py +++ b/tests/test_services_draft_sheet.py @@ -5,8 +5,7 @@ Tests the Google Sheets integration for draft pick tracking. Uses mocked pygsheets to avoid actual API calls. """ import pytest -from unittest.mock import AsyncMock, MagicMock, patch -from typing import Tuple, List +from unittest.mock import MagicMock, patch from services.draft_sheet_service import DraftSheetService, get_draft_sheet_service diff --git a/tests/test_services_help_commands.py b/tests/test_services_help_commands.py index 849c3d7..34eb84b 100644 --- a/tests/test_services_help_commands.py +++ b/tests/test_services_help_commands.py @@ -4,7 +4,7 @@ Tests for Help Commands Service in Discord Bot v2.0 Comprehensive tests for help commands CRUD operations and business logic. """ import pytest -from datetime import datetime, timezone, timedelta +from datetime import datetime, timezone from unittest.mock import AsyncMock from services.help_commands_service import ( diff --git a/tests/test_services_injury.py b/tests/test_services_injury.py index 52f7b55..94cb1f2 100644 --- a/tests/test_services_injury.py +++ b/tests/test_services_injury.py @@ -12,7 +12,7 @@ rather than trying to mock HTTP responses, since the service uses BaseService which manages its own client instance. """ import pytest -from unittest.mock import AsyncMock, MagicMock +from unittest.mock import AsyncMock from services.injury_service import InjuryService from models.injury import Injury diff --git a/tests/test_services_league_service.py b/tests/test_services_league_service.py index a5dce40..752fa7f 100644 --- a/tests/test_services_league_service.py +++ b/tests/test_services_league_service.py @@ -10,7 +10,6 @@ from typing import Dict, Any, List from services.league_service import LeagueService, league_service from models.current import Current -from exceptions import APIException class TestLeagueService: diff --git a/tests/test_services_trade_builder.py b/tests/test_services_trade_builder.py index cd60564..dc2f238 100644 --- a/tests/test_services_trade_builder.py +++ b/tests/test_services_trade_builder.py @@ -19,7 +19,7 @@ from services.trade_builder import ( _team_to_trade_key, ) from models.trade import TradeStatus -from models.team import RosterType, Team +from models.team import RosterType from tests.factories import PlayerFactory, TeamFactory diff --git a/tests/test_services_transaction.py b/tests/test_services_transaction.py index 6bb8de3..9c87e53 100644 --- a/tests/test_services_transaction.py +++ b/tests/test_services_transaction.py @@ -4,8 +4,7 @@ Tests for TransactionService Validates transaction service functionality, API interaction, and business logic. """ import pytest -from unittest.mock import AsyncMock, MagicMock, patch -from datetime import datetime +from unittest.mock import AsyncMock, patch from services.transaction_service import TransactionService, transaction_service from models.transaction import Transaction, RosterValidation diff --git a/tests/test_services_transaction_builder.py b/tests/test_services_transaction_builder.py index e33acb0..8b3dbcb 100644 --- a/tests/test_services_transaction_builder.py +++ b/tests/test_services_transaction_builder.py @@ -5,7 +5,6 @@ Validates transaction building, roster validation, and move management. """ import pytest from unittest.mock import AsyncMock, MagicMock, patch -from datetime import datetime from services.transaction_builder import ( TransactionBuilder, @@ -19,7 +18,6 @@ from models.team import Team from models.player import Player from models.roster import TeamRoster from models.transaction import Transaction -from tests.factories import PlayerFactory, TeamFactory class TestTransactionBuilder: diff --git a/tests/test_tasks_custom_command_cleanup.py b/tests/test_tasks_custom_command_cleanup.py index ff62b8d..a241995 100644 --- a/tests/test_tasks_custom_command_cleanup.py +++ b/tests/test_tasks_custom_command_cleanup.py @@ -4,10 +4,7 @@ Tests for Custom Command Cleanup Tasks in Discord Bot v2.0 Fixed version that tests cleanup logic without Discord task infrastructure. """ import pytest -import asyncio from datetime import datetime, timedelta, timezone -from unittest.mock import AsyncMock, MagicMock, Mock, patch -from typing import List from models.custom_command import ( CustomCommand, diff --git a/tests/test_tasks_transaction_freeze.py b/tests/test_tasks_transaction_freeze.py index f3fc032..31f4c20 100644 --- a/tests/test_tasks_transaction_freeze.py +++ b/tests/test_tasks_transaction_freeze.py @@ -9,8 +9,7 @@ Validates the automated weekly freeze system for transactions, including: - Transaction processing """ import pytest -from datetime import datetime, timezone, UTC -from unittest.mock import AsyncMock, MagicMock, Mock, patch, call +from unittest.mock import AsyncMock, MagicMock, patch from typing import List from tasks.transaction_freeze import ( diff --git a/tests/test_transactions_integration.py b/tests/test_transactions_integration.py index c6e8dd9..134009b 100644 --- a/tests/test_transactions_integration.py +++ b/tests/test_transactions_integration.py @@ -9,7 +9,6 @@ import asyncio from models.transaction import Transaction, RosterValidation from models.team import Team -from models.roster import TeamRoster from services.transaction_service import transaction_service from commands.transactions.management import TransactionCommands from tests.factories import TeamFactory diff --git a/tests/test_utils_decorators.py b/tests/test_utils_decorators.py index b7f799c..703a426 100644 --- a/tests/test_utils_decorators.py +++ b/tests/test_utils_decorators.py @@ -2,9 +2,7 @@ Tests for the logging decorator utility """ import pytest -import asyncio -from unittest.mock import AsyncMock, Mock, patch -import discord +from unittest.mock import Mock, patch from utils.decorators import logged_command from utils.logging import get_contextual_logger diff --git a/tests/test_utils_helpers.py b/tests/test_utils_helpers.py index f667e14..c017b08 100644 --- a/tests/test_utils_helpers.py +++ b/tests/test_utils_helpers.py @@ -12,7 +12,6 @@ Why these tests matter: - Proper fallback behavior ensures backwards compatibility """ -import pytest from utils.helpers import ( DEFAULT_SALARY_CAP, SALARY_CAP_TOLERANCE, diff --git a/tests/test_utils_logging.py b/tests/test_utils_logging.py index 851bf52..5b1ba9e 100644 --- a/tests/test_utils_logging.py +++ b/tests/test_utils_logging.py @@ -6,7 +6,6 @@ Tests contextual logging, operation tracing, and Discord context management. import pytest import time from unittest.mock import Mock, patch -from typing import Dict, Any from utils.logging import ( get_contextual_logger, diff --git a/tests/test_utils_scorebug_helpers.py b/tests/test_utils_scorebug_helpers.py index 53c2d0d..0a97848 100644 --- a/tests/test_utils_scorebug_helpers.py +++ b/tests/test_utils_scorebug_helpers.py @@ -4,7 +4,6 @@ Tests for scorebug_helpers utility functions. Tests the create_team_progress_bar function to ensure correct win probability visualization for home and away teams. """ -import pytest from utils.scorebug_helpers import create_team_progress_bar diff --git a/tests/test_views_custom_commands.py b/tests/test_views_custom_commands.py index 81c645e..bca630a 100644 --- a/tests/test_views_custom_commands.py +++ b/tests/test_views_custom_commands.py @@ -4,17 +4,14 @@ Tests for Custom Command Views in Discord Bot v2.0 Fixed version with proper async handling and model validation. """ import pytest -import asyncio from datetime import datetime, timedelta, timezone -from unittest.mock import AsyncMock, MagicMock, Mock, patch -from typing import List +from unittest.mock import AsyncMock, Mock import discord from models.custom_command import ( CustomCommand, - CustomCommandCreator, - CustomCommandSearchResult + CustomCommandCreator ) diff --git a/tests/test_views_injury_modals.py b/tests/test_views_injury_modals.py index 41e3638..ccc3f9a 100644 --- a/tests/test_views_injury_modals.py +++ b/tests/test_views_injury_modals.py @@ -5,13 +5,11 @@ Tests week and game validation for BatterInjuryModal and PitcherRestModal, including regular season and playoff round validation. """ import pytest -from unittest.mock import AsyncMock, MagicMock, Mock, patch, PropertyMock -from datetime import datetime, timezone +from unittest.mock import AsyncMock, MagicMock, patch, PropertyMock import discord from views.modals import BatterInjuryModal, PitcherRestModal -from views.embeds import EmbedTemplate from models.player import Player diff --git a/tests/test_views_transaction_embed.py b/tests/test_views_transaction_embed.py index c21e2b4..ad60453 100644 --- a/tests/test_views_transaction_embed.py +++ b/tests/test_views_transaction_embed.py @@ -11,17 +11,14 @@ import discord from views.transaction_embed import ( TransactionEmbedView, RemoveMoveView, - RemoveMoveSelect, SubmitConfirmationModal, create_transaction_embed, ) from services.transaction_builder import ( TransactionBuilder, - TransactionMove, RosterValidationResult, ) -from models.team import Team, RosterType -from models.player import Player +from models.team import Team class TestTransactionEmbedView: diff --git a/utils/autocomplete.py b/utils/autocomplete.py index acce3c8..9b4371c 100644 --- a/utils/autocomplete.py +++ b/utils/autocomplete.py @@ -3,7 +3,7 @@ Autocomplete Utilities Shared autocomplete functions for Discord slash commands. """ -from typing import List, Optional +from typing import List import discord from discord import app_commands diff --git a/utils/helpers.py b/utils/helpers.py index ccdeaba..ec4fd29 100644 --- a/utils/helpers.py +++ b/utils/helpers.py @@ -3,7 +3,6 @@ Helper functions for Discord Bot v2.0 Contains utility functions for salary cap calculations and other common operations. """ -from typing import Union from config import get_config # Get default values from config diff --git a/utils/injury_log.py b/utils/injury_log.py index b671d45..2594c5d 100644 --- a/utils/injury_log.py +++ b/utils/injury_log.py @@ -5,14 +5,13 @@ Provides functions for posting injury information to Discord channels: - #injury-log: Two embeds showing current injuries by team and by return week - #sba-network-news: Individual injury announcements """ -from typing import Optional, Dict, List, Any +from typing import Dict, List from collections import defaultdict import discord from config import get_config from models.player import Player -from models.team import Team from services.injury_service import injury_service from services.team_service import team_service from views.embeds import EmbedTemplate, EmbedColors diff --git a/utils/random_gen.py b/utils/random_gen.py index 699ffea..a9e0af5 100644 --- a/utils/random_gen.py +++ b/utils/random_gen.py @@ -4,7 +4,7 @@ Random content generation utilities for Discord Bot v2.0 Provides fun, random content for bot interactions and responses. """ import random -from typing import List, Optional, Union +from typing import List, Optional from utils.logging import get_contextual_logger logger = get_contextual_logger(__name__) diff --git a/utils/scorebug_helpers.py b/utils/scorebug_helpers.py index 48108d0..325557c 100644 --- a/utils/scorebug_helpers.py +++ b/utils/scorebug_helpers.py @@ -4,7 +4,6 @@ Scorebug Display Helpers Utility functions for formatting and displaying scorebug information. """ import discord -from typing import Optional from views.embeds import EmbedColors diff --git a/utils/transaction_logging.py b/utils/transaction_logging.py index d6eed24..cbb9de7 100644 --- a/utils/transaction_logging.py +++ b/utils/transaction_logging.py @@ -10,7 +10,6 @@ import discord from config import get_config from models.transaction import Transaction from models.team import Team -from models.trade import Trade from services.trade_builder import TradeBuilder from views.embeds import EmbedTemplate, EmbedColors from utils.logging import get_contextual_logger diff --git a/views/base.py b/views/base.py index dab3ef1..7cfac08 100644 --- a/views/base.py +++ b/views/base.py @@ -3,12 +3,10 @@ Base View Classes for Discord Bot v2.0 Provides foundational view components with consistent styling and behavior. """ -import logging -from typing import List, Optional, Any, Callable, Awaitable, Union +from typing import List, Optional, Any, Callable, Awaitable from datetime import datetime, timezone import discord -from discord.ext import commands from utils.logging import get_contextual_logger diff --git a/views/common.py b/views/common.py index f4aee72..58e575e 100644 --- a/views/common.py +++ b/views/common.py @@ -4,17 +4,14 @@ Common Discord View Components for Bot v2.0 Specialized views for frequent use cases including player/team selection, detailed information displays, and interactive menus. """ -from typing import Optional, List, Dict, Any, Callable, Awaitable, Union -import asyncio +from typing import Optional, List, Dict, Any, Callable, Awaitable import discord -from discord.ext import commands from .base import BaseView, PaginationView, SelectMenuView from .embeds import SBAEmbedTemplate, EmbedTemplate, EmbedColors from models.player import Player from models.team import Team -from utils.logging import get_contextual_logger class PlayerSelectionView(SelectMenuView): diff --git a/views/custom_commands.py b/views/custom_commands.py index 924df63..7e3c4ce 100644 --- a/views/custom_commands.py +++ b/views/custom_commands.py @@ -3,15 +3,13 @@ Custom Command Views for Discord Bot v2.0 Interactive views and modals for the modern custom command system. """ -from typing import Optional, List, Callable, Awaitable +from typing import Optional, List import discord -from discord.ext import commands from views.base import BaseView, ConfirmationView, PaginationView from views.embeds import EmbedTemplate, EmbedColors from views.modals import BaseModal from models.custom_command import CustomCommand, CustomCommandSearchResult -from utils.logging import get_contextual_logger from services.custom_commands_service import custom_commands_service from exceptions import BotException diff --git a/views/draft_views.py b/views/draft_views.py index 264deb5..cab021d 100644 --- a/views/draft_views.py +++ b/views/draft_views.py @@ -4,7 +4,6 @@ Draft Views for Discord Bot v2.0 Provides embeds and UI components for draft system. """ from typing import Optional, List -from datetime import datetime import discord @@ -15,7 +14,6 @@ from models.player import Player from models.draft_list import DraftList from views.embeds import EmbedTemplate, EmbedColors from utils.draft_helpers import format_pick_display, get_round_name -from config import get_config async def create_on_the_clock_embed( diff --git a/views/embeds.py b/views/embeds.py index 52e2218..cc825ee 100644 --- a/views/embeds.py +++ b/views/embeds.py @@ -3,7 +3,7 @@ Embed Templates for Discord Bot v2.0 Provides consistent embed styling and templates for common use cases. """ -from typing import Optional, Union, Any, List +from typing import Optional, Union, List from datetime import datetime from dataclasses import dataclass diff --git a/views/help_commands.py b/views/help_commands.py index b836319..7a9cc3a 100644 --- a/views/help_commands.py +++ b/views/help_commands.py @@ -6,12 +6,10 @@ Interactive views and modals for the custom help system. from typing import Optional, List import discord -from views.base import BaseView, ConfirmationView, PaginationView +from views.base import BaseView from views.embeds import EmbedTemplate, EmbedColors from views.modals import BaseModal -from models.help_command import HelpCommand, HelpCommandSearchResult -from utils.logging import get_contextual_logger -from exceptions import BotException +from models.help_command import HelpCommand class HelpCommandCreateModal(BaseModal): diff --git a/views/modals.py b/views/modals.py index f64b815..857c5a8 100644 --- a/views/modals.py +++ b/views/modals.py @@ -7,9 +7,8 @@ from typing import Optional, Callable, Awaitable, Dict, Any, List import re import discord -from discord.ext import commands -from .embeds import EmbedTemplate, EmbedColors +from .embeds import EmbedTemplate from utils.logging import get_contextual_logger @@ -738,7 +737,6 @@ class PitcherRestModal(BaseModal): """Handle pitcher rest input and log injury.""" from services.player_service import player_service from services.injury_service import injury_service - from models.injury import Injury from config import get_config import math diff --git a/views/players.py b/views/players.py index b5bed53..e28debb 100644 --- a/views/players.py +++ b/views/players.py @@ -7,9 +7,7 @@ Interactive Discord UI components for player information display with toggleable from typing import Optional, TYPE_CHECKING import discord -from discord.ext import commands -from utils.logging import get_contextual_logger from views.base import BaseView from views.embeds import EmbedTemplate, EmbedColors from models.team import RosterType diff --git a/views/trade_embed.py b/views/trade_embed.py index cec7182..507299f 100644 --- a/views/trade_embed.py +++ b/views/trade_embed.py @@ -7,7 +7,7 @@ import discord from typing import Optional, List from datetime import datetime, timezone -from services.trade_builder import TradeBuilder, TradeValidationResult +from services.trade_builder import TradeBuilder from models.team import Team, RosterType from views.embeds import EmbedColors, EmbedTemplate diff --git a/views/transaction_embed.py b/views/transaction_embed.py index 69a12fb..6af27c0 100644 --- a/views/transaction_embed.py +++ b/views/transaction_embed.py @@ -5,12 +5,9 @@ Handles the Discord embed and button interfaces for the transaction builder. """ import discord -from typing import Optional, List -from datetime import datetime from services.transaction_builder import ( TransactionBuilder, - RosterValidationResult, clear_transaction_builder, ) from services.league_service import league_service