fix: remove duplicate sheets.open_by_key() call in get_full_roster_from_sheets (#30)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-05 03:31:39 -06:00 committed by cal
parent 8b0c82f687
commit 4fcc8ed269

View File

@ -75,7 +75,6 @@ from utilities.dropdown import (
from utilities.embeds import image_embed
from utilities.pages import Pagination
logger = logging.getLogger("discord_app")
WPA_DF = pd.read_csv(f"storage/wpa_data.csv").set_index("index")
TO_BASE = {2: "to second", 3: "to third", 4: "home"}
@ -612,9 +611,11 @@ async def read_lineup(
this_game,
this_team=lineup_team,
lineup_num=lineup_num,
roster_num=this_game.away_roster_id
if this_game.home_team.is_ai
else this_game.home_roster_id,
roster_num=(
this_game.away_roster_id
if this_game.home_team.is_ai
else this_game.home_roster_id
),
)
await interaction.edit_original_response(
@ -759,7 +760,11 @@ def complete_play(session: Session, this_play: Play):
opponent_play = get_last_team_play(
session, this_play.game, this_play.pitcher.team
)
nbo = opponent_play.batting_order + 1 if opponent_play.pa == 1 else opponent_play.batting_order
nbo = (
opponent_play.batting_order + 1
if opponent_play.pa == 1
else opponent_play.batting_order
)
except PlayNotFoundException as e:
logger.info(
f"logic_gameplay - complete_play - No last play found for {this_play.pitcher.team.sname}, setting upcoming batting order to 1"
@ -1106,7 +1111,8 @@ async def get_lineups_from_sheets(
position = row[0].upper()
if position != "DH":
player_positions = [
getattr(this_card.player, f"pos_{i}") for i in range(1, 9)
getattr(this_card.player, f"pos_{i}")
for i in range(1, 9)
if getattr(this_card.player, f"pos_{i}") is not None
]
if position not in player_positions:
@ -1156,8 +1162,6 @@ async def get_full_roster_from_sheets(
"""
logger.debug(f"get_full_roster_from_sheets - sheets: {sheets}")
this_sheet = sheets.open_by_key(this_team.gsheet)
this_sheet = sheets.open_by_key(this_team.gsheet)
logger.debug(f"this_sheet: {this_sheet}")
@ -1216,7 +1220,10 @@ async def get_full_roster_from_sheets(
async def checks_log_interaction(
session: Session, interaction: discord.Interaction, command_name: str, lock_play: bool = True
session: Session,
interaction: discord.Interaction,
command_name: str,
lock_play: bool = True,
) -> tuple[Game, Team, Play]:
"""
Validates interaction permissions and optionally locks the current play for processing.
@ -3862,7 +3869,14 @@ async def xchecks(
this_play.run,
this_play.triple,
this_play.batter_final,
) = 1, 1, 1, 1, 1, 4
) = (
1,
1,
1,
1,
1,
4,
)
this_play = advance_runners(session, this_play, num_bases=4, earned_bases=3)
session.add(this_play)