diff --git a/.flake8 b/.flake8 index d6c84a48..1e5573d2 100644 --- a/.flake8 +++ b/.flake8 @@ -4,8 +4,6 @@ ignore = E221, # E241: multiple spaces after comma E241, - # F401: module imported but unused - F401, # E402: module level import not at top of file E402, # E501: line too long diff --git a/src/apps/common/request_passphrase.py b/src/apps/common/request_passphrase.py index fd592576..acfc39d6 100644 --- a/src/apps/common/request_passphrase.py +++ b/src/apps/common/request_passphrase.py @@ -1,9 +1,9 @@ -from trezor import res, ui, wire +from trezor import ui, wire from trezor.messages import ButtonRequestType, wire_types from trezor.messages.ButtonRequest import ButtonRequest from trezor.messages.FailureType import ActionCancelled, ProcessError from trezor.messages.PassphraseRequest import PassphraseRequest -from trezor.ui.entry_select import DEVICE, HOST, EntrySelector +from trezor.ui.entry_select import DEVICE, EntrySelector from trezor.ui.passphrase import CANCELLED, PassphraseKeyboard from trezor.ui.text import Text from apps.common import storage diff --git a/src/apps/common/signverify.py b/src/apps/common/signverify.py index f50379b3..e599b5c3 100644 --- a/src/apps/common/signverify.py +++ b/src/apps/common/signverify.py @@ -1,5 +1,4 @@ from ubinascii import hexlify -from micropython import const from trezor.crypto.hashlib import sha256 from trezor.utils import chunks, split_words from apps.common.hash_writer import HashWriter diff --git a/src/apps/debug/__init__.py b/src/apps/debug/__init__.py index 432f39ef..64fed4f7 100644 --- a/src/apps/debug/__init__.py +++ b/src/apps/debug/__init__.py @@ -2,9 +2,7 @@ import micropython import gc from uctypes import bytes_at, bytearray_at -from trezor import log from trezor import loop -from trezor.utils import unimport from trezor.wire import register, protobuf_workflow from trezor.messages.wire_types import \ DebugLinkDecision, DebugLinkGetState, DebugLinkStop, \ diff --git a/src/apps/ethereum/__init__.py b/src/apps/ethereum/__init__.py index bbe134ed..af15ef41 100644 --- a/src/apps/ethereum/__init__.py +++ b/src/apps/ethereum/__init__.py @@ -1,7 +1,7 @@ from trezor.wire import register, protobuf_workflow from trezor.utils import unimport -from trezor.messages.wire_types import \ - EthereumGetAddress, EthereumSignTx, EthereumSignMessage, EthereumVerifyMessage +from trezor.messages.wire_types import EthereumGetAddress, EthereumSignTx +# from trezor.messages.wire_types import EthereumSignMessage, EthereumVerifyMessage @unimport diff --git a/src/apps/ethereum/get_address.py b/src/apps/ethereum/get_address.py index 8f7fbc58..c06fd2d1 100644 --- a/src/apps/ethereum/get_address.py +++ b/src/apps/ethereum/get_address.py @@ -1,4 +1,4 @@ -from trezor import wire, ui +from trezor import ui async def layout_ethereum_get_address(ctx, msg): diff --git a/src/apps/ethereum/layout.py b/src/apps/ethereum/layout.py index 759ffd6a..8f89da1c 100644 --- a/src/apps/ethereum/layout.py +++ b/src/apps/ethereum/layout.py @@ -1,5 +1,5 @@ from apps.common.confirm import * -from trezor import wire, ui +from trezor import ui from trezor.utils import chunks, format_amount from trezor.messages import ButtonRequestType from trezor.ui.text import Text diff --git a/src/apps/homescreen/homescreen.py b/src/apps/homescreen/homescreen.py index 587442ad..9ef9f9cd 100644 --- a/src/apps/homescreen/homescreen.py +++ b/src/apps/homescreen/homescreen.py @@ -1,4 +1,4 @@ -from trezor import ui, loop, res +from trezor import ui, res from trezor.utils import unimport diff --git a/src/apps/management/backup_device.py b/src/apps/management/backup_device.py index 0e1e3b46..a8362db5 100644 --- a/src/apps/management/backup_device.py +++ b/src/apps/management/backup_device.py @@ -1,4 +1,4 @@ -from trezor import ui, wire +from trezor import wire from trezor.messages.FailureType import ProcessError from trezor.messages.Success import Success from apps.common import storage diff --git a/src/apps/wallet/get_entropy.py b/src/apps/wallet/get_entropy.py index 41039d6a..b363f146 100644 --- a/src/apps/wallet/get_entropy.py +++ b/src/apps/wallet/get_entropy.py @@ -1,4 +1,4 @@ -from trezor import wire, ui +from trezor import ui async def layout_get_entropy(ctx, msg): @@ -15,7 +15,6 @@ async def layout_get_entropy(ctx, msg): async def _show_entropy(ctx): from trezor.messages.ButtonRequestType import ProtectCall from trezor.ui.text import Text - from trezor.ui.container import Container from ..common.confirm import require_confirm await require_confirm(ctx, Text( diff --git a/src/main.py b/src/main.py index 77f5e4bb..f3b49e9b 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,4 @@ -import boot +import boot # noqa: F401 from trezor import io from trezor import log diff --git a/src/trezor/__init__.py b/src/trezor/__init__.py index a25a3e8d..ddf3109c 100644 --- a/src/trezor/__init__.py +++ b/src/trezor/__init__.py @@ -1,2 +1,2 @@ -import trezorconfig as config -import trezorio as io +import trezorconfig as config # noqa: F401 +import trezorio as io # noqa: F401 diff --git a/src/trezor/crypto/__init__.py b/src/trezor/crypto/__init__.py index f58737df..0cb5c149 100644 --- a/src/trezor/crypto/__init__.py +++ b/src/trezor/crypto/__init__.py @@ -1,7 +1 @@ -from trezorcrypto import bip32 -from trezorcrypto import bip39 -from trezorcrypto import chacha20poly1305 -from trezorcrypto import crc -from trezorcrypto import pbkdf2 -from trezorcrypto import random -from trezorcrypto import rfc6979 +from trezorcrypto import bip32, bip39, chacha20poly1305, crc, pbkdf2, random, rfc6979 # noqa: F401 diff --git a/src/trezor/crypto/curve.py b/src/trezor/crypto/curve.py index 60bb0431..e5d0aa4e 100644 --- a/src/trezor/crypto/curve.py +++ b/src/trezor/crypto/curve.py @@ -1,4 +1 @@ -from trezorcrypto import curve25519 -from trezorcrypto import ed25519 -from trezorcrypto import nist256p1 -from trezorcrypto import secp256k1 +from trezorcrypto import curve25519, ed25519, nist256p1, secp256k1 # noqa: F401 diff --git a/src/trezor/crypto/hashlib.py b/src/trezor/crypto/hashlib.py index 7814fd6e..14ea76d6 100644 --- a/src/trezor/crypto/hashlib.py +++ b/src/trezor/crypto/hashlib.py @@ -1,9 +1 @@ -from trezorcrypto import blake256 -from trezorcrypto import blake2b -from trezorcrypto import blake2s -from trezorcrypto import ripemd160 -from trezorcrypto import sha1 -from trezorcrypto import sha256 -from trezorcrypto import sha512 -from trezorcrypto import sha3_256 -from trezorcrypto import sha3_512 +from trezorcrypto import blake256, blake2b, blake2s, ripemd160, sha1, sha256, sha512, sha3_256, sha3_512 # noqa: F401 diff --git a/src/trezor/ui/passphrase.py b/src/trezor/ui/passphrase.py index c12a7996..037fbb30 100644 --- a/src/trezor/ui/passphrase.py +++ b/src/trezor/ui/passphrase.py @@ -1,8 +1,8 @@ from micropython import const from trezor import io, loop, ui, res from trezor.ui import display -from trezor.ui.button import BTN_CLICKED, ICON, Button -from trezor.ui.swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, SWIPE_RIGHT, Swipe +from trezor.ui.button import BTN_CLICKED, Button +from trezor.ui.swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, Swipe SPACE = res.load(ui.ICON_SPACE) diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index 72b79132..3d833831 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -1,8 +1,6 @@ from micropython import const from trezor import ui -from trezor.ui import display -DISPLAY_WIDTH = const(240) TEXT_HEADER_HEIGHT = const(48) TEXT_LINE_HEIGHT = const(26) TEXT_MARGIN_LEFT = const(14) diff --git a/src/trezor/utils.py b/src/trezor/utils.py index 931b031e..5e1e511a 100644 --- a/src/trezor/utils.py +++ b/src/trezor/utils.py @@ -1,7 +1,7 @@ import sys import gc -from trezorutils import halt, memcpy, set_mode_unprivileged, symbol +from trezorutils import halt, memcpy, set_mode_unprivileged, symbol # noqa: F401 def unimport(genfunc): diff --git a/src/trezor/workflow.py b/src/trezor/workflow.py index 53e0fc4f..7aa9ec93 100644 --- a/src/trezor/workflow.py +++ b/src/trezor/workflow.py @@ -1,6 +1,4 @@ -from trezor import log from trezor import loop -from trezor import ui started = [] default = None diff --git a/tests/common.py b/tests/common.py index f6d185a7..b4195235 100644 --- a/tests/common.py +++ b/tests/common.py @@ -2,6 +2,6 @@ import sys sys.path.append('../src') -from ubinascii import hexlify, unhexlify +from ubinascii import hexlify, unhexlify # noqa: F401 -import unittest +import unittest # noqa: F401 diff --git a/tests/examples/2048/main.py b/tests/examples/2048/main.py index b105b65e..16c36008 100644 --- a/tests/examples/2048/main.py +++ b/tests/examples/2048/main.py @@ -9,7 +9,7 @@ from trezor import ui from trezor import loop from trezor import workflow from trezor.crypto import random -from trezor.ui.swipe import Swipe, SWIPE_DOWN, SWIPE_UP, SWIPE_LEFT, SWIPE_RIGHT +from trezor.ui.swipe import Swipe, SWIPE_DOWN, SWIPE_UP, SWIPE_LEFT color_bg = ui.rgb(0xbb, 0xad, 0xa0) color_empty = ui.rgb(0xcc, 0xc0, 0xb3) diff --git a/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py b/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py index 8f97c0c2..a27d1c61 100644 --- a/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py +++ b/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py @@ -8,7 +8,7 @@ from trezor.messages.TxOutputType import TxOutputType from trezor.messages.TxRequest import TxRequest from trezor.messages.TxAck import TxAck from trezor.messages.TransactionType import TransactionType -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED +from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXFINISHED from trezor.messages.TxRequestDetailsType import TxRequestDetailsType from trezor.messages.TxRequestSerializedType import TxRequestSerializedType from trezor.messages import InputScriptType diff --git a/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py b/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py index 66e48a6e..2fbe3dc3 100644 --- a/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py +++ b/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py @@ -8,7 +8,7 @@ from trezor.messages.TxOutputType import TxOutputType from trezor.messages.TxRequest import TxRequest from trezor.messages.TxAck import TxAck from trezor.messages.TransactionType import TransactionType -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED +from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXFINISHED from trezor.messages.TxRequestDetailsType import TxRequestDetailsType from trezor.messages.TxRequestSerializedType import TxRequestSerializedType from trezor.messages import InputScriptType diff --git a/tests/test_apps.wallet.signtx.fee_threshold.py b/tests/test_apps.wallet.signtx.fee_threshold.py index 0147aec3..03cebae5 100644 --- a/tests/test_apps.wallet.signtx.fee_threshold.py +++ b/tests/test_apps.wallet.signtx.fee_threshold.py @@ -9,7 +9,7 @@ from trezor.messages.TxOutputBinType import TxOutputBinType from trezor.messages.TxRequest import TxRequest from trezor.messages.TxAck import TxAck from trezor.messages.TransactionType import TransactionType -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED +from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA from trezor.messages.TxRequestDetailsType import TxRequestDetailsType from trezor.messages import OutputScriptType diff --git a/tests/test_trezor.ui.display.py b/tests/test_trezor.ui.display.py index 21a8e390..c3e6ee29 100644 --- a/tests/test_trezor.ui.display.py +++ b/tests/test_trezor.ui.display.py @@ -1,7 +1,5 @@ from common import * -from trezor.crypto import random - from trezor.ui import display diff --git a/tests/test_trezor.wire.codec_v1.py b/tests/test_trezor.wire.codec_v1.py index e5736d08..20f35b27 100644 --- a/tests/test_trezor.wire.codec_v1.py +++ b/tests/test_trezor.wire.codec_v1.py @@ -3,12 +3,10 @@ import sys sys.path.append('../src') from utest import * -from ustruct import pack, unpack -from ubinascii import hexlify, unhexlify +from ubinascii import unhexlify from trezor import io -from trezor.loop import select, Syscall -from trezor.crypto import random +from trezor.loop import select from trezor.utils import chunks from trezor.wire import codec_v1 diff --git a/tests/test_trezor.wire.codec_v2.py b/tests/test_trezor.wire.codec_v2.py index c3fcf0fe..c5aecc43 100644 --- a/tests/test_trezor.wire.codec_v2.py +++ b/tests/test_trezor.wire.codec_v2.py @@ -3,11 +3,10 @@ import sys sys.path.append('../src') from utest import * -from ustruct import pack, unpack -from ubinascii import hexlify, unhexlify +from ustruct import pack from trezor import io -from trezor.loop import select, Syscall +from trezor.loop import select from trezor.utils import chunks from trezor.wire import codec_v2