migrate to pydantic 2

This commit is contained in:
Jakub Miazek
2023-07-07 20:32:41 +02:00
parent d07fb04553
commit d05f2cdb2e
8 changed files with 17 additions and 23 deletions

View File

@@ -36,7 +36,7 @@ async def update_nonsense(
db_session: AsyncSession = Depends(get_db),
):
nonsense = await Nonsense.find(db_session, name)
await nonsense.update(db_session, **payload.dict())
await nonsense.update(db_session, **payload.model_dump())
return nonsense
@@ -45,6 +45,6 @@ async def merge_nonsense(
payload: NonsenseSchema,
db_session: AsyncSession = Depends(get_db),
):
nonsense = Nonsense(**payload.dict())
nonsense = Nonsense(**payload.model_dump())
await nonsense.save_or_update(db_session)
return nonsense

View File

@@ -1,7 +1,6 @@
from typing import Annotated
from fastapi import APIRouter, Depends, Query
from pydantic import Required
from sqlalchemy.ext.asyncio import AsyncSession
from app.database import get_db
@@ -14,7 +13,7 @@ router = APIRouter(prefix="/v1/shakespeare")
"/",
)
async def find_paragraph(
character: Annotated[str, Query(description="Character name")] = Required,
character: Annotated[str, Query(description="Character name")],
db_session: AsyncSession = Depends(get_db),
):
return await Paragraph.find(db_session=db_session, character=character)

View File

@@ -54,5 +54,5 @@ async def update_stuff(
db_session: AsyncSession = Depends(get_db),
):
stuff = await Stuff.find(db_session, name)
await stuff.update(db_session, **payload.dict())
await stuff.update(db_session, **payload.model_dump())
return stuff