26
loading...
This website collects cookies to deliver better user experience
/docs
, you can access the API documentation.@router.get("", response_model=List[task_schema.TaskResponse])
async def list_tasks(db: AsyncSession = Depends(get_db)):
return await task_crud.get_tasks(db)
response_model=List[task_schema.TaskResponse]
.from pydantic import BaseModel, Field
class TaskResponse(TaskBase):
id: int = Field(..., gt=0, example=1)
done: bool = Field(False, description="done task or not")
class Config:
orm_mode = True
task_schema.TaskResponse
is a class that inherits from Pydantic's BaseModel and sets python type hints in its member variables.orm_mode = True
, the ORM (SQLAlchemy in this case) model object will be converted to Pydantic response object.future=True
in 1.4, I knew where to look in the documentation. I also understood that engine
is a setting passed to the DB, and session
is a setting that holds the engine
setting.install_command
to install the dependent libraries for each test environment using poetry, as shown below.[tox]
skipsdist = true
envlist = flake8, py310
install_command = poetry install -D {packages}
[testenv]
deps = pytest
allowlist_externals = poetry
commands =
poetry install
poetry run pytest tests/
[testenv:flake8]
deps = flake8
commands =
poetry run flake8 src/
db-test:
image: mysql:8.0
environment:
MYSQL_DATABASE: "todo"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
TZ: "Asia/Tokyo"
volumes:
- ./my.conf:/etc/mysql/conf.d/my.cnf
ports:
- 33050:3306
gridGap
and py
(padding-top,bottom), it seems to be possible to write all CSS as React props, and I personally like it because it seems to be intuitive and I don't have to worry about class names like Tailwind CSS.VStack
HStack
for creating horizontal and vertical flex containers useful.<div className="App">
<Container>
<VStack gridGap="8" py="16">
<Heading as="h1" size="4xl">
My Todo List
</Heading>
<InputForm tasks={tasks} setTasks={setTasks} />
<List tasks={tasks} setTasks={setTasks} />
</VStack>
</Container>
</div>