From b4fa00f56a5284615616c339de55652f6ca27fb7 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Mon, 14 Apr 2025 12:27:48 +0200 Subject: [PATCH] fix: style --- python/src/trezorlib/client.py | 1 + python/src/trezorlib/debuglink.py | 11 +++++++---- python/src/trezorlib/transport/session.py | 3 +-- tests/conftest.py | 2 +- tests/device_tests/thp/test_pairing.py | 1 - 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/python/src/trezorlib/client.py b/python/src/trezorlib/client.py index 33f3a15b1f..bb62de02bb 100644 --- a/python/src/trezorlib/client.py +++ b/python/src/trezorlib/client.py @@ -63,6 +63,7 @@ class TrezorClient: _last_active_session: SessionV1 | None = None _session_id_counter: int = 0 + def __init__( self, transport: Transport, diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index feeadec082..bbeab11a6f 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -33,14 +33,18 @@ from mnemonic import Mnemonic from . import btc, mapping, messages, models, protobuf from .client import ProtocolVersion, TrezorClient -from .exceptions import Cancelled, TrezorFailure, UnexpectedMessageError +from .exceptions import ( + Cancelled, + DeviceLockedException, + TrezorFailure, + UnexpectedMessageError, +) from .log import DUMP_BYTES from .messages import DebugWaitType from .tools import parse_path from .transport import Timeout from .transport.session import ProtocolV2Channel, Session from .transport.thp.protocol_v1 import ProtocolV1Channel -from trezorlib import exceptions if t.TYPE_CHECKING: from typing_extensions import Protocol @@ -1102,7 +1106,7 @@ class TrezorClientDebugLink(TrezorClient): try: super().__init__(transport) - except exceptions.DeviceLockedException: + except DeviceLockedException: self.use_pin_sequence(["1234"]) self.debug.input(self.debug.encode_pin("1234")) super().__init__(transport) @@ -1444,7 +1448,6 @@ class TrezorClientDebugLink(TrezorClient): return resp def notify_read(self, msg: protobuf.MessageType) -> None: - pass try: if self.actual_responses is not None: self.actual_responses.append(msg) diff --git a/python/src/trezorlib/transport/session.py b/python/src/trezorlib/transport/session.py index 5e8f0a0d19..549a713373 100644 --- a/python/src/trezorlib/transport/session.py +++ b/python/src/trezorlib/transport/session.py @@ -3,7 +3,6 @@ from __future__ import annotations import logging import typing as t - from .. import exceptions, messages, models from ..client import MAX_PIN_LENGTH from ..protobuf import MessageType @@ -275,7 +274,7 @@ class SessionV2(Session): self.channel.write(self.sid, msg) def _read(self) -> t.Any: - from trezorlib.debuglink import TrezorClientDebugLink + from ..debuglink import TrezorClientDebugLink msg = self.channel.read(self.sid) LOG.debug("reading message %s", type(msg)) diff --git a/tests/conftest.py b/tests/conftest.py index a612325513..45983c3f1c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -348,7 +348,7 @@ def _client_unlocked( sleep(LOCK_TIME) try: _raw_client = _raw_client.get_new_client() - except Exception as e: + except Exception: sleep(1.5) _raw_client = _get_raw_client(request) diff --git a/tests/device_tests/thp/test_pairing.py b/tests/device_tests/thp/test_pairing.py index 527da751f8..39bf7c0778 100644 --- a/tests/device_tests/thp/test_pairing.py +++ b/tests/device_tests/thp/test_pairing.py @@ -37,7 +37,6 @@ from trezorlib.messages import ( from trezorlib.transport.thp import curve25519 from trezorlib.transport.thp.cpace import Cpace - from .connect import ( get_encrypted_transport_protocol, handle_pairing_request,