ruff FURB163 (math.log), FURB166 (base16 w/o prefix)

This commit is contained in:
The MMGen Project 2026-08-07 09:37:47 +00:00
commit d8dd0cc246
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 3 additions and 4 deletions

View file

@ -73,7 +73,7 @@ def get_terminfo_colors(term=None):
if s.isdecimal():
return int(s)
elif s.startswith('0x') and is_hex_str(s[2:]):
return int(s[2:], 16)
return int(s, 16)
else:
return None

View file

@ -22,8 +22,6 @@ ignore = [
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
"BLE001", # Do not catch blind exception: `Exception`
"E722", # bare except
"FURB163", # Prefer `math.log2(state.lanew)` over `math.log` with a redundant base
"FURB166", # Use of `int` with explicit `base=16` after removing prefix
"FURB192", # Prefer `max` over `sorted()` to compute the maximum value in a sequence
"I001", # Import block is un-sorted or un-formatted
"ISC004", # Unparenthesized implicit string concatenation in collection
@ -73,6 +71,7 @@ ignore = [
[tool.ruff.lint.per-file-ignores]
"mmgen/tool/*" = [ "F821" ] # Undefined name `sstr`
"mmgen/tool/file.py" = [ "B008" ] # function call in dfl args
"mmgen/contrib/keccak.py" = [ "FURB163" ] # `math.log` -> `math.log2(state.lanew)`
"examples/*" = [ "ASYNC230" ] # open() in async function
"test/include/common.py" = [ "F821" ] # undefined name 'cfg'

View file

@ -240,7 +240,7 @@ class TestCoinInfo(CoinInfo):
def fix_ver_info(e, k):
e[k] = list(e[k])
e[k][0] = myhex(e[k][0])
s1 = cls.find_addr_leading_symbol(int(e[k][0][2:], 16))
s1 = cls.find_addr_leading_symbol(int(e[k][0], 16))
m = f'Fixing leading address letter for coin {e["symbol"]} ({e[k][1]!r} --> {s1})'
if e[k][1] != '?':
assert s1 == e[k][1], f'First letters do not match! {m}'