diff --git a/build.py b/build.py index 2bc3e50c..155cc3a0 100644 --- a/build.py +++ b/build.py @@ -1,10 +1,8 @@ import glob import os -import subprocess import warnings from os import path -from pathlib import Path -from typing import Any, List, NamedTuple, Optional +from typing import List LNBITS_PATH = path.dirname(path.realpath(__file__)) + "/lnbits" diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 9341a603..7f6ff460 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -702,7 +702,7 @@ async def websocket_connect(websocket: WebSocket, item_id: str): await websocketManager.connect(websocket) try: while True: - data = await websocket.receive_text() + await websocket.receive_text() except WebSocketDisconnect: websocketManager.disconnect(websocket) diff --git a/lnbits/extensions/bleskomat/exchange_rates.py b/lnbits/extensions/bleskomat/exchange_rates.py index c6f1d880..aff9ce65 100644 --- a/lnbits/extensions/bleskomat/exchange_rates.py +++ b/lnbits/extensions/bleskomat/exchange_rates.py @@ -1,6 +1,6 @@ import json import os -from typing import Callable, Dict, Union +from typing import Callable, Union import httpx diff --git a/lnbits/extensions/boltz/tasks.py b/lnbits/extensions/boltz/tasks.py index ba394164..289332a2 100644 --- a/lnbits/extensions/boltz/tasks.py +++ b/lnbits/extensions/boltz/tasks.py @@ -143,10 +143,10 @@ async def check_swap(swap: SubmarineSwap, client): timeout_block_height=swap.timeout_block_height, ) await update_swap_status(swap.id, "refunded") - except BoltzNotFoundException as exc: + except BoltzNotFoundException: logger.debug(f"Boltz - swap: {swap.boltz_id} does not exist.") await update_swap_status(swap.id, "failed") - except MempoolBlockHeightException as exc: + except MempoolBlockHeightException: logger.debug( f"Boltz - tried to refund swap: {swap.id}, but has not reached the timeout." ) @@ -171,7 +171,7 @@ async def check_reverse_swap(reverse_swap: ReverseSubmarineSwap, client): logger.debug(f"Boltz - swap_status: {str(exc)}") await update_swap_status(reverse_swap.id, "failed") # should only happen while development when regtest is reset - except BoltzNotFoundException as exc: + except BoltzNotFoundException: logger.debug(f"Boltz - reverse swap: {reverse_swap.boltz_id} does not exist.") await update_swap_status(reverse_swap.id, "failed") except Exception as exc: diff --git a/lnbits/extensions/cashu/__init__.py b/lnbits/extensions/cashu/__init__.py index 83d8ce27..a519b081 100644 --- a/lnbits/extensions/cashu/__init__.py +++ b/lnbits/extensions/cashu/__init__.py @@ -10,7 +10,6 @@ from lnbits.tasks import catch_everything_and_restart db = Database("ext_cashu") -import sys cashu_static_files = [ { diff --git a/lnbits/extensions/cashu/crud.py b/lnbits/extensions/cashu/crud.py index 23f808c1..30bc7486 100644 --- a/lnbits/extensions/cashu/crud.py +++ b/lnbits/extensions/cashu/crud.py @@ -1,7 +1,4 @@ -import os -import random -import time -from typing import Any, List, Optional, Union +from typing import List, Optional, Union from cashu.core.base import MintKeyset from embit import bip32, bip39, ec, script diff --git a/lnbits/extensions/cashu/models.py b/lnbits/extensions/cashu/models.py index c820d12e..84f28c2b 100644 --- a/lnbits/extensions/cashu/models.py +++ b/lnbits/extensions/cashu/models.py @@ -1,5 +1,5 @@ from sqlite3 import Row -from typing import List, Union +from typing import List from fastapi import Query from pydantic import BaseModel diff --git a/lnbits/extensions/cashu/tasks.py b/lnbits/extensions/cashu/tasks.py index bf49171c..7893bc4f 100644 --- a/lnbits/extensions/cashu/tasks.py +++ b/lnbits/extensions/cashu/tasks.py @@ -1,5 +1,4 @@ import asyncio -import json from cashu.core.migrations import migrate_databases from cashu.mint import migrations @@ -15,7 +14,6 @@ async def startup_cashu_mint(): await migrate_databases(db, migrations) await ledger.load_used_proofs() await ledger.init_keysets(autosave=False) - pass async def wait_for_paid_invoices(): diff --git a/lnbits/extensions/cashu/views_api.py b/lnbits/extensions/cashu/views_api.py index 69e3d26a..1b65a567 100644 --- a/lnbits/extensions/cashu/views_api.py +++ b/lnbits/extensions/cashu/views_api.py @@ -1,6 +1,6 @@ import math from http import HTTPStatus -from typing import Dict, List, Union +from typing import Dict, Union # -------- cashu imports from cashu.core.base import ( diff --git a/lnbits/extensions/deezy/crud.py b/lnbits/extensions/deezy/crud.py index 75549349..1e1e285d 100644 --- a/lnbits/extensions/deezy/crud.py +++ b/lnbits/extensions/deezy/crud.py @@ -1,4 +1,3 @@ -from http import HTTPStatus from typing import List, Optional from . import db diff --git a/lnbits/extensions/deezy/models.py b/lnbits/extensions/deezy/models.py index e69db355..89533693 100644 --- a/lnbits/extensions/deezy/models.py +++ b/lnbits/extensions/deezy/models.py @@ -1,5 +1,3 @@ -from typing import Optional - from pydantic.main import BaseModel from sqlalchemy.engine import base # type: ignore diff --git a/lnbits/extensions/discordbot/models.py b/lnbits/extensions/discordbot/models.py index 8b9cd822..85f527a5 100644 --- a/lnbits/extensions/discordbot/models.py +++ b/lnbits/extensions/discordbot/models.py @@ -1,5 +1,4 @@ from sqlite3 import Row -from typing import Optional from fastapi.param_functions import Query from pydantic import BaseModel diff --git a/lnbits/extensions/gerty/__init__.py b/lnbits/extensions/gerty/__init__.py index 5b24718a..da20adfb 100644 --- a/lnbits/extensions/gerty/__init__.py +++ b/lnbits/extensions/gerty/__init__.py @@ -1,5 +1,3 @@ -import asyncio - from fastapi import APIRouter from fastapi.staticfiles import StaticFiles diff --git a/lnbits/extensions/livestream/tasks.py b/lnbits/extensions/livestream/tasks.py index 9837654e..5cee447c 100644 --- a/lnbits/extensions/livestream/tasks.py +++ b/lnbits/extensions/livestream/tasks.py @@ -1,5 +1,4 @@ import asyncio -import json from loguru import logger diff --git a/lnbits/extensions/lnaddress/cloudflare.py b/lnbits/extensions/lnaddress/cloudflare.py index cf8feaf0..558bca7d 100644 --- a/lnbits/extensions/lnaddress/cloudflare.py +++ b/lnbits/extensions/lnaddress/cloudflare.py @@ -1,5 +1,3 @@ -import json - import httpx from .models import Domains diff --git a/lnbits/extensions/lndhub/views_api.py b/lnbits/extensions/lndhub/views_api.py index 1dff5235..059604f2 100644 --- a/lnbits/extensions/lndhub/views_api.py +++ b/lnbits/extensions/lndhub/views_api.py @@ -228,4 +228,3 @@ async def lndhub_decodeinvoice(invoice: str = Query(None)): @lndhub_ext.get("/ext/checkrouteinvoice") async def lndhub_checkrouteinvoice(): "not implemented on canonical lndhub" - pass diff --git a/lnbits/extensions/lnurldevice/crud.py b/lnbits/extensions/lnurldevice/crud.py index 0ab520da..8e15d4ec 100644 --- a/lnbits/extensions/lnurldevice/crud.py +++ b/lnbits/extensions/lnurldevice/crud.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Union +from typing import List, Optional import shortuuid diff --git a/lnbits/extensions/lnurlp/lnurl.py b/lnbits/extensions/lnurlp/lnurl.py index 99de459c..918a5bd3 100644 --- a/lnbits/extensions/lnurlp/lnurl.py +++ b/lnbits/extensions/lnurlp/lnurl.py @@ -1,5 +1,3 @@ -import hashlib -import math from http import HTTPStatus from fastapi import Request diff --git a/lnbits/extensions/market/crud.py b/lnbits/extensions/market/crud.py index 1d9c28be..53a9afd5 100644 --- a/lnbits/extensions/market/crud.py +++ b/lnbits/extensions/market/crud.py @@ -1,6 +1,4 @@ -from base64 import urlsafe_b64encode from typing import List, Optional, Union -from uuid import uuid4 # from lnbits.db import open_ext_db from lnbits.db import SQLITE diff --git a/lnbits/extensions/market/views.py b/lnbits/extensions/market/views.py index e6c8eeff..2f5e6a89 100644 --- a/lnbits/extensions/market/views.py +++ b/lnbits/extensions/market/views.py @@ -1,6 +1,5 @@ import json from http import HTTPStatus -from typing import List from fastapi import ( BackgroundTasks, diff --git a/lnbits/extensions/market/views_api.py b/lnbits/extensions/market/views_api.py index 31703e8d..effba755 100644 --- a/lnbits/extensions/market/views_api.py +++ b/lnbits/extensions/market/views_api.py @@ -1,7 +1,4 @@ -from base64 import urlsafe_b64encode from http import HTTPStatus -from typing import List, Union -from uuid import uuid4 from fastapi import Body, Depends, Query, Request from loguru import logger diff --git a/lnbits/extensions/nostrnip5/models.py b/lnbits/extensions/nostrnip5/models.py index 5abbf128..7e7bf254 100644 --- a/lnbits/extensions/nostrnip5/models.py +++ b/lnbits/extensions/nostrnip5/models.py @@ -1,6 +1,4 @@ -from enum import Enum from sqlite3 import Row -from typing import List, Optional from fastapi.param_functions import Query from pydantic import BaseModel diff --git a/lnbits/extensions/nostrnip5/views.py b/lnbits/extensions/nostrnip5/views.py index fc897d5d..40f498c1 100644 --- a/lnbits/extensions/nostrnip5/views.py +++ b/lnbits/extensions/nostrnip5/views.py @@ -1,4 +1,3 @@ -from datetime import datetime from http import HTTPStatus from fastapi import Depends, Request diff --git a/lnbits/extensions/offlineshop/views.py b/lnbits/extensions/offlineshop/views.py index 3c2aaf5a..a193b8ef 100644 --- a/lnbits/extensions/offlineshop/views.py +++ b/lnbits/extensions/offlineshop/views.py @@ -1,7 +1,6 @@ import time from datetime import datetime from http import HTTPStatus -from typing import List from fastapi import Depends, HTTPException, Query, Request from starlette.responses import HTMLResponse diff --git a/lnbits/extensions/streamalerts/crud.py b/lnbits/extensions/streamalerts/crud.py index 94113447..f376841a 100644 --- a/lnbits/extensions/streamalerts/crud.py +++ b/lnbits/extensions/streamalerts/crud.py @@ -1,4 +1,3 @@ -from http import HTTPStatus from typing import Optional import httpx diff --git a/lnbits/extensions/subdomains/cloudflare.py b/lnbits/extensions/subdomains/cloudflare.py index 5b951b21..d0d8c4f3 100644 --- a/lnbits/extensions/subdomains/cloudflare.py +++ b/lnbits/extensions/subdomains/cloudflare.py @@ -54,6 +54,6 @@ async def cloudflare_deletesubdomain(domain: Domains, domain_id: str): async with httpx.AsyncClient() as client: try: r = await client.delete(url + "/" + domain_id, headers=header, timeout=40) - cf_response = r.text + r.text except AssertionError: - cf_response = "Error occured" + pass diff --git a/lnbits/extensions/subdomains/tasks.py b/lnbits/extensions/subdomains/tasks.py index ca57950b..8cadcad0 100644 --- a/lnbits/extensions/subdomains/tasks.py +++ b/lnbits/extensions/subdomains/tasks.py @@ -55,4 +55,4 @@ async def on_invoice_paid(payment: Payment) -> None: timeout=40, ) except AssertionError: - webhook = None + pass diff --git a/lnbits/tasks.py b/lnbits/tasks.py index 00d36725..f4d3bf7b 100644 --- a/lnbits/tasks.py +++ b/lnbits/tasks.py @@ -3,7 +3,7 @@ import time import traceback import uuid from http import HTTPStatus -from typing import Callable, Dict, List +from typing import Dict from fastapi.exceptions import HTTPException from loguru import logger diff --git a/lnbits/wallets/cliche.py b/lnbits/wallets/cliche.py index c580dce7..4fcf75ae 100644 --- a/lnbits/wallets/cliche.py +++ b/lnbits/wallets/cliche.py @@ -1,7 +1,7 @@ import asyncio import hashlib import json -from typing import AsyncGenerator, Dict, Optional +from typing import AsyncGenerator, Optional import httpx from loguru import logger diff --git a/lnbits/wallets/cln.py b/lnbits/wallets/cln.py index a77cbf0a..2bd6b214 100644 --- a/lnbits/wallets/cln.py +++ b/lnbits/wallets/cln.py @@ -4,9 +4,7 @@ except ImportError: # pragma: nocover LightningRpc = None import asyncio -import hashlib import random -import time from functools import partial, wraps from typing import AsyncGenerator, Optional diff --git a/lnbits/wallets/eclair.py b/lnbits/wallets/eclair.py index 0eb43ca0..b6e0c1e5 100644 --- a/lnbits/wallets/eclair.py +++ b/lnbits/wallets/eclair.py @@ -98,7 +98,6 @@ class EclairWallet(Wallet): error_message = data["error"] except: error_message = r.text - pass return InvoiceResponse(False, None, None, error_message) @@ -120,7 +119,6 @@ class EclairWallet(Wallet): error_message = data["error"] except: error_message = r.text - pass return PaymentResponse(False, None, None, None, error_message) data = r.json() @@ -147,7 +145,6 @@ class EclairWallet(Wallet): error_message = data["error"] except: error_message = r.text - pass return PaymentResponse(None, checking_id, None, preimage, error_message) statuses = { diff --git a/lnbits/wallets/lnbits.py b/lnbits/wallets/lnbits.py index 27747ce9..e2ea8e43 100644 --- a/lnbits/wallets/lnbits.py +++ b/lnbits/wallets/lnbits.py @@ -1,5 +1,4 @@ import asyncio -import hashlib import json from typing import AsyncGenerator, Dict, Optional diff --git a/lnbits/wallets/lndgrpc.py b/lnbits/wallets/lndgrpc.py index 541c6ab7..25b04ed3 100644 --- a/lnbits/wallets/lndgrpc.py +++ b/lnbits/wallets/lndgrpc.py @@ -9,7 +9,7 @@ except ImportError: # pragma: nocover import asyncio import base64 import hashlib -from os import environ, error +from os import environ from typing import AsyncGenerator, Dict, Optional from loguru import logger @@ -238,7 +238,7 @@ class LndWallet(Wallet): return PaymentStatus(None) try: resp = await self.rpc.LookupInvoice(ln.PaymentHash(r_hash=r_hash)) - except RpcError as exc: + except RpcError: return PaymentStatus(None) if resp.settled: return PaymentStatus(True) diff --git a/lnbits/wallets/lndrest.py b/lnbits/wallets/lndrest.py index d317df3c..d07aae09 100644 --- a/lnbits/wallets/lndrest.py +++ b/lnbits/wallets/lndrest.py @@ -2,7 +2,6 @@ import asyncio import base64 import hashlib import json -from pydoc import describe from typing import AsyncGenerator, Dict, Optional import httpx diff --git a/lnbits/wallets/lntips.py b/lnbits/wallets/lntips.py index 92b33b7a..4551a207 100644 --- a/lnbits/wallets/lntips.py +++ b/lnbits/wallets/lntips.py @@ -77,7 +77,6 @@ class LnTipsWallet(Wallet): error_message = data["message"] except: error_message = r.text - pass return InvoiceResponse(False, None, None, error_message) @@ -103,7 +102,6 @@ class LnTipsWallet(Wallet): error_message = data["error"] except: error_message = r.text - pass return PaymentResponse(False, None, 0, None, error_message) data = r.json()["details"] @@ -165,7 +163,7 @@ class LnTipsWallet(Wallet): except: continue yield inv["payment_hash"] - except Exception as e: + except Exception: pass # do not sleep if the connection was active for more than 10s diff --git a/lnbits/wallets/lntxbot.py b/lnbits/wallets/lntxbot.py index ce315e75..a1e41bd2 100644 --- a/lnbits/wallets/lntxbot.py +++ b/lnbits/wallets/lntxbot.py @@ -75,7 +75,6 @@ class LntxbotWallet(Wallet): error_message = data["message"] except: error_message = r.text - pass return InvoiceResponse(False, None, None, error_message) @@ -97,7 +96,6 @@ class LntxbotWallet(Wallet): error_message = data["message"] except: error_message = r.text - pass return PaymentResponse(False, None, None, None, error_message) data = r.json() diff --git a/lnbits/wallets/spark.py b/lnbits/wallets/spark.py index 25ff1668..6f0f55db 100644 --- a/lnbits/wallets/spark.py +++ b/lnbits/wallets/spark.py @@ -161,7 +161,6 @@ class SparkWallet(Wallet): # this may result in an error if it was paid previously # our database won't allow the same payment_hash to be added twice # this is good - pass fee_msat = -int(r["msatoshi_sent"] - r["msatoshi"]) preimage = r["payment_preimage"] diff --git a/tests/conftest.py b/tests/conftest.py index fc672dd6..7010221d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,4 @@ import asyncio -from typing import Tuple import pytest_asyncio from httpx import AsyncClient