From c4da584b1644c4bfbedf00793e4dd50cfb5327d0 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 30 Jan 2023 17:56:46 +0000 Subject: [PATCH] fix issues found by flake8 --- __init__.py | 1 - crud.py | 2 +- views.py | 4 +--- views_api.py | 15 ++++++++------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/__init__.py b/__init__.py index 3c52fd2..b73db10 100644 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,4 @@ import asyncio -import json from fastapi import APIRouter from starlette.staticfiles import StaticFiles diff --git a/crud.py b/crud.py index 3254ad4..a26e384 100644 --- a/crud.py +++ b/crud.py @@ -38,7 +38,7 @@ async def set_ticket_paid(payment_hash: str) -> Tickets: row = await db.fetchone( "SELECT * FROM lnticket.ticket WHERE id = ?", (payment_hash,) ) - if row[7] == False: + if row[7] is False: await db.execute( """ UPDATE lnticket.ticket diff --git a/views.py b/views.py index 9bb1d9b..4bc532f 100644 --- a/views.py +++ b/views.py @@ -1,8 +1,6 @@ from http import HTTPStatus -from fastapi import Request -from fastapi.param_functions import Depends -from fastapi.params import Depends +from fastapi import Depends, Request from fastapi.templating import Jinja2Templates from starlette.exceptions import HTTPException from starlette.responses import HTMLResponse diff --git a/views_api.py b/views_api.py index 4462688..12caf8d 100644 --- a/views_api.py +++ b/views_api.py @@ -50,12 +50,12 @@ async def api_form_create( if not form: raise HTTPException( - status_code=HTTPStatus.NOT_FOUND, detail=f"Form does not exist." + status_code=HTTPStatus.NOT_FOUND, detail="Form does not exist." ) if form.wallet != wallet.wallet.id: raise HTTPException( - status_code=HTTPStatus.FORBIDDEN, detail=f"Not your form." + status_code=HTTPStatus.FORBIDDEN, detail="Not your form." ) form = await update_form(form_id, **data.dict()) @@ -70,11 +70,11 @@ async def api_form_delete(form_id, wallet: WalletTypeInfo = Depends(get_key_type if not form: raise HTTPException( - status_code=HTTPStatus.NOT_FOUND, detail=f"Form does not exist." + status_code=HTTPStatus.NOT_FOUND, detail="Form does not exist." ) if form.wallet != wallet.wallet.id: - raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail=f"Not your form.") + raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail="Not your form.") await delete_form(form_id) @@ -102,11 +102,11 @@ async def api_ticket_make_ticket(data: CreateTicketData, form_id): form = await get_form(form_id) if not form: raise HTTPException( - status_code=HTTPStatus.NOT_FOUND, detail=f"LNTicket does not exist." + status_code=HTTPStatus.NOT_FOUND, detail="LNTicket does not exist." ) if data.sats < 1: raise HTTPException( - status_code=HTTPStatus.NOT_FOUND, detail=f"0 invoices not allowed." + status_code=HTTPStatus.NOT_FOUND, detail="0 invoices not allowed." ) nwords = len(re.split(r"\s+", data.ltext)) @@ -136,6 +136,7 @@ async def api_ticket_make_ticket(data: CreateTicketData, form_id): @lnticket_ext.get("/api/v1/tickets/{payment_hash}", status_code=HTTPStatus.OK) async def api_ticket_send_ticket(payment_hash): ticket = await get_ticket(payment_hash) + assert ticket try: status = await api_payment(payment_hash) @@ -154,7 +155,7 @@ async def api_ticket_delete(ticket_id, wallet: WalletTypeInfo = Depends(get_key_ if not ticket: raise HTTPException( - status_code=HTTPStatus.NOT_FOUND, detail=f"LNTicket does not exist." + status_code=HTTPStatus.NOT_FOUND, detail="LNTicket does not exist." ) if ticket.wallet != wallet.wallet.id: