Skip to content

Commit

Permalink
fix issues found by flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak authored and dni committed Feb 21, 2023
1 parent 9530088 commit c4da584
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import json

from fastapi import APIRouter
from starlette.staticfiles import StaticFiles
Expand Down
2 changes: 1 addition & 1 deletion crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 8 additions & 7 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit c4da584

Please sign in to comment.