From ff0f12d0d221cf1800666dbf52bb9cf9fc097f0c Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:35:58 +0200 Subject: [PATCH] stricter type checking --- Makefile | 2 +- cashu/core/legacy.py | 6 +++--- cashu/mint/ledger.py | 3 ++- cashu/wallet/wallet.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 6c63bf01..92596a45 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ black-check: poetry run black . --check mypy: - poetry run mypy cashu --ignore-missing + poetry run mypy cashu --ignore-missing --check-untyped-defs format: black ruff diff --git a/cashu/core/legacy.py b/cashu/core/legacy.py index 9fc64b27..60535618 100644 --- a/cashu/core/legacy.py +++ b/cashu/core/legacy.py @@ -18,9 +18,9 @@ def hash_to_point_pre_0_3_3(secret_msg): _hash = hashlib.sha256(msg).hexdigest().encode("utf-8") # type: ignore try: # We construct compressed pub which has x coordinate encoded with even y - _hash = list(_hash[:33]) # take the 33 bytes and get a list of bytes - _hash[0] = 0x02 # set first byte to represent even y coord - _hash = bytes(_hash) + _hash_list = list(_hash[:33]) # take the 33 bytes and get a list of bytes + _hash_list[0] = 0x02 # set first byte to represent even y coord + _hash = bytes(_hash_list) point = PublicKey(_hash, raw=True) except Exception: msg = _hash diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 90946986..22d1e779 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -537,10 +537,11 @@ async def get_melt_fees(self, pr: str) -> int: """ # hack: check if it's internal, if it exists, it will return paid = False, # if id does not exist (not internal), it returns paid = None + amount_msat = 0 if settings.lightning: decoded_invoice = bolt11.decode(pr) assert decoded_invoice.amount_msat, "Amountless invoices not supported." - amount_msat = decoded_invoice.amount_msat + amount_msat = int(decoded_invoice.amount_msat) logger.trace( "get_melt_fees: checking lightning invoice:" f" {decoded_invoice.payment_hash}" diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index a2c21dc4..50a58eb3 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -92,7 +92,7 @@ async def wrapper(self, *args, **kwargs): self.httpx = httpx.AsyncClient( verify=not settings.debug, - proxies=proxies_dict, + proxies=proxies_dict, # type: ignore headers=headers_dict, base_url=self.url, )