use proper typing
This commit is contained in:
parent
f3e0bd4907
commit
6d29cc85b0
2 changed files with 5 additions and 4 deletions
|
|
@ -50,15 +50,13 @@ async def create_gerty(wallet_id: str, data: Gerty) -> Gerty:
|
|||
return gerty
|
||||
|
||||
|
||||
async def update_gerty(gerty_id: str, **kwargs) -> Gerty:
|
||||
async def update_gerty(gerty_id: str, **kwargs) -> Optional[Gerty]:
|
||||
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
||||
await db.execute(
|
||||
f"UPDATE gerty.gertys SET {q} WHERE id = ?", (*kwargs.values(), gerty_id)
|
||||
)
|
||||
|
||||
gerty = await get_gerty(gerty_id)
|
||||
assert gerty
|
||||
return gerty
|
||||
return await get_gerty(gerty_id)
|
||||
|
||||
|
||||
async def get_gerty(gerty_id: str) -> Optional[Gerty]:
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ async def api_link_create_or_update(
|
|||
|
||||
data.wallet = wallet.wallet.id
|
||||
gerty = await update_gerty(gerty_id, **data.dict())
|
||||
assert gerty, HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Gerty does not exist"
|
||||
)
|
||||
else:
|
||||
gerty = await create_gerty(wallet_id=wallet.wallet.id, data=data)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue