1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-01 18:30:56 +00:00

chore: minor fixes in style and reducing unnecessary diffs with main

[no changelog]
This commit is contained in:
M1nd3r 2025-01-31 17:31:56 +01:00
parent aa3c07aee2
commit 2b3a63dbae
11 changed files with 13 additions and 47 deletions

View File

@ -226,7 +226,6 @@ def cli_main(
except ValueError:
raise click.ClickException(f"Not a valid session id: {session_id}")
# ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script)
ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script)
# Optionally record the screen into a specified directory.
@ -299,7 +298,7 @@ def list_devices(no_resolve: bool) -> Optional[Iterable["Transport"]]:
"""List connected Trezor devices."""
if no_resolve:
for d in enumerate_devices():
print(d.get_path())
click.echo(d.get_path())
return
from . import get_client
@ -358,7 +357,6 @@ def get_session(
obj.session_id = None
with obj.client_context() as client:
if client.features.model == "1" and client.version < (1, 9, 0):
raise click.ClickException(
"Upgrade your firmware to enable session support."

View File

@ -1,6 +1,6 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2024 SatoshiLabs and contributors
# Copyright (C) 2012-2022 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
@ -111,9 +111,7 @@ class UnstructuredJSONReader:
def top_level_value(self, key: str) -> t.Any:
return self.dict.get(key)
def find_objects_with_key_and_value(
self, key: str, value: t.Any
) -> list["AnyDict"]:
def find_objects_with_key_and_value(self, key: str, value: t.Any) -> list[AnyDict]:
def recursively_find(data: t.Any) -> t.Iterator[t.Any]:
if isinstance(data, dict):
if data.get(key) == value:
@ -430,7 +428,6 @@ def _make_input_func(
class DebugLink:
def __init__(self, transport: "Transport", auto_interact: bool = True) -> None:
self.transport = transport
self.allow_interactions = auto_interact
@ -536,10 +533,7 @@ class DebugLink:
self._write(msg)
return self._read()
def state(
self,
wait_type: DebugWaitType | None = None,
) -> messages.DebugLinkState:
def state(self, wait_type: DebugWaitType | None = None) -> messages.DebugLinkState:
if wait_type is None:
wait_type = (
DebugWaitType.CURRENT_LAYOUT
@ -1040,7 +1034,6 @@ class MessageFilter:
class MessageFilterGenerator:
def __getattr__(self, key: str) -> t.Callable[..., "MessageFilter"]:
message_type = getattr(messages, key)
return MessageFilter(message_type).update_fields
@ -1320,6 +1313,7 @@ class TrezorClientDebugLink(TrezorClient):
self.reset_debug_features(new_management_session=True)
self.sync_responses()
# So that we can choose right screenshotting logic (T1 vs TT)
# and know the supported debug capabilities
self.debug.model = self.model
@ -1340,7 +1334,6 @@ class TrezorClientDebugLink(TrezorClient):
Clears all debugging state that might have been modified by a testcase.
"""
self.ui: DebugUI = DebugUI(self.debug)
# self.pin_callback = self.ui.debug_callback_button
self.in_with_statement = False
self.expected_responses: list[MessageFilter] | None = None
self.actual_responses: list[protobuf.MessageType] | None = None

View File

@ -389,23 +389,6 @@ def _return_success(msg: "Success") -> str | None:
return _deprecation_retval_helper(msg.message, stacklevel=1)
# def session(
# f: "Callable[Concatenate[TrezorClient, P], R]",
# ) -> "Callable[Concatenate[TrezorClient, P], R]":
# # Decorator wraps a BaseClient method
# # with session activation / deactivation
# @functools.wraps(f)
# def wrapped_f(client: "TrezorClient", *args: "P.args", **kwargs: "P.kwargs") -> "R":
# __tracebackhide__ = True # for pytest # pylint: disable=W0612
# client.open()
# try:
# return f(client, *args, **kwargs)
# finally:
# client.close()
# return wrapped_f
# de-camelcasifier
# https://stackoverflow.com/a/1176023/222189

View File

@ -1,6 +1,6 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2024 SatoshiLabs and contributors
# Copyright (C) 2012-2022 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3

View File

@ -1,6 +1,6 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2024 SatoshiLabs and contributors
# Copyright (C) 2012-2022 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3

View File

@ -1,6 +1,6 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2024 SatoshiLabs and contributors
# Copyright (C) 2012-2022 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3

View File

@ -6,7 +6,6 @@ import logging
import os
import typing as t
from binascii import hexlify
from enum import IntEnum
import click
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
@ -468,10 +467,3 @@ class ProtocolV2(ProtocolAndChannel):
)
return False
return True
class ControlByteType(IntEnum):
CHANNEL_ALLOCATION_RES = 1
HANDSHAKE_INIT_RES = 2
HANDSHAKE_COMP_RES = 3
ACK = 4
ENCRYPTED_TRANSPORT = 5

View File

@ -1,6 +1,6 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2024 SatoshiLabs and contributors
# Copyright (C) 2012-2022 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3

View File

@ -1,6 +1,6 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2024 SatoshiLabs and contributors
# Copyright (C) 2012-2022 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3

View File

@ -24,14 +24,14 @@ from trezorlib.tools import parse_path
def main() -> None:
# Use first connected device
client = get_default_client()
session = client.get_session(derive_cardano=True)
session = client.get_session()
# Print out Trezor's features and settings
print(session.features)
# Get the first address of first BIP44 account
bip32_path = parse_path("44h/0h/0h/0/0")
address = btc.get_address(session, "Bitcoin", bip32_path, False)
address = btc.get_address(session, "Bitcoin", bip32_path, True)
print("Bitcoin address:", address)

View File

@ -71,7 +71,7 @@ def set_language(session: Session, lang: str):
language_data = build_and_sign_blob(lang, session)
with session:
device.change_language(session, language_data) # type: ignore
_CURRENT_TRANSLATION.TR = TRANSLATIONS[lang]
def get_lang_json(lang: str) -> translations.JsonDef:
assert lang in LANGUAGES