1
0

ci: enable more flake8 stuff

```
$ export ELECTRUM_LINTERS=E9,E101,E129,E273,E274,E703,E71,E722,F5,F6,F7,F8,W191,W29,B
$ export ELECTRUM_LINTERS_IGNORE=B007,B009,B010,B019,B036,F541,F841
$ flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "*_pb2.py,electrum/_vendor/"
./electrum/commands.py:98:1: F811 redefinition of unused 'format_satoshis' from line 48
def format_satoshis(x):
^
./electrum/commands.py:437:9: F811 redefinition of unused 'Mnemonic' from line 62
        from .mnemonic import Mnemonic
        ^
./electrum/gui/qt/wizard/wallet.py:37:5: F811 redefinition of unused 'Daemon' from line 14
    from electrum.daemon import Daemon
    ^
./electrum/lntransport.py:14:1: F811 redefinition of unused 'Optional' from line 12
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
^
./electrum/lntransport.py:14:1: F811 redefinition of unused 'TYPE_CHECKING' from line 12
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
^
./electrum/plugin.py:966:13: F811 redefinition of unused 'hid' from line 593
            import hid
            ^
./electrum/plugin.py:1040:13: F811 redefinition of unused 'hid' from line 593
            import hid
            ^
./electrum/util.py:44:1: F811 redefinition of unused 'json' from line 26
import json
^
./electrum/util.py:46:1: F811 redefinition of unused 'NamedTuple' from line 29
from typing import NamedTuple, Optional
^
./electrum/util.py:46:1: F811 redefinition of unused 'Optional' from line 29
from typing import NamedTuple, Optional
^
./electrum/util.py:1456:56: F811 redefinition of unused 'traceback' from line 34
        async def __aexit__(self, exc_type, exc_value, traceback):
                                                       ^
./electrum/wallet_db.py:536:9: F811 redefinition of unused 'LOCAL' from line 46
        LOCAL = 1
        ^
./electrum/wallet_db.py:537:9: F811 redefinition of unused 'REMOTE' from line 46
        REMOTE = -1
        ^
./tests/test_bitcoin.py:28:1: F811 redefinition of unused 'bitcoin' from line 9
from electrum import crypto, constants, bitcoin
^
./tests/test_txbatcher.py:11:1: F811 redefinition of unused 'Transaction' from line 7
from electrum.transaction import Transaction, PartialTxInput, PartialTxOutput, TxOutpoint
^
./tests/test_wallet_vertical.py:20:1: F811 redefinition of unused 'Transaction' from line 10
from electrum.transaction import Transaction, PartialTxOutput, tx_from_any, Sighash
^
16    F811 redefinition of unused 'format_satoshis' from line 48
16

```
This commit is contained in:
SomberNight
2025-04-02 16:16:05 +00:00
parent 55281295b7
commit 5c233ac325
10 changed files with 12 additions and 19 deletions

View File

@@ -151,7 +151,7 @@ task:
folder: ~/.cache/pip folder: ~/.cache/pip
fingerprint_script: echo Flake8 && echo $ELECTRUM_IMAGE && cat $ELECTRUM_REQUIREMENTS fingerprint_script: echo Flake8 && echo $ELECTRUM_IMAGE && cat $ELECTRUM_REQUIREMENTS
install_script: install_script:
- pip install "flake8==7.2.0" "flake8-bugbear==24.12.12" # flake8-commas - pip install "flake8==7.2.0" "flake8-bugbear==24.12.12"
flake8_script: flake8_script:
- flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "*_pb2.py,electrum/_vendor/" - flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "*_pb2.py,electrum/_vendor/"
env: env:
@@ -164,8 +164,8 @@ task:
# - https://flake8.pycqa.org/en/latest/user/error-codes.html # - https://flake8.pycqa.org/en/latest/user/error-codes.html
# - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes # - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
# - https://github.com/PyCQA/flake8-bugbear/tree/8c0e7eb04217494d48d0ab093bf5b31db0921989#list-of-warnings # - https://github.com/PyCQA/flake8-bugbear/tree/8c0e7eb04217494d48d0ab093bf5b31db0921989#list-of-warnings
ELECTRUM_LINTERS: E9,E101,E129,E273,E274,E703,E71,E722,F63,F7,F82,W191,W29,B ELECTRUM_LINTERS: E9,E101,E129,E273,E274,E703,E71,E722,F5,F6,F7,F8,W191,W29,B
ELECTRUM_LINTERS_IGNORE: B007,B009,B010,B019,B036 ELECTRUM_LINTERS_IGNORE: B007,B009,B010,B019,B036,F541,F841
- name: "linter: Flake8 Non-Mandatory" - name: "linter: Flake8 Non-Mandatory"
env: env:
ELECTRUM_LINTERS: E,F,W,C90,B ELECTRUM_LINTERS: E,F,W,C90,B

View File

@@ -45,7 +45,7 @@ from . import util
from .lnmsg import OnionWireSerializer from .lnmsg import OnionWireSerializer
from .logging import Logger from .logging import Logger
from .onion_message import create_blinded_path, send_onion_message_to from .onion_message import create_blinded_path, send_onion_message_to
from .util import (bfh, format_satoshis, json_decode, json_normalize, is_hash256_str, is_hex_str, to_bytes, from .util import (bfh, json_decode, json_normalize, is_hash256_str, is_hex_str, to_bytes,
parse_max_spend, to_decimal, UserFacingException, InvalidPassword) parse_max_spend, to_decimal, UserFacingException, InvalidPassword)
from . import bitcoin from . import bitcoin
@@ -434,7 +434,6 @@ class Commands(Logger):
arg:str:seed_type:The type of seed to create, e.g. 'standard' or 'segwit' arg:str:seed_type:The type of seed to create, e.g. 'standard' or 'segwit'
arg:str:language:Default language for wordlist arg:str:language:Default language for wordlist
""" """
from .mnemonic import Mnemonic
s = Mnemonic(language).make_seed(seed_type=seed_type, num_bits=nbits) s = Mnemonic(language).make_seed(seed_type=seed_type, num_bits=nbits)
return s return s
@@ -1156,7 +1155,7 @@ class Commands(Logger):
if labels or balance: if labels or balance:
item = (item,) item = (item,)
if balance: if balance:
item += (format_satoshis(sum(wallet.get_addr_balance(addr))),) item += (util.format_satoshis(sum(wallet.get_addr_balance(addr))),)
if labels: if labels:
item += (repr(wallet.get_label_for_address(addr)),) item += (repr(wallet.get_label_for_address(addr)),)
out.append(item) out.append(item)

View File

@@ -34,7 +34,6 @@ from electrum.gui.qt.util import (PasswordLineEdit, char_width_in_lineedit, WWLa
if TYPE_CHECKING: if TYPE_CHECKING:
from electrum.simple_config import SimpleConfig from electrum.simple_config import SimpleConfig
from electrum.plugin import Plugins from electrum.plugin import Plugins
from electrum.daemon import Daemon
from electrum.gui.qt import QElectrumApplication from electrum.gui.qt import QElectrumApplication
WIF_HELP_TEXT = (_('WIF keys are typed in Electrum, based on script type.') + '\n\n' + WIF_HELP_TEXT = (_('WIF keys are typed in Electrum, based on script type.') + '\n\n' +

View File

@@ -9,7 +9,6 @@ import re
import hashlib import hashlib
import asyncio import asyncio
from asyncio import StreamReader, StreamWriter from asyncio import StreamReader, StreamWriter
from typing import Optional, TYPE_CHECKING
from functools import cached_property from functools import cached_property
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence

View File

@@ -963,7 +963,7 @@ class DeviceMgr(ThreadJob):
@runs_in_hwd_thread @runs_in_hwd_thread
def _scan_devices_with_hid(self) -> List['Device']: def _scan_devices_with_hid(self) -> List['Device']:
try: try:
import hid import hid # noqa: F811
except ImportError: except ImportError:
return [] return []
@@ -1037,7 +1037,7 @@ class DeviceMgr(ThreadJob):
ret["libusb.path"] = None ret["libusb.path"] = None
# add hidapi # add hidapi
try: try:
import hid import hid # noqa: F811
ret["hidapi.version"] = hid.__version__ # available starting with 0.12.0.post2 ret["hidapi.version"] = hid.__version__ # available starting with 0.12.0.post2
except Exception as e: except Exception as e:
from importlib.metadata import version from importlib.metadata import version

View File

@@ -23,7 +23,7 @@
import binascii import binascii
import concurrent.futures import concurrent.futures
import logging import logging
import os, sys, re, json import os, sys, re
from collections import defaultdict, OrderedDict from collections import defaultdict, OrderedDict
from concurrent.futures.process import ProcessPoolExecutor from concurrent.futures.process import ProcessPoolExecutor
from typing import (NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable, Any, from typing import (NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable, Any,
@@ -31,7 +31,6 @@ from typing import (NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable,
from datetime import datetime, timezone from datetime import datetime, timezone
import decimal import decimal
from decimal import Decimal from decimal import Decimal
import traceback
import urllib import urllib
import threading import threading
import hmac import hmac
@@ -43,7 +42,6 @@ import urllib.request, urllib.parse, urllib.error
import builtins import builtins
import json import json
import time import time
from typing import NamedTuple, Optional
import ssl import ssl
import ipaddress import ipaddress
from ipaddress import IPv4Address, IPv6Address from ipaddress import IPv4Address, IPv6Address
@@ -1453,9 +1451,9 @@ if hasattr(asyncio, 'timeout'): # python 3.11+
async_timeout = asyncio.timeout async_timeout = asyncio.timeout
else: else:
class TimeoutAfterAsynciolike(aiorpcx.curio.TimeoutAfter): class TimeoutAfterAsynciolike(aiorpcx.curio.TimeoutAfter):
async def __aexit__(self, exc_type, exc_value, traceback): async def __aexit__(self, exc_type, exc_value, tb):
try: try:
await super().__aexit__(exc_type, exc_value, traceback) await super().__aexit__(exc_type, exc_value, tb)
except (aiorpcx.TaskTimeout, aiorpcx.UncaughtTimeoutError): except (aiorpcx.TaskTimeout, aiorpcx.UncaughtTimeoutError):
raise asyncio.TimeoutError from None raise asyncio.TimeoutError from None
except aiorpcx.TimeoutCancellationError: except aiorpcx.TimeoutCancellationError:

View File

@@ -43,7 +43,7 @@ from .keystore import bip44_derivation
from .transaction import Transaction, TxOutpoint, tx_from_any, PartialTransaction, PartialTxOutput, BadHeaderMagic from .transaction import Transaction, TxOutpoint, tx_from_any, PartialTransaction, PartialTxOutput, BadHeaderMagic
from .logging import Logger from .logging import Logger
from .lnutil import LOCAL, REMOTE, HTLCOwner, ChannelType from .lnutil import HTLCOwner, ChannelType
from . import json_db from . import json_db
from .json_db import StoredDict, JsonDB, locked, modifier, StoredObject, stored_in, stored_as from .json_db import StoredDict, JsonDB, locked, modifier, StoredObject, stored_in, stored_as
from .plugin import run_hook, plugin_loaders from .plugin import run_hook, plugin_loaders

View File

@@ -25,7 +25,7 @@ from electrum.bip32 import (BIP32Node, convert_bip32_intpath_to_strpath,
is_xpub, convert_bip32_strpath_to_intpath, is_xpub, convert_bip32_strpath_to_intpath,
normalize_bip32_derivation, is_all_public_derivation) normalize_bip32_derivation, is_all_public_derivation)
from electrum.crypto import sha256d, SUPPORTED_PW_HASH_VERSIONS from electrum.crypto import sha256d, SUPPORTED_PW_HASH_VERSIONS
from electrum import crypto, constants, bitcoin from electrum import crypto, constants
from electrum.util import bfh, InvalidPassword, randrange from electrum.util import bfh, InvalidPassword, randrange
from electrum.storage import WalletStorage from electrum.storage import WalletStorage
from electrum.keystore import xtype_from_derivation from electrum.keystore import xtype_from_derivation

View File

@@ -4,7 +4,6 @@ from unittest import mock
import asyncio import asyncio
from electrum import storage, bitcoin, keystore, wallet from electrum import storage, bitcoin, keystore, wallet
from electrum import Transaction
from electrum import SimpleConfig from electrum import SimpleConfig
from electrum import util from electrum import util
from electrum.address_synchronizer import TX_HEIGHT_UNCONFIRMED, TX_HEIGHT_UNCONF_PARENT, TX_HEIGHT_LOCAL from electrum.address_synchronizer import TX_HEIGHT_UNCONFIRMED, TX_HEIGHT_UNCONF_PARENT, TX_HEIGHT_LOCAL

View File

@@ -7,7 +7,6 @@ import asyncio
import copy import copy
from electrum import storage, bitcoin, keystore, bip32, slip39, wallet from electrum import storage, bitcoin, keystore, bip32, slip39, wallet
from electrum import Transaction
from electrum import SimpleConfig from electrum import SimpleConfig
from electrum import util from electrum import util
from electrum.address_synchronizer import TX_HEIGHT_UNCONFIRMED, TX_HEIGHT_UNCONF_PARENT, TX_HEIGHT_LOCAL from electrum.address_synchronizer import TX_HEIGHT_UNCONFIRMED, TX_HEIGHT_UNCONF_PARENT, TX_HEIGHT_LOCAL