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}")
|
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)!
|
# payment.ok can be True (paid) or None (pending)!
|
||||||
logger.debug(f"updating payment {temp_id}")
|
logger.debug(f"updating payment {temp_id}")
|
||||||
async with db.connect() as conn:
|
async with db.connect() as conn:
|
||||||
await update_payment_details(
|
await update_payment_details(
|
||||||
checking_id=temp_id,
|
checking_id=temp_id,
|
||||||
pending=payment.ok != True,
|
pending=payment.ok is not True,
|
||||||
fee=payment.fee_msat,
|
fee=payment.fee_msat,
|
||||||
preimage=payment.preimage,
|
preimage=payment.preimage,
|
||||||
new_checking_id=payment.checking_id,
|
new_checking_id=payment.checking_id,
|
||||||
conn=conn,
|
conn=conn,
|
||||||
)
|
)
|
||||||
logger.debug(f"payment successful {payment.checking_id}")
|
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
|
# payment failed
|
||||||
logger.warning(f"backend sent payment failure")
|
logger.warning(f"backend sent payment failure")
|
||||||
async with db.connect() as conn:
|
async with db.connect() as conn:
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ class InstallableExtension(BaseModel):
|
||||||
return False
|
return False
|
||||||
with open(config_file, "r") as json_file:
|
with open(config_file, "r") as json_file:
|
||||||
config_json = json.load(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):
|
def download_archive(self):
|
||||||
ext_zip_file = self.zip_path
|
ext_zip_file = self.zip_path
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ async def melt_coins(
|
||||||
status: PaymentStatus = await check_transaction_status(
|
status: PaymentStatus = await check_transaction_status(
|
||||||
cashu.wallet, invoice_obj.payment_hash
|
cashu.wallet, invoice_obj.payment_hash
|
||||||
)
|
)
|
||||||
if status.paid == True:
|
if status.paid is True:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Cashu: Payment successful, invalidating proofs for {invoice_obj.payment_hash}"
|
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."
|
status_code=HTTPStatus.FORBIDDEN, detail="Ticket not paid for."
|
||||||
)
|
)
|
||||||
|
|
||||||
if ticket.registered == True:
|
if ticket.registered is True:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN, detail="Ticket already registered"
|
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 "items" not in r.json():
|
||||||
if r.status_code == 401:
|
if r.status_code == 401:
|
||||||
token = await api_get_token(juke_id)
|
token = await api_get_token(juke_id)
|
||||||
if token == False:
|
if token is False:
|
||||||
return False
|
return False
|
||||||
elif retry:
|
elif retry:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -205,7 +205,7 @@ async def api_get_jukebox_device_check(
|
||||||
return json.loads(rDevice.text)
|
return json.loads(rDevice.text)
|
||||||
elif rDevice.status_code == 401 or rDevice.status_code == 403:
|
elif rDevice.status_code == 401 or rDevice.status_code == 403:
|
||||||
token = await api_get_token(juke_id)
|
token = await api_get_token(juke_id)
|
||||||
if token == False:
|
if token is False:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN, detail="No devices connected"
|
status_code=HTTPStatus.FORBIDDEN, detail="No devices connected"
|
||||||
)
|
)
|
||||||
|
|
@ -309,7 +309,7 @@ async def api_get_jukebox_invoice_paid(
|
||||||
if rDevice.status_code == 200:
|
if rDevice.status_code == 200:
|
||||||
isPlaying = rDevice.json()["is_playing"]
|
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:
|
async with httpx.AsyncClient() as client:
|
||||||
uri = ["spotify:track:" + song_id]
|
uri = ["spotify:track:" + song_id]
|
||||||
assert jukebox.sp_device
|
assert jukebox.sp_device
|
||||||
|
|
@ -324,7 +324,7 @@ async def api_get_jukebox_invoice_paid(
|
||||||
return jukebox_payment
|
return jukebox_payment
|
||||||
elif r.status_code == 401 or r.status_code == 403:
|
elif r.status_code == 401 or r.status_code == 403:
|
||||||
token = await api_get_token(juke_id)
|
token = await api_get_token(juke_id)
|
||||||
if token == False:
|
if token is False:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN,
|
status_code=HTTPStatus.FORBIDDEN,
|
||||||
detail="Invoice not paid",
|
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:
|
elif r.status_code == 401 or r.status_code == 403:
|
||||||
token = await api_get_token(juke_id)
|
token = await api_get_token(juke_id)
|
||||||
if token == False:
|
if token is False:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN,
|
status_code=HTTPStatus.FORBIDDEN,
|
||||||
detail="Invoice not paid",
|
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:
|
elif r.status_code == 401 or r.status_code == 403:
|
||||||
token = await api_get_token(juke_id)
|
token = await api_get_token(juke_id)
|
||||||
if token == False:
|
if token is False:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.OK, detail="Invoice not paid"
|
status_code=HTTPStatus.OK, detail="Invoice not paid"
|
||||||
)
|
)
|
||||||
|
|
@ -433,7 +433,7 @@ async def api_get_jukebox_currently(
|
||||||
|
|
||||||
elif r.status_code == 401:
|
elif r.status_code == 401:
|
||||||
token = await api_get_token(juke_id)
|
token = await api_get_token(juke_id)
|
||||||
if token == False:
|
if token is False:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN, detail="Invoice not paid"
|
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)
|
address = await get_address(payment_hash)
|
||||||
assert address
|
assert address
|
||||||
|
|
||||||
if address.paid == False:
|
if address.paid is False:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
UPDATE lnaddress.address
|
UPDATE lnaddress.address
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ async def api_get_nostr_json(
|
||||||
if not local_part:
|
if not local_part:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if address.get("active") == False:
|
if address.get("active") is False:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if name and name.lower() != local_part.lower():
|
if name and name.lower() != local_part.lower():
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class Charges(BaseModel):
|
||||||
return ChargeConfig(**charge_config)
|
return ChargeConfig(**charge_config)
|
||||||
|
|
||||||
def must_call_webhook(self):
|
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):
|
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:
|
async def set_email_paid(payment_hash: str) -> bool:
|
||||||
email = await get_email_by_payment_hash(payment_hash)
|
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(
|
await db.execute(
|
||||||
f"UPDATE smtp.email SET paid = true WHERE payment_hash = ?", (payment_hash,)
|
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 = ?",
|
"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,),
|
(payment_hash,),
|
||||||
)
|
)
|
||||||
if row[8] == False:
|
if row[8] is False:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
UPDATE subdomains.subdomain
|
UPDATE subdomains.subdomain
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ async def api_subdomain_make_subdomain(domain_id, data: CreateSubdomain):
|
||||||
record_type=data.record_type,
|
record_type=data.record_type,
|
||||||
ip=data.ip,
|
ip=data.ip,
|
||||||
)
|
)
|
||||||
if cf_response["success"] == True:
|
if cf_response["success"] is True:
|
||||||
await cloudflare_deletesubdomain(
|
await cloudflare_deletesubdomain(
|
||||||
domain=domain, domain_id=cf_response["result"]["id"]
|
domain=domain, domain_id=cf_response["result"]["id"]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,12 @@ class PaymentStatus(NamedTuple):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def failed(self) -> bool:
|
def failed(self) -> bool:
|
||||||
return self.paid == False
|
return self.paid is False
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
if self.paid == True:
|
if self.paid is True:
|
||||||
return "settled"
|
return "settled"
|
||||||
elif self.paid == False:
|
elif self.paid is False:
|
||||||
return "failed"
|
return "failed"
|
||||||
elif self.paid == None:
|
elif self.paid == None:
|
||||||
return "still pending"
|
return "still pending"
|
||||||
|
|
|
||||||
|
|
@ -216,11 +216,11 @@ class LndWallet(Wallet):
|
||||||
error_message = None
|
error_message = None
|
||||||
checking_id = 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
|
fee_msat = -resp.htlcs[-1].route.total_fees_msat
|
||||||
preimage = resp.payment_preimage
|
preimage = resp.payment_preimage
|
||||||
checking_id = resp.payment_hash
|
checking_id = resp.payment_hash
|
||||||
elif statuses[resp.status] == False:
|
elif statuses[resp.status] is False:
|
||||||
error_message = failure_reasons[resp.failure_reason]
|
error_message = failure_reasons[resp.failure_reason]
|
||||||
|
|
||||||
return PaymentResponse(
|
return PaymentResponse(
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ async def test_check_payment_without_key(client, invoice):
|
||||||
# check the payment status
|
# check the payment status
|
||||||
response = await client.get(f"/api/v1/payments/{invoice['payment_hash']}")
|
response = await client.get(f"/api/v1/payments/{invoice['payment_hash']}")
|
||||||
assert response.status_code < 300
|
assert response.status_code < 300
|
||||||
assert response.json()["paid"] == True
|
assert response.json()["paid"] is True
|
||||||
assert invoice
|
assert invoice
|
||||||
# not key, that's why no "details"
|
# not key, that's why no "details"
|
||||||
assert "details" not in response.json()
|
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
|
f"/api/v1/payments/{invoice['payment_hash']}", headers=inkey_headers_from
|
||||||
)
|
)
|
||||||
assert response.status_code < 300
|
assert response.status_code < 300
|
||||||
assert response.json()["paid"] == True
|
assert response.json()["paid"] is True
|
||||||
assert invoice
|
assert invoice
|
||||||
# with key, that's why with "details"
|
# with key, that's why with "details"
|
||||||
assert "details" in response.json()
|
assert "details" in response.json()
|
||||||
|
|
@ -205,7 +205,7 @@ async def test_api_payment_without_key(invoice):
|
||||||
# check the payment status
|
# check the payment status
|
||||||
response = await api_payment(invoice["payment_hash"])
|
response = await api_payment(invoice["payment_hash"])
|
||||||
assert type(response) == dict
|
assert type(response) == dict
|
||||||
assert response["paid"] == True
|
assert response["paid"] is True
|
||||||
# no key, that's why no "details"
|
# no key, that's why no "details"
|
||||||
assert "details" not in response
|
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"]
|
invoice["payment_hash"], inkey_headers_from["X-Api-Key"]
|
||||||
)
|
)
|
||||||
assert type(response) == dict
|
assert type(response) == dict
|
||||||
assert response["paid"] == True
|
assert response["paid"] is True
|
||||||
assert "details" in response
|
assert "details" in response
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ async def test_bleskomat_lnurl_api_action_insufficient_balance(client, lnurl):
|
||||||
assert wallet.balance_msat == 0
|
assert wallet.balance_msat == 0
|
||||||
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
||||||
assert bleskomat_lnurl, not None
|
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()
|
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
|
assert wallet.balance_msat == 50000
|
||||||
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
||||||
assert bleskomat_lnurl, not None
|
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)
|
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}"
|
f"/invoices/api/v1/invoice/{invoice_id}/payments/{payment_hash}"
|
||||||
)
|
)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.json()["paid"] == True
|
assert response.json()["paid"] is True
|
||||||
|
|
||||||
# check invoice status
|
# check invoice status
|
||||||
response = await client.get(f"/invoices/api/v1/invoice/{invoice_id}")
|
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}"
|
# f"/invoices/api/v1/invoice/{invoice_id}/payments/{payment_hash}"
|
||||||
# )
|
# )
|
||||||
# assert response.status_code == 200
|
# assert response.status_code == 200
|
||||||
# assert response.json()["paid"] == True
|
# assert response.json()["paid"] is True
|
||||||
|
|
||||||
# # check invoice status
|
# # check invoice status
|
||||||
# response = await client.get(f"/invoices/api/v1/invoice/{invoice_id}")
|
# response = await client.get(f"/invoices/api/v1/invoice/{invoice_id}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue