From e11bcc2a08f7afffbd0ef3dace5f3e3713bb7aa9 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Mon, 25 Nov 2024 21:57:19 -0800 Subject: [PATCH] refactor(models): Upgrade to pydantic v2 Resolves #4. --- backend-flask/models/player_team_availability.py | 9 ++++----- backend-flask/spec.py | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/backend-flask/models/player_team_availability.py b/backend-flask/models/player_team_availability.py index 9790190..fda003b 100644 --- a/backend-flask/models/player_team_availability.py +++ b/backend-flask/models/player_team_availability.py @@ -47,13 +47,12 @@ class AvailabilitySchema(spec.BaseModel): i += 1 class PlayerTeamAvailabilityRoleSchema(spec.BaseModel): - from models.player import PlayerSchema - from models.player_team_role import RoleSchema - - player: PlayerSchema + player: "PlayerSchema" playtime: int availability: int - roles: list[RoleSchema] + roles: list["RoleSchema"] +from models.player import PlayerSchema +from models.player_team_role import RoleSchema from models.player_team import PlayerTeam diff --git a/backend-flask/spec.py b/backend-flask/spec.py index 779ce3c..c6c1ce6 100644 --- a/backend-flask/spec.py +++ b/backend-flask/spec.py @@ -20,8 +20,7 @@ spec = SpecTree( nested_naming_strategy=nested_naming_strategy ) -class BaseModel(pydantic.v1.BaseModel): +class BaseModel(pydantic.BaseModel): class Config: alias_generator = to_camel - allow_population_by_field_name = True - smart_union = True + populate_by_name = True