Merge pull request #1630 from lnbits/update/flake8
FEAT: improve on flake8 linting
This commit is contained in:
commit
07946d873f
16
.flake8
Normal file
16
.flake8
Normal file
|
@ -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
|
|
@ -428,7 +428,10 @@ class Formatter:
|
|||
self.padding = 0
|
||||
self.minimal_fmt: str = "<green>{time:YYYY-MM-DD HH:mm:ss.SS}</green> | <level>{level}</level> | <level>{message}</level>\n"
|
||||
if settings.debug:
|
||||
self.fmt: str = "<green>{time:YYYY-MM-DD HH:mm:ss.SS}</green> | <level>{level: <4}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> | <level>{message}</level>\n"
|
||||
self.fmt: str = (
|
||||
"<green>{time:YYYY-MM-DD HH:mm:ss.SS}</green> | <level>{level: <4}</level> | "
|
||||
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> | <level>{message}</level>\n"
|
||||
)
|
||||
else:
|
||||
self.fmt: str = self.minimal_fmt
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -355,8 +355,6 @@ def send_admin_user_to_saas():
|
|||
)
|
||||
|
||||
|
||||
############### INIT #################
|
||||
|
||||
readonly_variables = ReadOnlySettings.readonly_fields()
|
||||
transient_variables = TransientSettings.readonly_fields()
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
28
setup.cfg
28
setup.cfg
|
@ -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
|
Loading…
Reference in New Issue
Block a user