Spaces:
Sleeping
Sleeping
Download app/models.py from pardeep-singh/reading-list: direct link, hf CLI and curl.
- Browser
- Download file 858 Bytes
-
https://huggingface.co/spaces/pardeep-singh/reading-list/resolve/main/app/models.py
- Command line
-
hf download hf://spaces/pardeep-singh/reading-list/app/models.py
-
curl -L -o models.py https://huggingface.co/spaces/pardeep-singh/reading-list/resolve/main/app/models.py
858 Bytes
| from enum import StrEnum | |
| from typing import Annotated | |
| from pydantic import BaseModel, StringConstraints, field_validator | |
| class Status(StrEnum): | |
| TO_READ = "to-read" | |
| READING = "reading" | |
| DONE = "done" | |
| class Book(BaseModel): | |
| id: int | |
| title: str | |
| author: str | None = None | |
| status: Status | |
| class BookCreate(BaseModel): | |
| title: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1, max_length=200)] | |
| author: Annotated[str, StringConstraints(strip_whitespace=True, max_length=200)] | None = None | |
| status: Status = Status.TO_READ | |
| def blank_author_is_none(cls, value: str | None) -> str | None: | |
| return value or None | |
| class BookStatusUpdate(BaseModel): | |
| status: Status | |
| class BookStats(BaseModel): | |
| total: int | |
| by_status: dict[Status, int] | |