remove asserts and add ignore instead for now

This commit is contained in:
dni 2022-07-27 09:39:52 +02:00
parent 347baa076a
commit 7da496dbb4
2 changed files with 15 additions and 20 deletions

View File

@ -55,8 +55,7 @@ async def dispatch_webhook(payment: Payment):
data = payment.dict() data = payment.dict()
try: try:
logger.debug("sending webhook", payment.webhook) logger.debug("sending webhook", payment.webhook)
assert payment.webhook is not None r = await client.post(payment.webhook, json=data, timeout=40) # type: ignore
r = await client.post(payment.webhook, json=data, timeout=40)
await mark_webhook_sent(payment, r.status_code) await mark_webhook_sent(payment, r.status_code)
except (httpx.ConnectError, httpx.RequestError): except (httpx.ConnectError, httpx.RequestError):
await mark_webhook_sent(payment, -1) await mark_webhook_sent(payment, -1)

View File

@ -121,11 +121,9 @@ async def wallet(
if not user_id: if not user_id:
user = await get_user((await create_account()).id) user = await get_user((await create_account()).id)
assert user is not None logger.info(f"Create user {user.id}") # type: ignore
logger.info(f"Create user {user.id}")
else: else:
user = await get_user(user_id) user = await get_user(user_id)
assert user is not None
if not user: if not user:
return template_renderer().TemplateResponse( return template_renderer().TemplateResponse(
"error.html", {"request": request, "err": "User does not exist."} "error.html", {"request": request, "err": "User does not exist."}
@ -137,21 +135,21 @@ async def wallet(
if LNBITS_ADMIN_USERS and user_id in LNBITS_ADMIN_USERS: if LNBITS_ADMIN_USERS and user_id in LNBITS_ADMIN_USERS:
user.admin = True user.admin = True
if not wallet_id: if not wallet_id:
if user.wallets and not wallet_name: if user.wallets and not wallet_name: # type: ignore
wallet = user.wallets[0] wallet = user.wallets[0] # type: ignore
else: else:
wallet = await create_wallet(user_id=user.id, wallet_name=wallet_name) wallet = await create_wallet(user_id=user.id, wallet_name=wallet_name) # type: ignore
logger.info( logger.info(
f"Created new wallet {wallet_name if wallet_name else '(no name)'} for user {user.id}" f"Created new wallet {wallet_name if wallet_name else '(no name)'} for user {user.id}" # type: ignore
) )
return RedirectResponse( return RedirectResponse(
f"/wallet?usr={user.id}&wal={wallet.id}", f"/wallet?usr={user.id}&wal={wallet.id}", # type: ignore
status_code=status.HTTP_307_TEMPORARY_REDIRECT, status_code=status.HTTP_307_TEMPORARY_REDIRECT,
) )
logger.debug(f"Access wallet {wallet_name}{'of user '+ user.id if user else ''}") logger.debug(f"Access wallet {wallet_name}{'of user '+ user.id if user else ''}")
userwallet = user.get_wallet(wallet_id) userwallet = user.get_wallet(wallet_id) # type: ignore
if not userwallet: if not userwallet:
return template_renderer().TemplateResponse( return template_renderer().TemplateResponse(
"error.html", {"request": request, "err": "Wallet not found"} "error.html", {"request": request, "err": "Wallet not found"}
@ -161,10 +159,10 @@ async def wallet(
"core/wallet.html", "core/wallet.html",
{ {
"request": request, "request": request,
"user": user.dict(), "user": user.dict(), # type: ignore
"wallet": userwallet.dict(), "wallet": userwallet.dict(),
"service_fee": service_fee, "service_fee": service_fee,
"web_manifest": f"/manifest/{user.id}.webmanifest", "web_manifest": f"/manifest/{user.id}.webmanifest", # type: ignore
}, },
) )
@ -220,19 +218,18 @@ async def lnurl_full_withdraw_callback(request: Request):
@core_html_routes.get("/deletewallet", response_class=RedirectResponse) @core_html_routes.get("/deletewallet", response_class=RedirectResponse)
async def deletewallet(request: Request, wal: str = Query(...), usr: str = Query(...)): # type: ignore async def deletewallet(request: Request, wal: str = Query(...), usr: str = Query(...)): # type: ignore
user = await get_user(usr) user = await get_user(usr)
assert user is not None user_wallet_ids = [u.id for u in user.wallets] # type: ignore
user_wallet_ids = [u.id for u in user.wallets]
if wal not in user_wallet_ids: if wal not in user_wallet_ids:
raise HTTPException(HTTPStatus.FORBIDDEN, "Not your wallet.") raise HTTPException(HTTPStatus.FORBIDDEN, "Not your wallet.")
else: else:
await delete_wallet(user_id=user.id, wallet_id=wal) await delete_wallet(user_id=user.id, wallet_id=wal) # type: ignore
user_wallet_ids.remove(wal) user_wallet_ids.remove(wal)
logger.debug("Deleted wallet {wal} of user {user.id}") logger.debug("Deleted wallet {wal} of user {user.id}")
if user_wallet_ids: if user_wallet_ids:
return RedirectResponse( return RedirectResponse(
url_for("/wallet", usr=user.id, wal=user_wallet_ids[0]), url_for("/wallet", usr=user.id, wal=user_wallet_ids[0]), # type: ignore
status_code=status.HTTP_307_TEMPORARY_REDIRECT, status_code=status.HTTP_307_TEMPORARY_REDIRECT,
) )
@ -255,8 +252,7 @@ async def lnurlwallet(request: Request):
async with db.connect() as conn: async with db.connect() as conn:
account = await create_account(conn=conn) account = await create_account(conn=conn)
user = await get_user(account.id, conn=conn) user = await get_user(account.id, conn=conn)
assert user is not None wallet = await create_wallet(user_id=user.id, conn=conn) # type: ignore
wallet = await create_wallet(user_id=user.id, conn=conn)
asyncio.create_task( asyncio.create_task(
redeem_lnurl_withdraw( redeem_lnurl_withdraw(
@ -269,7 +265,7 @@ async def lnurlwallet(request: Request):
) )
return RedirectResponse( return RedirectResponse(
f"/wallet?usr={user.id}&wal={wallet.id}", f"/wallet?usr={user.id}&wal={wallet.id}", # type: ignore
status_code=status.HTTP_307_TEMPORARY_REDIRECT, status_code=status.HTTP_307_TEMPORARY_REDIRECT,
) )