import logging import pydantic from pydantic import field_validator from db_calls import db_get from exceptions import log_exception, ApiException logger = logging.getLogger('discord_app') class Current(pydantic.BaseModel): id: int = 0 week: int = 69 freeze: bool = True season: int = 69 bet_week: str = 'sheets' trade_deadline: int = 1 pick_trade_start: int = 69 pick_trade_end: int = 420 playoffs_begin: int = 420 @field_validator("bet_week", mode="before") @classmethod def cast_to_string(cls, v): if isinstance(v, str): return v return str(v) async def get_current() -> Current: data = await db_get('current') # data = {'id': 420, 'transcount': 555} if data is None: log_exception(ApiException('Did not receive current metadata from the API')) # return Current() return Current(**data)