fix: remove import-time derived globals in retrosheet_data.py (#14) #48
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-card-creation#48
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-card-creation#14"
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 #14
Summary
MIN_PA_VL,MIN_PA_VR,MIN_TBF_VL,MIN_TBF_VR, andCARDSET_IDwere derived fromPLAYER_DESCRIPTIONat module import time, creating a hidden ordering dependency: changingPLAYER_DESCRIPTIONafter import wouldn't update these derived valuespd_cards/commands/retrosheet.py:142-156) explicitly overrides all of them anyway, so the import-time derivation provided no benefit while creating silent couplingPLAYER_DESCRIPTION = "Live"→MIN_PA_VL=20,MIN_PA_VR=40,CARDSET_ID=27)LAST_WEEK_RATIO = 0.0 if PLAYER_DESCRIPTION == "Live" else 0.0ternary (both branches were0.0)Files changed
retrosheet_data.py: lines 56–62 (5 globals), line 70 (dead ternary)Test results
No test suite. Changes verified by reading the modified file and confirming the diff contains only the targeted lines.
AI Code Review
Files Reviewed
retrosheet_data.py(modified — lines 56–62, 70)Findings
Correctness
PLAYER_DESCRIPTION = "Live", all five conditional expressions evaluate to exactly the new plain scalars (MIN_PA_VL=20,MIN_PA_VR=40,MIN_TBF_VL=20,MIN_TBF_VR=40,CARDSET_ID=27). No behaviour change.LAST_WEEK_RATIOternary collapse is correct — both branches were0.0.pd_cards/commands/retrosheet.py:141-156: the CLI explicitly overwrites all six globals after import, validating the PR's claim that the import-time derivation was dead coupling.Security
Style & Conventions
# 1 for PotM,# 27: 2005 Live, 28: 2005 Promos) still document intent for direct-script users — good.Suggestions
LAST_WEEK_RATIOline (70). Both PRs are open against the same unmerged file. If #45 merges first, #48 will apply theLAST_WEEK_RATIOchange redundantly (likely cleanly, but worth being aware of ordering). Consider merging these together or closing #45 in favour of this broader PR.Verdict: COMMENT (LGTM)
Correct, clean cleanup. The CLI verification confirms the premise. The only observation is the overlap with PR #45 on line 70 — no action required, just merge-order awareness.
Automated review by Claude PR Reviewer
AI Code Review
Files Reviewed
retrosheet_data.py(modified)Findings
Correctness
No issues found. The scalar values assigned are correct:
MIN_PA_VL = 20andMIN_PA_VR = 40match what20 if "live" in PLAYER_DESCRIPTION.lower() else 1evaluated to withPLAYER_DESCRIPTION = "Live"(the default).MIN_TBF_VL = 20andMIN_TBF_VR = 40are now explicit instead of aliasingMIN_PA_VL/MIN_PA_VR— values are consistent with the CLAUDE.md documentation which lists "Live Series: 20 PA vs L / 40 PA vs R (batters), 20 TBF vs L / 40 TBF vs R (pitchers)".CARDSET_ID = 27matches the "2005 Live" default.LAST_WEEK_RATIO = 0.0is correct — both branches of the removed ternary evaluated to0.0.pd_cards/commands/retrosheet.py(lines 142–156) does explicitly overwrite all five of these globals before callingrd.main([]), confirming the PR's claim that the import-time derivation served no purpose.Security
No issues found.
Style & Conventions
No issues found. The comments (
# 1 for PotM,# 27: 2005 Live, 28: 2005 Promos) are preserved, keeping the intent clear for operators who configure the file directly. The change is conservative and well-scoped.Suggestions
PLAYER_DESCRIPTIONvariable at line 42 now has no derived dependents in this file. Its only remaining role is being overridden by the CLI and potentially used elsewhere inretrosheet_data.py. No action required, but worth knowing it is now truly just a documentation signal for direct-run users.Verdict: APPROVED
The change is correct, minimal, and achieves its stated goal. The removed expressions were genuinely dead weight — the CLI overwrites all five globals unconditionally on every invocation, and the dead
0.0 if ... else 0.0ternary was pure noise. The PR description accurately describes the diff. No TODOs, FIXMEs, stub code, or security concerns. Safe to merge.Automated review by Claude PR Reviewer
Approved. Removing import-time derived globals eliminates the hidden ordering dependency. Plain scalar defaults are correct given the CLI overrides them explicitly anyway.
e61ef955f2tod43927258a