fix scrub for mypy

This commit is contained in:
dni ⚡ 2023-01-02 11:25:01 +01:00
parent 765fd892bf
commit 3824a108aa
4 changed files with 8 additions and 13 deletions

View File

@ -25,9 +25,9 @@ async def wait_for_paid_invoices():
await on_invoice_paid(payment)
async def on_invoice_paid(payment: Payment) -> None:
async def on_invoice_paid(payment: Payment):
# (avoid loops)
if payment.extra.get("tag") == "scrubed":
if payment.extra and payment.extra.get("tag") == "scrubed":
# already scrubbed
return
@ -53,7 +53,7 @@ async def on_invoice_paid(payment: Payment) -> None:
timeout=40,
)
if r.is_error:
raise httpx.ConnectError
raise httpx.ConnectError("issue with scrub callback")
except (httpx.ConnectError, httpx.RequestError):
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,

View File

@ -1,5 +1,4 @@
from fastapi import Request
from fastapi.params import Depends
from fastapi import Request, Depends
from fastapi.templating import Jinja2Templates
from starlette.responses import HTMLResponse

View File

@ -1,9 +1,6 @@
from http import HTTPStatus
from fastapi import Request
from fastapi.param_functions import Query
from fastapi.params import Depends
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl # type: ignore
from fastapi import Query, Depends
from starlette.exceptions import HTTPException
from lnbits.core.crud import get_user
@ -23,14 +20,14 @@ from .models import CreateScrubLink
@scrub_ext.get("/api/v1/links", status_code=HTTPStatus.OK)
async def api_links(
req: Request,
wallet: WalletTypeInfo = Depends(get_key_type),
all_wallets: bool = Query(False),
):
wallet_ids = [wallet.wallet.id]
if all_wallets:
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
user = await get_user(wallet.wallet.user)
wallet_ids = user.wallet_ids if user else []
try:
return [link.dict() for link in await get_scrub_links(wallet_ids)]
@ -44,7 +41,7 @@ async def api_links(
@scrub_ext.get("/api/v1/links/{link_id}", status_code=HTTPStatus.OK)
async def api_link_retrieve(
r: Request, link_id, wallet: WalletTypeInfo = Depends(get_key_type)
link_id, wallet: WalletTypeInfo = Depends(get_key_type)
):
link = await get_scrub_link(link_id)

View File

@ -106,7 +106,6 @@ exclude = """(?x)(
| ^lnbits/extensions/offlineshop.
| ^lnbits/extensions/paywall.
| ^lnbits/extensions/satspay.
| ^lnbits/extensions/scrub.
| ^lnbits/extensions/splitpayments.
| ^lnbits/extensions/streamalerts.
| ^lnbits/extensions/tipjar.