feat: adhere to ruff's B rules (#2423)
* feat: adhere to ruff's `B` rules last of the ruff checks. closes #2308 * B904 * B008 * B005 * B025 * cleanup on fake
This commit is contained in:
@@ -93,11 +93,13 @@ class PaymentPendingStatus(PaymentStatus):
|
||||
|
||||
|
||||
class Wallet(ABC):
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
__node_cls__: Optional[type[Node]] = None
|
||||
|
||||
@abstractmethod
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def status(self) -> Coroutine[None, None, StatusResponse]:
|
||||
pass
|
||||
|
||||
@@ -27,6 +27,9 @@ class ClicheWallet(Wallet):
|
||||
|
||||
self.endpoint = self.normalize_endpoint(settings.cliche_endpoint)
|
||||
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
async def status(self) -> StatusResponse:
|
||||
try:
|
||||
ws = create_connection(self.endpoint)
|
||||
|
||||
@@ -31,6 +31,9 @@ async def run_sync(func) -> Any:
|
||||
class CoreLightningWallet(Wallet):
|
||||
__node_cls__ = CoreLightningNode
|
||||
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
rpc = settings.corelightning_rpc or settings.clightning_rpc
|
||||
if not rpc:
|
||||
|
||||
@@ -42,6 +42,9 @@ class FakeWallet(Wallet):
|
||||
32,
|
||||
).hex()
|
||||
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
async def status(self) -> StatusResponse:
|
||||
logger.info(
|
||||
"FakeWallet funding source is for using LNbits as a centralised,"
|
||||
|
||||
@@ -109,6 +109,9 @@ class LndWallet(Wallet):
|
||||
def metadata_callback(self, _, callback):
|
||||
callback([("macaroon", self.macaroon)], None)
|
||||
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
async def status(self) -> StatusResponse:
|
||||
try:
|
||||
resp = await self.rpc.ChannelBalance(ln.ChannelBalanceRequest())
|
||||
|
||||
@@ -77,12 +77,12 @@ class SparkWallet(Wallet):
|
||||
httpx.HTTPError,
|
||||
httpx.TimeoutException,
|
||||
) as exc:
|
||||
raise UnknownError(f"error connecting to spark: {exc}")
|
||||
raise UnknownError(f"error connecting to spark: {exc}") from exc
|
||||
|
||||
try:
|
||||
data = r.json()
|
||||
except Exception:
|
||||
raise UnknownError(r.text)
|
||||
except Exception as exc:
|
||||
raise UnknownError(r.text) from exc
|
||||
|
||||
if r.is_error:
|
||||
if r.status_code == 401:
|
||||
@@ -171,7 +171,7 @@ class SparkWallet(Wallet):
|
||||
raise SparkError(
|
||||
f"listpays({payment_hash}) returned an unexpected response:"
|
||||
f" {listpays}"
|
||||
)
|
||||
) from exc
|
||||
|
||||
if pay["status"] == "failed":
|
||||
return PaymentResponse(False, None, None, None, str(exc))
|
||||
|
||||
@@ -13,6 +13,10 @@ from .base import (
|
||||
|
||||
|
||||
class VoidWallet(Wallet):
|
||||
|
||||
async def cleanup(self):
|
||||
pass
|
||||
|
||||
async def create_invoice(self, *_, **__) -> InvoiceResponse:
|
||||
return InvoiceResponse(
|
||||
ok=False, error_message="VoidWallet cannot create invoices."
|
||||
|
||||
Reference in New Issue
Block a user