Download src/schemas/task.py from BilalCode/TaskFlow: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/spaces/BilalCode/TaskFlow/resolve/main/src/schemas/task.py
- Command line
-
hf download hf://spaces/BilalCode/TaskFlow/src/schemas/task.py
-
curl -L -o task.py https://huggingface.co/spaces/BilalCode/TaskFlow/resolve/main/src/schemas/task.py
2.21 kB
| from pydantic import BaseModel, Field | |
| from typing import Optional | |
| from datetime import datetime | |
| class TaskCreate(BaseModel): | |
| """Schema for creating a new task.""" | |
| title: str = Field(..., min_length=1, max_length=200, description="Task title (required)") | |
| description: Optional[str] = Field(None, max_length=2000, description="Optional detailed description") | |
| class Config: | |
| json_schema_extra = { | |
| "example": { | |
| "title": "Buy groceries", | |
| "description": "Milk, eggs, bread, and vegetables" | |
| } | |
| } | |
| class TaskUpdate(BaseModel): | |
| """Schema for updating an existing task.""" | |
| title: Optional[str] = Field(None, min_length=1, max_length=200, description="Updated task title") | |
| description: Optional[str] = Field(None, max_length=2000, description="Updated description") | |
| completed: Optional[bool] = Field(None, description="Updated completion status") | |
| class Config: | |
| json_schema_extra = { | |
| "example": { | |
| "title": "Buy groceries and cook dinner", | |
| "description": "Updated shopping list", | |
| "completed": True | |
| } | |
| } | |
| class TaskResponse(BaseModel): | |
| """Schema for task response.""" | |
| id: int = Field(..., description="Unique task identifier") | |
| title: str = Field(..., description="Task title") | |
| description: Optional[str] = Field(None, description="Task description") | |
| completed: bool = Field(..., description="Whether task is marked as complete") | |
| user_id: int = Field(..., description="ID of user who owns this task") | |
| created_at: datetime = Field(..., description="Timestamp when task was created") | |
| updated_at: datetime = Field(..., description="Timestamp when task was last modified") | |
| class Config: | |
| from_attributes = True | |
| json_schema_extra = { | |
| "example": { | |
| "id": 1, | |
| "title": "Buy groceries", | |
| "description": "Milk, eggs, bread", | |
| "completed": False, | |
| "user_id": 42, | |
| "created_at": "2026-02-02T10:30:00Z", | |
| "updated_at": "2026-02-02T10:30:00Z" | |
| } | |
| } | |