fix: return default 8 on XBT% parse error in running() (#8) #37

Merged
Claude merged 3 commits from ai/paper-dynasty-card-creation#8 into main 2026-03-23 03:52:20 +00:00
Collaborator

Closes #8

What was wrong

In batters/calcs_batter.py, the running() function set xb_pct = 20 on parse failure — a raw integer instead of a fraction. This fed into round(6 + (10 * 20)) = 206, which after clamping to max 17 silently awarded every player with an unparseable XBT% the elite baserunning rating.

Fix

Changed the except block to return 8 (the same default used for empty strings) instead of setting a bad xb_pct value. This ensures parse errors produce a conservative average rating rather than an elite one.

Files changed

  • batters/calcs_batter.py — 1-line fix in running()
Closes #8 ## What was wrong In `batters/calcs_batter.py`, the `running()` function set `xb_pct = 20` on parse failure — a raw integer instead of a fraction. This fed into `round(6 + (10 * 20)) = 206`, which after clamping to `max 17` silently awarded every player with an unparseable XBT% the elite baserunning rating. ## Fix Changed the `except` block to `return 8` (the same default used for empty strings) instead of setting a bad `xb_pct` value. This ensures parse errors produce a conservative average rating rather than an elite one. ## Files changed - `batters/calcs_batter.py` — 1-line fix in `running()`
Claude added 1 commit 2026-03-21 02:32:26 +00:00
Closes #8

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-21 02:45:48 +00:00
Claude reviewed 2026-03-21 02:46:41 +00:00
Claude left a comment
Author
Collaborator

Review: fix: return default 8 on XBT% parse error in running() (#8)

Decision: APPROVED (posted as COMMENT — Gitea prevents self-approval)

Core fix — correct

The bug is real and the fix is right. In the old code, the except block set xb_pct = 20 and fell through to:

return max(min(round(6 + (10 * 20)), 17), 8)
# → max(min(206, 17), 8) → 17  (elite rating, silently)

Changing the except block to return 8 is the correct choice — it matches the established empty-string default (line 580-581) and gives a conservative average rating instead of silently awarding the cap.

Cosmetic changes — harmless

The quote-style normalisation in stealing_line() and the two get_batter_ratings() debug f-strings (outer double-quotes, inner single-quotes; also removes a stray double-space before else "") has no behavioural impact.

Minor observations (not blocking)

  • except Exception is intentionally broad here (log-and-default pattern); pre-existing and not introduced by this PR.
  • A unit test for running() with a malformed input string would prevent regressions, but absence of one isn't a blocker for a one-liner fix like this.

Clean, minimal, and solves the issue exactly as described. Safe to merge.

## Review: fix: return default 8 on XBT% parse error in running() (#8) **Decision: APPROVED** *(posted as COMMENT — Gitea prevents self-approval)* ### Core fix — correct The bug is real and the fix is right. In the old code, the `except` block set `xb_pct = 20` and fell through to: ```python return max(min(round(6 + (10 * 20)), 17), 8) # → max(min(206, 17), 8) → 17 (elite rating, silently) ``` Changing the `except` block to `return 8` is the correct choice — it matches the established empty-string default (line 580-581) and gives a conservative average rating instead of silently awarding the cap. ### Cosmetic changes — harmless The quote-style normalisation in `stealing_line()` and the two `get_batter_ratings()` debug f-strings (outer double-quotes, inner single-quotes; also removes a stray double-space before `else ""`) has no behavioural impact. ### Minor observations (not blocking) - `except Exception` is intentionally broad here (log-and-default pattern); pre-existing and not introduced by this PR. - A unit test for `running()` with a malformed input string would prevent regressions, but absence of one isn't a blocker for a one-liner fix like this. Clean, minimal, and solves the issue exactly as described. Safe to merge.
Claude added 1 commit 2026-03-23 03:50:50 +00:00
cal approved these changes 2026-03-23 03:51:37 +00:00
cal left a comment
Owner

Approved — safe bug fix per PO triage.

Approved — safe bug fix per PO triage.
Claude added 1 commit 2026-03-23 03:52:17 +00:00
Claude merged commit e413fd5cc8 into main 2026-03-23 03:52:20 +00:00
Claude deleted branch ai/paper-dynasty-card-creation#8 2026-03-23 03:52:21 +00:00
Sign in to join this conversation.
No reviewers
cal
No Milestone
No project
No Assignees
2 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/paper-dynasty-card-creation#37
No description provided.