Merge pull request #1270 from lnbits/fix/mypy/scrub

fix scrub for mypy
This commit is contained in:
calle
2023-01-03 12:38:37 +01:00
committed by GitHub
4 changed files with 8 additions and 15 deletions
+3 -3
View File
@@ -25,9 +25,9 @@ async def wait_for_paid_invoices():
await on_invoice_paid(payment) await on_invoice_paid(payment)
async def on_invoice_paid(payment: Payment) -> None: async def on_invoice_paid(payment: Payment):
# (avoid loops) # (avoid loops)
if payment.extra.get("tag") == "scrubed": if payment.extra and payment.extra.get("tag") == "scrubed":
# already scrubbed # already scrubbed
return return
@@ -53,7 +53,7 @@ async def on_invoice_paid(payment: Payment) -> None:
timeout=40, timeout=40,
) )
if r.is_error: if r.is_error:
raise httpx.ConnectError raise httpx.ConnectError("issue with scrub callback")
except (httpx.ConnectError, httpx.RequestError): except (httpx.ConnectError, httpx.RequestError):
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST, status_code=HTTPStatus.BAD_REQUEST,
+1 -2
View File
@@ -1,5 +1,4 @@
from fastapi import Request from fastapi import Depends, Request
from fastapi.params import Depends
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from starlette.responses import HTMLResponse from starlette.responses import HTMLResponse
+4 -9
View File
@@ -1,9 +1,6 @@
from http import HTTPStatus from http import HTTPStatus
from fastapi import Request from fastapi import Depends, Query
from fastapi.param_functions import Query
from fastapi.params import Depends
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl # type: ignore
from starlette.exceptions import HTTPException from starlette.exceptions import HTTPException
from lnbits.core.crud import get_user 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) @scrub_ext.get("/api/v1/links", status_code=HTTPStatus.OK)
async def api_links( async def api_links(
req: Request,
wallet: WalletTypeInfo = Depends(get_key_type), wallet: WalletTypeInfo = Depends(get_key_type),
all_wallets: bool = Query(False), all_wallets: bool = Query(False),
): ):
wallet_ids = [wallet.wallet.id] wallet_ids = [wallet.wallet.id]
if all_wallets: 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: try:
return [link.dict() for link in await get_scrub_links(wallet_ids)] return [link.dict() for link in await get_scrub_links(wallet_ids)]
@@ -43,9 +40,7 @@ async def api_links(
@scrub_ext.get("/api/v1/links/{link_id}", status_code=HTTPStatus.OK) @scrub_ext.get("/api/v1/links/{link_id}", status_code=HTTPStatus.OK)
async def api_link_retrieve( async def api_link_retrieve(link_id, wallet: WalletTypeInfo = Depends(get_key_type)):
r: Request, link_id, wallet: WalletTypeInfo = Depends(get_key_type)
):
link = await get_scrub_link(link_id) link = await get_scrub_link(link_id)
if not link: if not link:
-1
View File
@@ -104,7 +104,6 @@ exclude = """(?x)(
| ^lnbits/extensions/offlineshop. | ^lnbits/extensions/offlineshop.
| ^lnbits/extensions/paywall. | ^lnbits/extensions/paywall.
| ^lnbits/extensions/satspay. | ^lnbits/extensions/satspay.
| ^lnbits/extensions/scrub.
| ^lnbits/extensions/splitpayments. | ^lnbits/extensions/splitpayments.
| ^lnbits/extensions/streamalerts. | ^lnbits/extensions/streamalerts.
| ^lnbits/extensions/tpos. | ^lnbits/extensions/tpos.