diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..9fc73459 --- /dev/null +++ b/.flake8 @@ -0,0 +1,16 @@ +[flake8] +max-line-length = 150 +exclude = lnbits/wallets/lnd_grpc_files/, lnbits/extensions/ +ignore = + # E203 whitespace before ':' black does not like it + E203 + # E402: module level import not at top of file + E402, + # W503: line break before binary operator + W503, + # F821: undefined name - should be addressed in future PR + F821, + # E722 do not use bare 'except' - should be addressed in future PR + E722, + # flake8-requirements import checks + I diff --git a/lnbits/app.py b/lnbits/app.py index 03dff297..f8bfd448 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -428,7 +428,10 @@ class Formatter: self.padding = 0 self.minimal_fmt: str = "{time:YYYY-MM-DD HH:mm:ss.SS} | {level} | {message}\n" if settings.debug: - self.fmt: str = "{time:YYYY-MM-DD HH:mm:ss.SS} | {level: <4} | {name}:{function}:{line} | {message}\n" + self.fmt: str = ( + "{time:YYYY-MM-DD HH:mm:ss.SS} | {level: <4} | " + "{name}:{function}:{line} | {message}\n" + ) else: self.fmt: str = self.minimal_fmt diff --git a/lnbits/bolt11.py b/lnbits/bolt11.py index 84bf61e7..c2e750f1 100644 --- a/lnbits/bolt11.py +++ b/lnbits/bolt11.py @@ -316,23 +316,23 @@ def _pull_tagged(stream): # Tagged field containing BitArray -def tagged(char, l): +def tagged(char, bits): # Tagged fields need to be zero-padded to 5 bits. - while l.len % 5 != 0: - l.append("0b0") + while bits.len % 5 != 0: + bits.append("0b0") return ( bitstring.pack( "uint:5, uint:5, uint:5", CHARSET.find(char), - (l.len / 5) / 32, - (l.len / 5) % 32, + (bits.len / 5) / 32, + (bits.len / 5) % 32, ) - + l + + bits ) -def tagged_bytes(char, l): - return tagged(char, bitstring.BitArray(l)) +def tagged_bytes(char, bits): + return tagged(char, bitstring.BitArray(bits)) def _trim_to_bytes(barr): diff --git a/lnbits/core/migrations.py b/lnbits/core/migrations.py index c19f40af..435e30b0 100644 --- a/lnbits/core/migrations.py +++ b/lnbits/core/migrations.py @@ -168,7 +168,8 @@ async def m004_ensure_fees_are_always_negative(db): async def m005_balance_check_balance_notify(db): """ - Keep track of balanceCheck-enabled lnurl-withdrawals to be consumed by an LNbits wallet and of balanceNotify URLs supplied by users to empty their wallets. + Keep track of balanceCheck-enabled lnurl-withdrawals to be consumed by an + LNbits wallet and of balanceNotify URLs supplied by users to empty their wallets. """ await db.execute( diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 9b699571..49ae4ef5 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -334,7 +334,8 @@ async def perform_lnurlauth( def encode_strict_der(r: int, s: int, order: int): # if s > order/2 verification will fail sometimes - # so we must fix it here (see https://github.com/indutny/elliptic/blob/e71b2d9359c5fe9437fbf46f1f05096de447de57/lib/elliptic/ec/index.js#L146-L147) + # so we must fix it here see: + # https://github.com/indutny/elliptic/blob/e71b2d9359c5fe9437fbf46f1f05096de447de57/lib/elliptic/ec/index.js#L146-L147 if s > order // 2: s = order - s diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index e0555b37..6421706f 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -704,7 +704,7 @@ async def api_auditor(): } -##################UNIVERSAL WEBSOCKET MANAGER######################## +# UNIVERSAL WEBSOCKET MANAGER @core_app.websocket("/api/v1/ws/{item_id}") @@ -843,7 +843,7 @@ async def get_extension_releases(ext_id: str): ) -############################TINYURL################################## +# TINYURL @core_app.post("/api/v1/tinyurl") diff --git a/lnbits/db.py b/lnbits/db.py index 4a6673a7..6c9002a3 100644 --- a/lnbits/db.py +++ b/lnbits/db.py @@ -96,7 +96,7 @@ class Connection(Compat): # tuple to list and back to tuple value_list = [values] if isinstance(values, str) else list(values) - values = tuple([cleanhtml(l) for l in value_list]) + values = tuple([cleanhtml(val) for val in value_list]) return values async def fetchall(self, query: str, values: tuple = ()) -> list: diff --git a/lnbits/settings.py b/lnbits/settings.py index c5bdc43d..e4df2772 100644 --- a/lnbits/settings.py +++ b/lnbits/settings.py @@ -355,8 +355,6 @@ def send_admin_user_to_saas(): ) -############### INIT ################# - readonly_variables = ReadOnlySettings.readonly_fields() transient_variables = TransientSettings.readonly_fields() diff --git a/lnbits/wallets/lndrest.py b/lnbits/wallets/lndrest.py index f1921192..a8a94dab 100644 --- a/lnbits/wallets/lndrest.py +++ b/lnbits/wallets/lndrest.py @@ -187,9 +187,9 @@ class LndRestWallet(Wallet): timeout=None, headers=self.auth, verify=self.cert ) as client: async with client.stream("GET", url) as r: - async for l in r.aiter_lines(): + async for json_line in r.aiter_lines(): try: - line = json.loads(l) + line = json.loads(json_line) if line.get("error"): logger.error( line["error"]["message"] diff --git a/lnbits/wallets/void.py b/lnbits/wallets/void.py index b74eb245..60f981ea 100644 --- a/lnbits/wallets/void.py +++ b/lnbits/wallets/void.py @@ -24,7 +24,10 @@ class VoidWallet(Wallet): async def status(self) -> StatusResponse: logger.warning( - "This backend does nothing, it is here just as a placeholder, you must configure an actual backend before being able to do anything useful with LNbits." + ( + "This backend does nothing, it is here just as a placeholder, you must configure an " + "actual backend before being able to do anything useful with LNbits." + ) ) return StatusResponse(None, 0) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index fada0c12..00000000 --- a/setup.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[flake8] -max-line-length = 300 -exclude = lnbits/wallets/lnd_grpc_files/, lnbits/extensions/ -ignore = - # E203 whitespace before ':' - E203, - # E221: multiple spaces before operator - E221, - # E241: multiple spaces after ':' - E241, - # E402: module level import not at top of file - E402, - # E501: line too long - E501, - # E741 ambiguous variable name - E741, - # W503: line break before binary operator - W503, - # F821: undefined name - should be addressed in future PR - F821, - # E265 block comment should start with '# ' - should be addressed in future PR - E265, - # E266 too many leading '#' for block comment - should be addressed in future PR - E266, - # E722 do not use bare 'except' - should be addressed in future PR - E722, - # flake8-requirements import checks - I