From 8d2f0a65664d3ba92dc565c412ea136467b9d858 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 26 Sep 2024 15:14:12 +0200 Subject: [PATCH] style: make style_check passing --- core/embed/rust/src/ui/component/base.rs | 6 ++---- core/embed/rust/src/ui/component/button_request.rs | 2 +- core/embed/rust/src/ui/layout/obj.rs | 5 ++++- core/embed/rust/src/ui/model_mercury/layout.rs | 5 ++++- core/embed/rust/src/ui/model_tr/layout.rs | 5 ++++- .../rust/src/ui/model_tt/component/keyboard/common.rs | 4 +++- core/embed/rust/src/ui/model_tt/layout.rs | 7 +++++-- core/src/apps/common/sdcard.py | 2 +- core/src/apps/ethereum/sign_tx.py | 1 - core/src/apps/management/recovery_device/layout.py | 3 +-- core/src/trezor/ui/layouts/mercury/__init__.py | 2 +- core/src/trezor/ui/layouts/mercury/fido.py | 2 -- core/src/trezor/ui/layouts/mercury/recovery.py | 2 +- python/src/trezorlib/debuglink.py | 2 +- 14 files changed, 28 insertions(+), 20 deletions(-) diff --git a/core/embed/rust/src/ui/component/base.rs b/core/embed/rust/src/ui/component/base.rs index 4fe0a6031..10faf12e5 100644 --- a/core/embed/rust/src/ui/component/base.rs +++ b/core/embed/rust/src/ui/component/base.rs @@ -582,8 +582,7 @@ impl EventCtx { } pub fn send_button_request(&mut self, code: ButtonRequestCode, name: TString<'static>) { - #[cfg(feature = "ui_debug")] - assert!(self.button_request.is_none()); + debug_assert!(self.button_request.is_none()); self.button_request = Some(ButtonRequest::new(code, name)); } @@ -612,8 +611,7 @@ impl EventCtx { } pub fn clear(&mut self) { - #[cfg(feature = "ui_debug")] - assert!(self.button_request.is_none()); + debug_assert!(self.button_request.is_none()); // replace self with a new instance, keeping only the fields we care about *self = Self::new(); } diff --git a/core/embed/rust/src/ui/component/button_request.rs b/core/embed/rust/src/ui/component/button_request.rs index 273f9858e..529f2b3e0 100644 --- a/core/embed/rust/src/ui/component/button_request.rs +++ b/core/embed/rust/src/ui/component/button_request.rs @@ -53,7 +53,7 @@ impl Component for SendButtonRequest { } } SendButtonRequestPolicy::OnAttachAlways => { - if let Some(br) = self.button_request.clone() { + if let Some(br) = self.button_request { ctx.send_button_request(br.code, br.name); } } diff --git a/core/embed/rust/src/ui/layout/obj.rs b/core/embed/rust/src/ui/layout/obj.rs index 9d780a40f..2c1f4115c 100644 --- a/core/embed/rust/src/ui/layout/obj.rs +++ b/core/embed/rust/src/ui/layout/obj.rs @@ -30,7 +30,10 @@ use crate::{ time::Duration, ui::{ button_request::ButtonRequest, - component::{base::{AttachType, TimerToken}, Component, Event, EventCtx, Never}, + component::{ + base::{AttachType, TimerToken}, + Component, Event, EventCtx, Never, + }, display, event::USBEvent, ui_features::ModelUI, diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 39bbc86f7..1bd45f2b7 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -44,7 +44,10 @@ use crate::{ flow::Swipable, geometry::{self, Direction}, layout::{ - base::LAYOUT_STATE, obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, result::{CANCELLED, CONFIRMED, INFO}, util::{upy_disable_animation, ConfirmBlob, PropsList, RecoveryType} + base::LAYOUT_STATE, + obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, + result::{CANCELLED, CONFIRMED, INFO}, + util::{upy_disable_animation, ConfirmBlob, PropsList, RecoveryType}, }, model_mercury::{ component::{check_homescreen_format, SwipeContent}, diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index 8fa00eded..47900eb51 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -47,7 +47,10 @@ use crate::{ }, geometry, layout::{ - base::LAYOUT_STATE, obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, result::{CANCELLED, CONFIRMED, INFO}, util::{upy_disable_animation, ConfirmBlob, RecoveryType} + base::LAYOUT_STATE, + obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, + result::{CANCELLED, CONFIRMED, INFO}, + util::{upy_disable_animation, ConfirmBlob, RecoveryType}, }, model_tr::component::check_homescreen_format, }, diff --git a/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs b/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs index b22274536..fe2d55858 100644 --- a/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs +++ b/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs @@ -58,7 +58,9 @@ impl MultiTapKeyboard { /// Returns `true` if `event` is an `Event::Timer` for the currently pending /// timer. pub fn timeout_event(&mut self, event: Event) -> bool { - self.pending.as_mut().map_or(false, |t| t.timer.expire(event)) + self.pending + .as_mut() + .map_or(false, |t| t.timer.expire(event)) } /// Reset to the empty state. Takes `EventCtx` to request a paint pass (to diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 7fe5be1c7..1c79507fb 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -50,7 +50,10 @@ use crate::{ }, geometry, layout::{ - base::LAYOUT_STATE, obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, result::{CANCELLED, CONFIRMED, INFO}, util::{upy_disable_animation, ConfirmBlob, PropsList, RecoveryType} + base::LAYOUT_STATE, + obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, + result::{CANCELLED, CONFIRMED, INFO}, + util::{upy_disable_animation, ConfirmBlob, PropsList, RecoveryType}, }, model_tt::component::check_homescreen_format, }, @@ -1720,7 +1723,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// /// def get_transition_out(self) -> AttachType: /// """Return the transition type.""" - /// + /// /// def return_value(self) -> T: /// """Retrieve the return value of the layout object.""" /// diff --git a/core/src/apps/common/sdcard.py b/core/src/apps/common/sdcard.py index 371303022..6246d05ab 100644 --- a/core/src/apps/common/sdcard.py +++ b/core/src/apps/common/sdcard.py @@ -1,4 +1,4 @@ -from trezor import TR, io, utils, wire +from trezor import TR, io, wire from trezor.ui.layouts import confirm_action, show_error_and_raise from trezor.utils import sd_hotswap_enabled diff --git a/core/src/apps/ethereum/sign_tx.py b/core/src/apps/ethereum/sign_tx.py index 9c9a47317..8294b90b1 100644 --- a/core/src/apps/ethereum/sign_tx.py +++ b/core/src/apps/ethereum/sign_tx.py @@ -1,6 +1,5 @@ from typing import TYPE_CHECKING -from trezor import utils from trezor.crypto import rlp from trezor.messages import EthereumTxRequest from trezor.utils import BufferReader diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py index 8d00a9ead..352cf2d47 100644 --- a/core/src/apps/management/recovery_device/layout.py +++ b/core/src/apps/management/recovery_device/layout.py @@ -1,7 +1,6 @@ from typing import TYPE_CHECKING from trezor import TR -from trezor.enums import ButtonRequestType from trezor.ui.layouts.recovery import ( # noqa: F401 request_word_count, show_group_share_success, @@ -11,7 +10,7 @@ from trezor.ui.layouts.recovery import ( # noqa: F401 from apps.common import backup_types if TYPE_CHECKING: - from typing import Awaitable, Callable + from typing import Awaitable from trezor.enums import BackupType diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index 791a7c8d7..6cf7c91a6 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -8,7 +8,7 @@ from trezor.wire import ActionCancelled from ..common import draw_simple, interact, raise_if_not_confirmed, with_info if TYPE_CHECKING: - from typing import Any, Awaitable, Iterable, NoReturn, Sequence, TypeVar + from typing import Awaitable, Iterable, NoReturn, Sequence, TypeVar from ..common import ExceptionType, PropertyType diff --git a/core/src/trezor/ui/layouts/mercury/fido.py b/core/src/trezor/ui/layouts/mercury/fido.py index d74df0619..098744e65 100644 --- a/core/src/trezor/ui/layouts/mercury/fido.py +++ b/core/src/trezor/ui/layouts/mercury/fido.py @@ -1,5 +1,3 @@ -from typing import TYPE_CHECKING - import trezorui2 from trezor import ui from trezor.enums import ButtonRequestType diff --git a/core/src/trezor/ui/layouts/mercury/recovery.py b/core/src/trezor/ui/layouts/mercury/recovery.py index 095ee0dac..e80979988 100644 --- a/core/src/trezor/ui/layouts/mercury/recovery.py +++ b/core/src/trezor/ui/layouts/mercury/recovery.py @@ -1,7 +1,7 @@ from typing import TYPE_CHECKING import trezorui2 -from trezor import TR, ui +from trezor import TR from trezor.enums import ButtonRequestType, RecoveryType from ..common import interact diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index 4e4c5bf73..3219b2c1c 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -48,7 +48,7 @@ from .client import TrezorClient from .exceptions import TrezorFailure from .log import DUMP_BYTES from .messages import DebugWaitType -from .tools import expect, session +from .tools import expect if TYPE_CHECKING: from typing_extensions import Protocol