Spaces:
Sleeping
Sleeping
File size: 754 Bytes
697c967 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from pydantic import BaseModel
from typing import Optional
from datetime import datetime
class TaskBase(BaseModel):
title: str
description: Optional[str] = None
completed: bool = False
class TaskCreate(TaskBase):
"""Schema for creating a new task."""
pass
class TaskRead(TaskBase):
"""Schema for reading task data."""
id: int
user_id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class TaskUpdate(BaseModel):
"""Schema for updating a task."""
title: Optional[str] = None
description: Optional[str] = None
completed: Optional[bool] = None
class TaskComplete(BaseModel):
"""Schema for updating task completion status."""
completed: bool |