Код: Выделить всё
import datetime
from typing import Optional
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
# ORM class
class Predictions(Base):
__tablename__ = 'predictions'
uid: Mapped[str] = mapped_column(primary_key=True)
event_date: Mapped[datetime.date]
location: Mapped[Optional[str]]
# ... other tables
Код: Выделить всё
# desired TypedDict
class PredictionsDict(TypedDict):
uid: str
event_date: datetime.date
location: Optional[str]
Подробнее здесь: https://stackoverflow.com/questions/790 ... tive-class