Fix team_lineup crash when pitcher lacks pitcherscouting

Card 6605 (Ohtani) placed at position P had pitcherscouting_id=NULL,
causing AttributeError when accessing pitcherscouting.pitchingcard.hand.

Added null check with fallback to batterscouting hand or '?' if neither
scouting record exists.

Also fixed set notation bug on line 240 where {value} created a Python
set instead of a string.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-01-30 13:17:26 -06:00
parent 541c5bbc1e
commit 329658ce8d

View File

@ -237,12 +237,18 @@ class Game(SQLModel, table=True):
for line in all_lineups:
logger.info(f'line in all_lineups: {line}')
if with_links:
name_string = {line.player.name_card_link("batting" if line.position != "P" else "pitching")}
name_string = line.player.name_card_link("batting" if line.position != "P" else "pitching")
else:
name_string = f'{line.player.name_with_desc}'
if line.position == 'P':
this_hand = line.card.pitcherscouting.pitchingcard.hand
if line.card.pitcherscouting:
this_hand = line.card.pitcherscouting.pitchingcard.hand
elif line.card.batterscouting:
# Fallback to batting hand if pitcherscouting is missing
this_hand = line.card.batterscouting.battingcard.hand
else:
this_hand = '?'
else:
this_hand = line.card.batterscouting.battingcard.hand