refactor: extract TIER_NAMES/TIER_COLORS to shared constants module (#146) #155
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#155
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/146-refactor-extract-tier-names-tier-colors-to-shared"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #146
Summary
helpers/refractor_constants.pyas single source of truth for refractor tier constantsTIER_NAMES— shared by all three consumers (was triplicated)STATUS_TIER_COLORS— status view colors (previouslyTIER_COLORSincogs/refractor.py)NOTIF_TIER_COLORS— notification embed colors (previouslyTIER_COLORSinhelpers/refractor_notifs.py)Files Changed
helpers/refractor_constants.py— new module (source of truth)cogs/refractor.py— removed localTIER_NAMES/TIER_COLORS; importsTIER_NAMES, STATUS_TIER_COLORS as TIER_COLORShelpers/refractor_notifs.py— removed localTIER_NAMES/TIER_COLORS; importsTIER_NAMES, NOTIF_TIER_COLORS as TIER_COLORScogs/players.py— removed localREFRACTOR_TIER_NAMES; importsTIER_NAMES as REFRACTOR_TIER_NAMES(call sites unchanged)tests/test_refractor_commands.py— updated divergence test to cover all three consumers includingcogs.playersTest Results
No test command configured. Ruff lint passed on commit hook. Changes verified by reading back modified files.
AI Code Review
Files Reviewed
helpers/refractor_constants.py(added)cogs/refractor.py(modified)helpers/refractor_notifs.py(modified)cogs/players.py(modified)tests/test_refractor_commands.py(modified)Findings
Correctness
No issues found.
cogs/refractor.py,helpers/refractor_notifs.py,cogs/players.py) correctly import fromhelpers.refractor_constants. Values in the new module exactly match the removed local copies.TIER_NAMESfromcogs.refractororhelpers.refractor_notifsstill works — Python re-exports imported names in module namespace. The top-level test importfrom cogs.refractor import TIER_NAMES(line 31) continues to resolve correctly.NOTIF_TIER_COLORSintentionally omits T0 — matches original, correct since tier-up notifications are never sent for T0.STATUS_TIER_COLORS as TIER_COLORSalias incogs/refractor.pymeans all existingTIER_COLORS[...]call sites in that module continue to work without change.Security
No issues found. Pure constant data reorganization with no user input, credentials, or auth logic.
Style & Conventions
cogs/players.py: the newfrom helpers.refractor_constants import TIER_NAMES as REFRACTOR_TIER_NAMESis appended after theutilities.*imports rather than grouped with the otherhelpers.*imports. Minor ordering inconsistency, not a blocker.Suggestions
TestTierNamesDivergenceChecknow compare three references to the same underlying object, sox == x == xwill always be true. The docstring correctly frames them as a "tripwire against accidental re-localization" — that's accurate and they earn their keep. No action needed.Verdict: APPROVED
Clean, well-scoped refactor. A single source of truth is clearly better than three identical copies. The aliasing strategy (
STATUS_TIER_COLORS as TIER_COLORS,NOTIF_TIER_COLORS as TIER_COLORS) keeps all call sites unchanged, and the distinction between the two color dicts is now documented where it matters. No correctness or security issues.Automated review by Claude PR Reviewer (posted as COMMENT — Gitea blocks self-approval)
Approved via pd-pr
Approved via pd-pr