From d15fc97afb5558e2f09b709334fae652ff2e4647 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 23 Mar 2026 12:50:16 -0500 Subject: [PATCH] fix: add pitcher_id null guard in _get_player_pairs Prevents (None, team_id) tuples from being added to pitching_pairs when a StratPlay row has no pitcher (edge case matching the existing batter_id guard). Co-Authored-By: Claude Opus 4.6 (1M context) --- app/services/season_stats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/season_stats.py b/app/services/season_stats.py index 991bfa5..bf0e06e 100644 --- a/app/services/season_stats.py +++ b/app/services/season_stats.py @@ -76,7 +76,8 @@ def _get_player_pairs(game_id: int) -> tuple[set, set]: for batter_id, batter_team_id, pitcher_id, pitcher_team_id in plays: if batter_id is not None: batting_pairs.add((batter_id, batter_team_id)) - pitching_pairs.add((pitcher_id, pitcher_team_id)) + if pitcher_id is not None: + pitching_pairs.add((pitcher_id, pitcher_team_id)) # Include pitchers who have a Decision but no StratPlay rows for this game # (rare edge case, e.g. a pitcher credited with a decision without recording