From 75a8fc8505379671e11f57756d7805d94228af39 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 27 Mar 2026 02:02:49 -0500 Subject: [PATCH] fix: replace deprecated Pydantic .dict() with .model_dump() (#76) Closes #76 Co-Authored-By: Claude Sonnet 4.6 --- app/routers_v3/awards.py | 2 +- app/routers_v3/battingstats.py | 6 ++++-- app/routers_v3/current.py | 2 +- app/routers_v3/decisions.py | 2 +- app/routers_v3/divisions.py | 2 +- app/routers_v3/draftlist.py | 2 +- app/routers_v3/draftpicks.py | 4 ++-- app/routers_v3/injuries.py | 2 +- app/routers_v3/keepers.py | 2 +- app/routers_v3/managers.py | 2 +- app/routers_v3/pitchingstats.py | 6 ++++-- app/routers_v3/results.py | 2 +- app/routers_v3/sbaplayers.py | 2 +- app/routers_v3/schedules.py | 2 +- app/routers_v3/stratgame.py | 2 +- app/routers_v3/stratplay/crud.py | 4 ++-- app/routers_v3/transactions.py | 2 +- 17 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/routers_v3/awards.py b/app/routers_v3/awards.py index 575ef42..7f1b24c 100644 --- a/app/routers_v3/awards.py +++ b/app/routers_v3/awards.py @@ -171,7 +171,7 @@ async def post_award(award_list: AwardList, token: str = Depends(oauth2_scheme)) status_code=404, detail=f"Team ID {x.team_id} not found" ) - new_awards.append(x.dict()) + new_awards.append(x.model_dump()) with db.atomic(): for batch in chunked(new_awards, 15): diff --git a/app/routers_v3/battingstats.py b/app/routers_v3/battingstats.py index 49d3fa8..e32d441 100644 --- a/app/routers_v3/battingstats.py +++ b/app/routers_v3/battingstats.py @@ -366,7 +366,9 @@ async def patch_batstats( if BattingStat.get_or_none(BattingStat.id == stat_id) is None: raise HTTPException(status_code=404, detail=f"Stat ID {stat_id} not found") - BattingStat.update(**new_stats.dict()).where(BattingStat.id == stat_id).execute() + BattingStat.update(**new_stats.model_dump()).where( + BattingStat.id == stat_id + ).execute() r_stat = model_to_dict(BattingStat.get_by_id(stat_id)) db.close() return r_stat @@ -404,7 +406,7 @@ async def post_batstats(s_list: BatStatList, token: str = Depends(oauth2_scheme) status_code=404, detail=f"Player ID {x.player_id} not found" ) - all_stats.append(BattingStat(**x.dict())) + all_stats.append(BattingStat(**x.model_dump())) with db.atomic(): for batch in chunked(all_stats, 15): diff --git a/app/routers_v3/current.py b/app/routers_v3/current.py index ba4458f..cde9b9a 100644 --- a/app/routers_v3/current.py +++ b/app/routers_v3/current.py @@ -116,7 +116,7 @@ async def post_current(new_current: CurrentModel, token: str = Depends(oauth2_sc logger.warning(f"patch_current - Bad Token: {token}") raise HTTPException(status_code=401, detail="Unauthorized") - this_current = Current(**new_current.dict()) + this_current = Current(**new_current.model_dump()) if this_current.save(): r_curr = model_to_dict(this_current) diff --git a/app/routers_v3/decisions.py b/app/routers_v3/decisions.py index a59b16f..0bcdeb1 100644 --- a/app/routers_v3/decisions.py +++ b/app/routers_v3/decisions.py @@ -222,7 +222,7 @@ async def post_decisions(dec_list: DecisionList, token: str = Depends(oauth2_sch status_code=404, detail=f"Player ID {x.pitcher_id} not found" ) - new_dec.append(x.dict()) + new_dec.append(x.model_dump()) with db.atomic(): for batch in chunked(new_dec, 10): diff --git a/app/routers_v3/divisions.py b/app/routers_v3/divisions.py index 095662a..1f350f4 100644 --- a/app/routers_v3/divisions.py +++ b/app/routers_v3/divisions.py @@ -117,7 +117,7 @@ async def post_division( logger.warning(f"post_division - Bad Token: {token}") raise HTTPException(status_code=401, detail="Unauthorized") - this_division = Division(**new_division.dict()) + this_division = Division(**new_division.model_dump()) if this_division.save() == 1: r_division = model_to_dict(this_division) diff --git a/app/routers_v3/draftlist.py b/app/routers_v3/draftlist.py index 4de0d7c..909497d 100644 --- a/app/routers_v3/draftlist.py +++ b/app/routers_v3/draftlist.py @@ -93,7 +93,7 @@ async def post_draftlist( DraftList.delete().where(DraftList.team == this_team).execute() for x in draft_list.draft_list: - new_list.append(x.dict()) + new_list.append(x.model_dump()) with db.atomic(): for batch in chunked(new_list, 15): diff --git a/app/routers_v3/draftpicks.py b/app/routers_v3/draftpicks.py index 2214aa3..9e754bc 100644 --- a/app/routers_v3/draftpicks.py +++ b/app/routers_v3/draftpicks.py @@ -151,7 +151,7 @@ async def patch_pick( if DraftPick.get_or_none(DraftPick.id == pick_id) is None: raise HTTPException(status_code=404, detail=f"Pick ID {pick_id} not found") - DraftPick.update(**new_pick.dict()).where(DraftPick.id == pick_id).execute() + DraftPick.update(**new_pick.model_dump()).where(DraftPick.id == pick_id).execute() r_pick = model_to_dict(DraftPick.get_by_id(pick_id)) db.close() return r_pick @@ -176,7 +176,7 @@ async def post_picks(p_list: DraftPickList, token: str = Depends(oauth2_scheme)) detail=f"Pick # {pick.overall} already exists for season {pick.season}", ) - new_picks.append(pick.dict()) + new_picks.append(pick.model_dump()) with db.atomic(): for batch in chunked(new_picks, 15): diff --git a/app/routers_v3/injuries.py b/app/routers_v3/injuries.py index 77984eb..3e7129f 100644 --- a/app/routers_v3/injuries.py +++ b/app/routers_v3/injuries.py @@ -109,7 +109,7 @@ async def post_injury(new_injury: InjuryModel, token: str = Depends(oauth2_schem logger.warning(f"post_injury - Bad Token: {token}") raise HTTPException(status_code=401, detail="Unauthorized") - this_injury = Injury(**new_injury.dict()) + this_injury = Injury(**new_injury.model_dump()) if this_injury.save(): r_injury = model_to_dict(this_injury) diff --git a/app/routers_v3/keepers.py b/app/routers_v3/keepers.py index d0fafcf..ab17525 100644 --- a/app/routers_v3/keepers.py +++ b/app/routers_v3/keepers.py @@ -96,7 +96,7 @@ async def post_keepers(k_list: KeeperList, token: str = Depends(oauth2_scheme)): new_keepers = [] for keeper in k_list.keepers: - new_keepers.append(keeper.dict()) + new_keepers.append(keeper.model_dump()) with db.atomic(): for batch in chunked(new_keepers, 14): diff --git a/app/routers_v3/managers.py b/app/routers_v3/managers.py index 4c0de88..294685f 100644 --- a/app/routers_v3/managers.py +++ b/app/routers_v3/managers.py @@ -140,7 +140,7 @@ async def post_manager(new_manager: ManagerModel, token: str = Depends(oauth2_sc logger.warning(f"post_manager - Bad Token: {token}") raise HTTPException(status_code=401, detail="Unauthorized") - this_manager = Manager(**new_manager.dict()) + this_manager = Manager(**new_manager.model_dump()) if this_manager.save(): r_manager = model_to_dict(this_manager) diff --git a/app/routers_v3/pitchingstats.py b/app/routers_v3/pitchingstats.py index d318013..72ee364 100644 --- a/app/routers_v3/pitchingstats.py +++ b/app/routers_v3/pitchingstats.py @@ -317,7 +317,9 @@ async def patch_pitstats( if PitchingStat.get_or_none(PitchingStat.id == stat_id) is None: raise HTTPException(status_code=404, detail=f"Stat ID {stat_id} not found") - PitchingStat.update(**new_stats.dict()).where(PitchingStat.id == stat_id).execute() + PitchingStat.update(**new_stats.model_dump()).where( + PitchingStat.id == stat_id + ).execute() r_stat = model_to_dict(PitchingStat.get_by_id(stat_id)) db.close() return r_stat @@ -344,7 +346,7 @@ async def post_pitstats(s_list: PitStatList, token: str = Depends(oauth2_scheme) status_code=404, detail=f"Player ID {x.player_id} not found" ) - all_stats.append(PitchingStat(**x.dict())) + all_stats.append(PitchingStat(**x.model_dump())) with db.atomic(): for batch in chunked(all_stats, 15): diff --git a/app/routers_v3/results.py b/app/routers_v3/results.py index 7ba46b8..5441424 100644 --- a/app/routers_v3/results.py +++ b/app/routers_v3/results.py @@ -180,7 +180,7 @@ async def post_results(result_list: ResultList, token: str = Depends(oauth2_sche status_code=404, detail=f"Team ID {x.hometeam_id} not found" ) - new_results.append(x.dict()) + new_results.append(x.model_dump()) with db.atomic(): for batch in chunked(new_results, 15): diff --git a/app/routers_v3/sbaplayers.py b/app/routers_v3/sbaplayers.py index 296e21e..6cd30fa 100644 --- a/app/routers_v3/sbaplayers.py +++ b/app/routers_v3/sbaplayers.py @@ -242,7 +242,7 @@ async def post_one_player(player: SbaPlayerModel, token: str = Depends(oauth2_sc detail=f"{player.first_name} {player.last_name} has a key already in the database", ) - new_player = SbaPlayer(**player.dict()) + new_player = SbaPlayer(**player.model_dump()) saved = new_player.save() if saved == 1: return_val = model_to_dict(new_player) diff --git a/app/routers_v3/schedules.py b/app/routers_v3/schedules.py index afcaabf..b8dbdab 100644 --- a/app/routers_v3/schedules.py +++ b/app/routers_v3/schedules.py @@ -165,7 +165,7 @@ async def post_schedules(sched_list: ScheduleList, token: str = Depends(oauth2_s status_code=404, detail=f"Team ID {x.hometeam_id} not found" ) - new_sched.append(x.dict()) + new_sched.append(x.model_dump()) with db.atomic(): for batch in chunked(new_sched, 15): diff --git a/app/routers_v3/stratgame.py b/app/routers_v3/stratgame.py index ba750a8..b05806b 100644 --- a/app/routers_v3/stratgame.py +++ b/app/routers_v3/stratgame.py @@ -248,7 +248,7 @@ async def post_games(game_list: GameList, token: str = Depends(oauth2_scheme)) - status_code=404, detail=f"Team ID {x.home_team_id} not found" ) - new_games.append(x.dict()) + new_games.append(x.model_dump()) with db.atomic(): for batch in chunked(new_games, 16): diff --git a/app/routers_v3/stratplay/crud.py b/app/routers_v3/stratplay/crud.py index ee56f51..9d76da0 100644 --- a/app/routers_v3/stratplay/crud.py +++ b/app/routers_v3/stratplay/crud.py @@ -40,7 +40,7 @@ async def patch_play( db.close() raise HTTPException(status_code=404, detail=f"Play ID {play_id} not found") - StratPlay.update(**new_play.dict()).where(StratPlay.id == play_id).execute() + StratPlay.update(**new_play.model_dump()).where(StratPlay.id == play_id).execute() r_play = model_to_dict(StratPlay.get_by_id(play_id)) db.close() return r_play @@ -88,7 +88,7 @@ async def post_plays(p_list: PlayList, token: str = Depends(oauth2_scheme)): if this_play.pa == 0: this_play.batter_final = None - new_plays.append(this_play.dict()) + new_plays.append(this_play.model_dump()) with db.atomic(): for batch in chunked(new_plays, 20): diff --git a/app/routers_v3/transactions.py b/app/routers_v3/transactions.py index 1880dcc..de9d2a2 100644 --- a/app/routers_v3/transactions.py +++ b/app/routers_v3/transactions.py @@ -172,7 +172,7 @@ async def post_transactions( status_code=404, detail=f"Player ID {x.player_id} not found" ) - all_moves.append(x.dict()) + all_moves.append(x.model_dump()) with db.atomic(): for batch in chunked(all_moves, 15): -- 2.25.1