refactor: move 42 unnecessary lazy imports to top-level #58

Merged
cal merged 2 commits from refactor/remove-unnecessary-lazy-imports into next-release 2026-03-02 20:48:27 +00:00
Owner

Summary

  • Codebase audit identified ~50 lazy imports across 20+ files
  • Moved 42 unnecessary ones to top-level imports — stdlib modules (asyncio, datetime, re, math), services, models, config, and utilities that had no circular import risk
  • Updated 2 test files (test_services_draft.py, test_views_injury_modals.py) to patch at correct module-level targets
  • Remaining 8 justified lazy imports tracked in #57 as DI refactoring candidates

Files modified (24)

Commands: injuries/management.py, draft/admin.py, draft/picks.py, draft/status.py, players/info.py, profile/images.py, soak/info.py
Services: draft_service.py, roster_service.py, schedule_service.py, sheets_service.py, standings_service.py, stats_service.py
Utils: autocomplete.py, discord_helpers.py, draft_helpers.py
Views: draft_views.py, help_commands.py, modals.py, trade_embed.py
Tasks: draft_monitor.py
Other: bot.py, tests/test_services_draft.py, tests/test_views_injury_modals.py

Test plan

  • Full test suite passes: 944 passed, 3 skipped, 0 failures
  • Verify bot starts cleanly with no import errors
  • Spot-check commands that previously relied on lazy imports (draft, injuries, trades)

🤖 Generated with Claude Code

## Summary - Codebase audit identified ~50 lazy imports across 20+ files - Moved 42 unnecessary ones to top-level imports — stdlib modules (`asyncio`, `datetime`, `re`, `math`), services, models, config, and utilities that had no circular import risk - Updated 2 test files (`test_services_draft.py`, `test_views_injury_modals.py`) to patch at correct module-level targets - Remaining 8 justified lazy imports tracked in #57 as DI refactoring candidates ### Files modified (24) **Commands:** `injuries/management.py`, `draft/admin.py`, `draft/picks.py`, `draft/status.py`, `players/info.py`, `profile/images.py`, `soak/info.py` **Services:** `draft_service.py`, `roster_service.py`, `schedule_service.py`, `sheets_service.py`, `standings_service.py`, `stats_service.py` **Utils:** `autocomplete.py`, `discord_helpers.py`, `draft_helpers.py` **Views:** `draft_views.py`, `help_commands.py`, `modals.py`, `trade_embed.py` **Tasks:** `draft_monitor.py` **Other:** `bot.py`, `tests/test_services_draft.py`, `tests/test_views_injury_modals.py` ## Test plan - [x] Full test suite passes: 944 passed, 3 skipped, 0 failures - [ ] Verify bot starts cleanly with no import errors - [ ] Spot-check commands that previously relied on lazy imports (draft, injuries, trades) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cal added 1 commit 2026-03-02 19:35:40 +00:00
Codebase audit identified ~50 lazy imports. Moved 42 unnecessary ones to
top-level imports — only keeping those justified by circular imports,
init-order dependencies, or optional dependency guards. Updated test mock
patch targets where needed. See #57 for remaining DI candidates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cal added 1 commit 2026-03-02 19:42:25 +00:00
Branch from next-release for normal work, main only for hotfixes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cal merged commit 6e4191f677 into next-release 2026-03-02 20:48:27 +00:00
cal deleted branch refactor/remove-unnecessary-lazy-imports 2026-03-02 20:48:27 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-v2#58
No description provided.