mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-22 14:22:55 +01:00
fix flake8 E712 (comparison-to-bool)
This commit is contained in:
parent
9ef4bd8fb9
commit
f6bd8684d3
16 changed files with 32 additions and 32 deletions
|
@ -214,20 +214,20 @@ async def pay_invoice(
|
|||
)
|
||||
|
||||
logger.debug(f"backend: pay_invoice finished {temp_id}")
|
||||
if payment.checking_id and payment.ok != False:
|
||||
if payment.checking_id and payment.ok is not False:
|
||||
# payment.ok can be True (paid) or None (pending)!
|
||||
logger.debug(f"updating payment {temp_id}")
|
||||
async with db.connect() as conn:
|
||||
await update_payment_details(
|
||||
checking_id=temp_id,
|
||||
pending=payment.ok != True,
|
||||
pending=payment.ok is not True,
|
||||
fee=payment.fee_msat,
|
||||
preimage=payment.preimage,
|
||||
new_checking_id=payment.checking_id,
|
||||
conn=conn,
|
||||
)
|
||||
logger.debug(f"payment successful {payment.checking_id}")
|
||||
elif payment.checking_id is None and payment.ok == False:
|
||||
elif payment.checking_id is None and payment.ok is False:
|
||||
# payment failed
|
||||
logger.warning(f"backend sent payment failure")
|
||||
async with db.connect() as conn:
|
||||
|
|
|
@ -240,7 +240,7 @@ class InstallableExtension(BaseModel):
|
|||
return False
|
||||
with open(config_file, "r") as json_file:
|
||||
config_json = json.load(json_file)
|
||||
return config_json.get("is_installed") == True
|
||||
return config_json.get("is_installed") is True
|
||||
|
||||
def download_archive(self):
|
||||
ext_zip_file = self.zip_path
|
||||
|
|
|
@ -335,7 +335,7 @@ async def melt_coins(
|
|||
status: PaymentStatus = await check_transaction_status(
|
||||
cashu.wallet, invoice_obj.payment_hash
|
||||
)
|
||||
if status.paid == True:
|
||||
if status.paid is True:
|
||||
logger.debug(
|
||||
f"Cashu: Payment successful, invalidating proofs for {invoice_obj.payment_hash}"
|
||||
)
|
||||
|
|
|
@ -188,7 +188,7 @@ async def api_event_register_ticket(ticket_id):
|
|||
status_code=HTTPStatus.FORBIDDEN, detail="Ticket not paid for."
|
||||
)
|
||||
|
||||
if ticket.registered == True:
|
||||
if ticket.registered is True:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Ticket already registered"
|
||||
)
|
||||
|
|
|
@ -123,7 +123,7 @@ async def api_get_jukebox_song(
|
|||
if "items" not in r.json():
|
||||
if r.status_code == 401:
|
||||
token = await api_get_token(juke_id)
|
||||
if token == False:
|
||||
if token is False:
|
||||
return False
|
||||
elif retry:
|
||||
raise HTTPException(
|
||||
|
@ -205,7 +205,7 @@ async def api_get_jukebox_device_check(
|
|||
return json.loads(rDevice.text)
|
||||
elif rDevice.status_code == 401 or rDevice.status_code == 403:
|
||||
token = await api_get_token(juke_id)
|
||||
if token == False:
|
||||
if token is False:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="No devices connected"
|
||||
)
|
||||
|
@ -309,7 +309,7 @@ async def api_get_jukebox_invoice_paid(
|
|||
if rDevice.status_code == 200:
|
||||
isPlaying = rDevice.json()["is_playing"]
|
||||
|
||||
if r.status_code == 204 or isPlaying == False:
|
||||
if r.status_code == 204 or isPlaying is False:
|
||||
async with httpx.AsyncClient() as client:
|
||||
uri = ["spotify:track:" + song_id]
|
||||
assert jukebox.sp_device
|
||||
|
@ -324,7 +324,7 @@ async def api_get_jukebox_invoice_paid(
|
|||
return jukebox_payment
|
||||
elif r.status_code == 401 or r.status_code == 403:
|
||||
token = await api_get_token(juke_id)
|
||||
if token == False:
|
||||
if token is False:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail="Invoice not paid",
|
||||
|
@ -359,7 +359,7 @@ async def api_get_jukebox_invoice_paid(
|
|||
|
||||
elif r.status_code == 401 or r.status_code == 403:
|
||||
token = await api_get_token(juke_id)
|
||||
if token == False:
|
||||
if token is False:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail="Invoice not paid",
|
||||
|
@ -379,7 +379,7 @@ async def api_get_jukebox_invoice_paid(
|
|||
)
|
||||
elif r.status_code == 401 or r.status_code == 403:
|
||||
token = await api_get_token(juke_id)
|
||||
if token == False:
|
||||
if token is False:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.OK, detail="Invoice not paid"
|
||||
)
|
||||
|
@ -433,7 +433,7 @@ async def api_get_jukebox_currently(
|
|||
|
||||
elif r.status_code == 401:
|
||||
token = await api_get_token(juke_id)
|
||||
if token == False:
|
||||
if token is False:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Invoice not paid"
|
||||
)
|
||||
|
|
|
@ -130,7 +130,7 @@ async def set_address_paid(payment_hash: str) -> Addresses:
|
|||
address = await get_address(payment_hash)
|
||||
assert address
|
||||
|
||||
if address.paid == False:
|
||||
if address.paid is False:
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE lnaddress.address
|
||||
|
|
|
@ -270,7 +270,7 @@ async def api_get_nostr_json(
|
|||
if not local_part:
|
||||
continue
|
||||
|
||||
if address.get("active") == False:
|
||||
if address.get("active") is False:
|
||||
continue
|
||||
|
||||
if name and name.lower() != local_part.lower():
|
||||
|
|
|
@ -77,7 +77,7 @@ class Charges(BaseModel):
|
|||
return ChargeConfig(**charge_config)
|
||||
|
||||
def must_call_webhook(self):
|
||||
return self.webhook and self.paid and self.config.webhook_success == False
|
||||
return self.webhook and self.paid and self.config.webhook_success is False
|
||||
|
||||
|
||||
class SatsPayThemes(BaseModel):
|
||||
|
|
|
@ -121,7 +121,7 @@ async def create_email(wallet: str, data: CreateEmail, payment_hash: str = "") -
|
|||
|
||||
async def set_email_paid(payment_hash: str) -> bool:
|
||||
email = await get_email_by_payment_hash(payment_hash)
|
||||
if email and email.paid == False:
|
||||
if email and email.paid is False:
|
||||
await db.execute(
|
||||
f"UPDATE smtp.email SET paid = true WHERE payment_hash = ?", (payment_hash,)
|
||||
)
|
||||
|
|
|
@ -36,7 +36,7 @@ async def set_subdomain_paid(payment_hash: str) -> Subdomains:
|
|||
"SELECT s.*, d.domain as domain_name FROM subdomains.subdomain s INNER JOIN subdomains.domain d ON (s.domain = d.id) WHERE s.id = ?",
|
||||
(payment_hash,),
|
||||
)
|
||||
if row[8] == False:
|
||||
if row[8] is False:
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE subdomains.subdomain
|
||||
|
|
|
@ -128,7 +128,7 @@ async def api_subdomain_make_subdomain(domain_id, data: CreateSubdomain):
|
|||
record_type=data.record_type,
|
||||
ip=data.ip,
|
||||
)
|
||||
if cf_response["success"] == True:
|
||||
if cf_response["success"] is True:
|
||||
await cloudflare_deletesubdomain(
|
||||
domain=domain, domain_id=cf_response["result"]["id"]
|
||||
)
|
||||
|
|
|
@ -34,12 +34,12 @@ class PaymentStatus(NamedTuple):
|
|||
|
||||
@property
|
||||
def failed(self) -> bool:
|
||||
return self.paid == False
|
||||
return self.paid is False
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self.paid == True:
|
||||
if self.paid is True:
|
||||
return "settled"
|
||||
elif self.paid == False:
|
||||
elif self.paid is False:
|
||||
return "failed"
|
||||
elif self.paid == None:
|
||||
return "still pending"
|
||||
|
|
|
@ -216,11 +216,11 @@ class LndWallet(Wallet):
|
|||
error_message = None
|
||||
checking_id = None
|
||||
|
||||
if statuses[resp.status] == True: # SUCCEEDED
|
||||
if statuses[resp.status] is True: # SUCCEEDED
|
||||
fee_msat = -resp.htlcs[-1].route.total_fees_msat
|
||||
preimage = resp.payment_preimage
|
||||
checking_id = resp.payment_hash
|
||||
elif statuses[resp.status] == False:
|
||||
elif statuses[resp.status] is False:
|
||||
error_message = failure_reasons[resp.failure_reason]
|
||||
|
||||
return PaymentResponse(
|
||||
|
|
|
@ -127,7 +127,7 @@ async def test_check_payment_without_key(client, invoice):
|
|||
# check the payment status
|
||||
response = await client.get(f"/api/v1/payments/{invoice['payment_hash']}")
|
||||
assert response.status_code < 300
|
||||
assert response.json()["paid"] == True
|
||||
assert response.json()["paid"] is True
|
||||
assert invoice
|
||||
# not key, that's why no "details"
|
||||
assert "details" not in response.json()
|
||||
|
@ -145,7 +145,7 @@ async def test_check_payment_with_key(client, invoice, inkey_headers_from):
|
|||
f"/api/v1/payments/{invoice['payment_hash']}", headers=inkey_headers_from
|
||||
)
|
||||
assert response.status_code < 300
|
||||
assert response.json()["paid"] == True
|
||||
assert response.json()["paid"] is True
|
||||
assert invoice
|
||||
# with key, that's why with "details"
|
||||
assert "details" in response.json()
|
||||
|
@ -205,7 +205,7 @@ async def test_api_payment_without_key(invoice):
|
|||
# check the payment status
|
||||
response = await api_payment(invoice["payment_hash"])
|
||||
assert type(response) == dict
|
||||
assert response["paid"] == True
|
||||
assert response["paid"] is True
|
||||
# no key, that's why no "details"
|
||||
assert "details" not in response
|
||||
|
||||
|
@ -218,7 +218,7 @@ async def test_api_payment_with_key(invoice, inkey_headers_from):
|
|||
invoice["payment_hash"], inkey_headers_from["X-Api-Key"]
|
||||
)
|
||||
assert type(response) == dict
|
||||
assert response["paid"] == True
|
||||
assert response["paid"] is True
|
||||
assert "details" in response
|
||||
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ async def test_bleskomat_lnurl_api_action_insufficient_balance(client, lnurl):
|
|||
assert wallet.balance_msat == 0
|
||||
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
||||
assert bleskomat_lnurl, not None
|
||||
assert bleskomat_lnurl.has_uses_remaining() == True
|
||||
assert bleskomat_lnurl.has_uses_remaining() is True
|
||||
WALLET.pay_invoice.assert_not_called()
|
||||
|
||||
|
||||
|
@ -140,5 +140,5 @@ async def test_bleskomat_lnurl_api_action_success(client, lnurl):
|
|||
assert wallet.balance_msat == 50000
|
||||
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
||||
assert bleskomat_lnurl, not None
|
||||
assert bleskomat_lnurl.has_uses_remaining() == False
|
||||
assert bleskomat_lnurl.has_uses_remaining() is False
|
||||
WALLET.pay_invoice.assert_called_once_with(pr, 2000)
|
||||
|
|
|
@ -80,7 +80,7 @@ async def test_invoices_api_partial_pay_invoice(
|
|||
f"/invoices/api/v1/invoice/{invoice_id}/payments/{payment_hash}"
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["paid"] == True
|
||||
assert response.json()["paid"] is True
|
||||
|
||||
# check invoice status
|
||||
response = await client.get(f"/invoices/api/v1/invoice/{invoice_id}")
|
||||
|
@ -124,7 +124,7 @@ async def test_invoices_api_partial_pay_invoice(
|
|||
# f"/invoices/api/v1/invoice/{invoice_id}/payments/{payment_hash}"
|
||||
# )
|
||||
# assert response.status_code == 200
|
||||
# assert response.json()["paid"] == True
|
||||
# assert response.json()["paid"] is True
|
||||
|
||||
# # check invoice status
|
||||
# response = await client.get(f"/invoices/api/v1/invoice/{invoice_id}")
|
||||
|
|
Loading…
Add table
Reference in a new issue