From 9672837cfbcc34afa875d2b4f17f594d2a84c432 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Aug 2026 09:37:48 +0000 Subject: [PATCH] ruff various minor --- mmgen/cfg.py | 2 +- mmgen/proto/eth/pyethereum/utils.py | 3 ++- mmgen/sha2.py | 2 +- mmgen/util2.py | 2 +- pyproject.toml | 13 +++++-------- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 215ea163..f81528d2 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -228,7 +228,7 @@ class Config(Lockable): enable_erigon = False autochg_ignore_labels = False autosign = False - threaded_python = sys.version_info.minor > 12 and not sys._is_gil_enabled() + threaded_python = sys.version_info >= (3, 13) and not sys._is_gil_enabled() aes_backend = 'cryptography' # regtest: diff --git a/mmgen/proto/eth/pyethereum/utils.py b/mmgen/proto/eth/pyethereum/utils.py index 99dc576d..59092dc2 100644 --- a/mmgen/proto/eth/pyethereum/utils.py +++ b/mmgen/proto/eth/pyethereum/utils.py @@ -4,7 +4,8 @@ # import struct, functools -from typing import Any, Callable, TypeVar +from typing import Any, TypeVar +from collections.abc import Callable ALL_BYTES = tuple(struct.pack('B', i) for i in range(256)) diff --git a/mmgen/sha2.py b/mmgen/sha2.py index 637b434d..475e9651 100755 --- a/mmgen/sha2.py +++ b/mmgen/sha2.py @@ -103,7 +103,7 @@ class Sha2: self.M = tuple(unpack(self.word_fmt, self.M[i*ws:ws+(i*ws)])[0] for i in range(len(self.M) // ws)) def digest(self): - return b''.join((pack(self.word_fmt, w) for w in self.H)) + return b''.join(pack(self.word_fmt, w) for w in self.H) def hexdigest(self): return self.digest().hex() diff --git a/mmgen/util2.py b/mmgen/util2.py index 5d82d61a..dfcdda6c 100755 --- a/mmgen/util2.py +++ b/mmgen/util2.py @@ -228,7 +228,7 @@ def decode_pretty_hexdump(data): pat = re.compile(fr'^[{hexdigits}]+:\s+') lines = [pat.sub('', line) for line in data.splitlines()] try: - return bytes.fromhex(''.join((''.join(lines).split()))) + return bytes.fromhex(''.join(''.join(lines).split())) except: msg('Data not in hexdump format') return False diff --git a/pyproject.toml b/pyproject.toml index de084f59..6ff6d995 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ indent-style = "tab" [tool.ruff.lint] ignore = [ - "ASYNC221", # blocking method in async function (mmgen/rpc/backends/curl.py) "B006", # Do not use mutable data structures for argument defaults "B018", # Found useless expression. Either assign it to a variable or remove it. "B026", # Star-arg unpacking after a keyword argument is strongly discouraged @@ -30,22 +29,18 @@ ignore = [ "RET501", # Do not explicitly `return None` in function if it is the only possible return value "RUF012", # Mutable default value for class attribute "RUF022", # `__all__` is not sorted - "RUF100", # Unused `noqa` directive (non-enabled: `F401`) "S102", # Use of `exec` detected "S110", # `try`-`except`-`pass` detected, consider logging the exception "SIM102", # Use a single `if` statement instead of nested `if` statements "SIM114", # Combine `if` branches using logical `or` operator "SIM905", # Consider using a list literal instead of `str.split` - "UP030", # Use implicit references for positional format fields "UP031", # Use format specifiers instead of percent format "UP032", # Use f-string instead of `format` call - "UP034", # Avoid extraneous parentheses - "UP035", # `typing.List` is deprecated, use `list` instead - "UP045", # Use `X | None` for type annotations - "YTT204", # `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple ] [tool.ruff.lint.per-file-ignores] +"protobuf.py" = [ "UP045" ] # Use `X | None` for type annotations +"mmgen/rpc/backends/curl.py" = [ "ASYNC221" ] # blocking method in async function "mmgen/xmrwallet/__init__.py" = [ "PLC3002" ] # Lambda expression called directly "mmgen/tool/*" = [ "F821" ] # Undefined name `sstr` "mmgen/tool/file.py" = [ "B008" ] # function call in dfl args @@ -55,7 +50,9 @@ ignore = [ "mmgen/proto/eth/rlp/*" = [ "TRY002", # create your own exception "UP004", # class `Binary` inherits from `object` - "UP008" # Use `super()` instead of `super(__class__, self)` + "UP008", # Use `super()` instead of `super(__class__, self)` + "UP030", # Use implicit references for positional format fields + "RUF100" # Unused `noqa` directive (non-enabled: `F401`) ] "test/include/common.py" = [