fix some of mypy complaints.

This commit is contained in:
fiatjaf
2021-04-10 18:06:41 -03:00
parent fdf4f6c1ae
commit e38b945d5c
4 changed files with 27 additions and 27 deletions

View File

@@ -106,7 +106,7 @@ async def create_bleskomat_lnurl(
return bleskomat_lnurl
async def get_bleskomat_lnurl(secret: str) -> BleskomatLnurl:
async def get_bleskomat_lnurl(secret: str) -> Optional[BleskomatLnurl]:
hash = generate_bleskomat_lnurl_hash(secret)
row = await db.fetchone("SELECT * FROM bleskomat_lnurls WHERE hash = ?", (hash,))
return BleskomatLnurl(**row) if row else None

View File

@@ -91,8 +91,8 @@ class BleskomatLnurl(NamedTuple):
wallet_id=self.wallet,
payment_request=query["pr"],
)
except Exception as exc:
raise LnurlValidationError(f"Failed to pay invoice: {exc.message}")
except Exception:
raise LnurlValidationError("Failed to pay invoice")
if not payment_hash:
raise LnurlValidationError("Failed to pay invoice")

View File

@@ -55,24 +55,25 @@ async def set_ticket_paid(payment_hash: str) -> Tickets:
)
ticket = await get_ticket(payment_hash)
assert ticket, "Newly paid ticket could not be retrieved"
if formdata.webhook:
async with httpx.AsyncClient() as client:
try:
r = await client.post(
formdata.webhook,
json={
"form": ticket.form,
"name": ticket.name,
"email": ticket.email,
"content": ticket.ltext,
},
timeout=40,
)
except AssertionError:
webhook = None
await client.post(
formdata.webhook,
json={
"form": ticket.form,
"name": ticket.name,
"email": ticket.email,
"content": ticket.ltext,
},
timeout=40,
)
return ticket
ticket = await get_ticket(payment_hash)
return
assert ticket, "Newly paid ticket could not be retrieved"
return ticket
async def get_ticket(ticket_id: str) -> Optional[Tickets]:

View File

@@ -4,7 +4,6 @@ from lnbits.helpers import urlsafe_short_hash
from . import db
from .models import Domains, Subdomains
from lnbits.extensions import subdomains
async def create_subdomain(
@@ -37,9 +36,9 @@ async def create_subdomain(
),
)
subdomain = await get_subdomain(payment_hash)
assert subdomain, "Newly created subdomain couldn't be retrieved"
return subdomain
new_subdomain = await get_subdomain(payment_hash)
assert new_subdomain, "Newly created subdomain couldn't be retrieved"
return new_subdomain
async def set_subdomain_paid(payment_hash: str) -> Subdomains:
@@ -70,8 +69,9 @@ async def set_subdomain_paid(payment_hash: str) -> Subdomains:
(amount, row[1]),
)
subdomain = await get_subdomain(payment_hash)
return subdomain
new_subdomain = await get_subdomain(payment_hash)
assert new_subdomain, "Newly paid subdomain couldn't be retrieved"
return new_subdomain
async def get_subdomain(subdomain_id: str) -> Optional[Subdomains]:
@@ -79,7 +79,6 @@ async def get_subdomain(subdomain_id: str) -> Optional[Subdomains]:
"SELECT s.*, d.domain as domain_name FROM subdomain s INNER JOIN domain d ON (s.domain = d.id) WHERE s.id = ?",
(subdomain_id,),
)
print(row)
return Subdomains(**row) if row else None
@@ -143,9 +142,9 @@ async def create_domain(
),
)
domain = await get_domain(domain_id)
assert domain, "Newly created domain couldn't be retrieved"
return domain
new_domain = await get_domain(domain_id)
assert new_domain, "Newly created domain couldn't be retrieved"
return new_domain
async def update_domain(domain_id: str, **kwargs) -> Domains: