diff --git a/Pipfile b/Pipfile index e4b91f9c6..5f849d993 100644 --- a/Pipfile +++ b/Pipfile @@ -23,6 +23,7 @@ pytest-random-order = "*" pytest-timeout = "*" tox = "*" dominate = "*" +flake8-requirements = ">=1.3.2" # hardware tests pyserial = "*" diff --git a/pyproject.toml b/pyproject.toml index 3a82bc80e..67eedaa40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,6 +73,7 @@ inotify = "*" [tool.poetry.dev-dependencies] scan-build = "*" +flake8-requirements = "^1.3.2" [build-system] requires = ["poetry>=0.12"] diff --git a/python/requirements.txt b/python/requirements.txt index e2ad3751d..039f0f9fa 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -6,3 +6,4 @@ libusb1>=1.6.4 construct>=2.9,!=2.10.55 typing_extensions>=3.7.4 pyblake2>=0.9.3 ; python_version<'3.6' +attrs diff --git a/python/setup.cfg b/python/setup.cfg index d68a18179..86c820791 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -21,6 +21,11 @@ ignore = E741, # W503: line break before binary operator W503 +per-file-ignores = + helper-scripts/*:I + tools/*:I + tests/*:I +known-modules = libusb1:[usb1],hidapi:[hid],attrs:[attr],PyQt5:[PyQt5.QtWidgets,PyQt5.QtGui,PyQt5.QtCore] [isort] multi_line_output = 3 diff --git a/python/setup.py b/python/setup.py index cc19e295e..eb9786f9c 100755 --- a/python/setup.py +++ b/python/setup.py @@ -14,8 +14,18 @@ install_requires = [ "construct>=2.9", "typing_extensions>=3.7.4", "pyblake2>=0.9.3 ; python_version<'3.6'", + "attrs", ] +extras_require = { + "hidapi": ["hidapi>=0.7.99.post20"], + "ethereum": ["rlp>=1.1.0", "web3>=4.8"], + "qt-widgets": ["PyQt5"], + "extra": ["Pillow"], +} + +extras_require["full"] = sum(extras_require.values(), []) + CWD = os.path.dirname(os.path.realpath(__file__)) @@ -48,10 +58,7 @@ setup( package_dir={"": "src"}, entry_points={"console_scripts": ["trezorctl=trezorlib.cli.trezorctl:cli"]}, install_requires=install_requires, - extras_require={ - "hidapi": ["hidapi>=0.7.99.post20"], - "ethereum": ["rlp>=1.1.0", "web3>=4.8"], - }, + extras_require=extras_require, python_requires=">=3.5", include_package_data=True, zip_safe=False, diff --git a/python/src/trezorlib/_internal/emulator.py b/python/src/trezorlib/_internal/emulator.py index 6873cd852..74c7eeb72 100644 --- a/python/src/trezorlib/_internal/emulator.py +++ b/python/src/trezorlib/_internal/emulator.py @@ -20,8 +20,8 @@ import subprocess import time from pathlib import Path -from trezorlib.debuglink import TrezorClientDebugLink -from trezorlib.transport.udp import UdpTransport +from ..debuglink import TrezorClientDebugLink +from ..transport.udp import UdpTransport LOG = logging.getLogger(__name__) diff --git a/python/src/trezorlib/_internal/firmware_headers.py b/python/src/trezorlib/_internal/firmware_headers.py index 52758456e..92b15b747 100644 --- a/python/src/trezorlib/_internal/firmware_headers.py +++ b/python/src/trezorlib/_internal/firmware_headers.py @@ -5,7 +5,7 @@ from typing import Any, List, Optional import click import construct as c -from trezorlib import cosi, firmware +from .. import cosi, firmware try: from hashlib import blake2s diff --git a/python/src/trezorlib/cli/trezorctl.py b/python/src/trezorlib/cli/trezorctl.py index 843b52981..9fc613750 100755 --- a/python/src/trezorlib/cli/trezorctl.py +++ b/python/src/trezorlib/cli/trezorctl.py @@ -290,7 +290,7 @@ def usb_reset(): This can fix LIBUSB_ERROR_PIPE and similar errors when connecting to a device in a messed state. """ - from trezorlib.transport.webusb import WebUsbTransport + from ..transport.webusb import WebUsbTransport WebUsbTransport.enumerate(usb_reset=True) diff --git a/python/src/trezorlib/qt/pinmatrix.py b/python/src/trezorlib/qt/pinmatrix.py index dc7d2f66a..c3b52d675 100644 --- a/python/src/trezorlib/qt/pinmatrix.py +++ b/python/src/trezorlib/qt/pinmatrix.py @@ -32,7 +32,7 @@ try: from PyQt5.QtGui import QRegExpValidator from PyQt5.QtCore import QRegExp, Qt, QT_VERSION_STR except Exception: - from PyQt4.QtGui import ( + from PyQt4.QtGui import ( # noqa: I QPushButton, QLineEdit, QSizePolicy, @@ -44,7 +44,7 @@ except Exception: QVBoxLayout, QHBoxLayout, ) - from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt, QT_VERSION_STR + from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt, QT_VERSION_STR # noqa: I class PinButton(QPushButton): diff --git a/setup.cfg b/setup.cfg index 9749ec730..0c434b7f6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,9 @@ ignore = # E741 ambiguous variable name E741, # W503: line break before binary operator - W503 + W503, + # flake8-requirements import checks + I per-file-ignores = core/mocks/generated/*:F4