1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

style: make style_check passing

This commit is contained in:
matejcik 2024-09-26 15:14:12 +02:00 committed by M1nd3r
parent 106587dfb9
commit c07d37c822
15 changed files with 31 additions and 24 deletions

View File

@ -582,8 +582,7 @@ impl EventCtx {
} }
pub fn send_button_request(&mut self, code: ButtonRequestCode, name: TString<'static>) { pub fn send_button_request(&mut self, code: ButtonRequestCode, name: TString<'static>) {
#[cfg(feature = "ui_debug")] debug_assert!(self.button_request.is_none());
assert!(self.button_request.is_none());
self.button_request = Some(ButtonRequest::new(code, name)); self.button_request = Some(ButtonRequest::new(code, name));
} }
@ -612,8 +611,7 @@ impl EventCtx {
} }
pub fn clear(&mut self) { pub fn clear(&mut self) {
#[cfg(feature = "ui_debug")] debug_assert!(self.button_request.is_none());
assert!(self.button_request.is_none());
// replace self with a new instance, keeping only the fields we care about // replace self with a new instance, keeping only the fields we care about
*self = Self::new(); *self = Self::new();
} }

View File

@ -53,7 +53,7 @@ impl<T: Component> Component for SendButtonRequest<T> {
} }
} }
SendButtonRequestPolicy::OnAttachAlways => { 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); ctx.send_button_request(br.code, br.name);
} }
} }

View File

@ -30,7 +30,10 @@ use crate::{
time::Duration, time::Duration,
ui::{ ui::{
button_request::ButtonRequest, button_request::ButtonRequest,
component::{base::{AttachType, TimerToken}, Component, Event, EventCtx, Never}, component::{
base::{AttachType, TimerToken},
Component, Event, EventCtx, Never,
},
display, display,
event::USBEvent, event::USBEvent,
ui_features::ModelUI, ui_features::ModelUI,

View File

@ -43,7 +43,10 @@ use crate::{
flow::Swipable, flow::Swipable,
geometry::{self, Direction}, geometry::{self, Direction},
layout::{ 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::{ model_mercury::{
component::{check_homescreen_format, SwipeContent}, component::{check_homescreen_format, SwipeContent},

View File

@ -47,7 +47,10 @@ use crate::{
}, },
geometry, geometry,
layout::{ 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, model_tr::component::check_homescreen_format,
}, },

View File

@ -58,7 +58,9 @@ impl MultiTapKeyboard {
/// Returns `true` if `event` is an `Event::Timer` for the currently pending /// Returns `true` if `event` is an `Event::Timer` for the currently pending
/// timer. /// timer.
pub fn timeout_event(&mut self, event: Event) -> bool { 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 /// Reset to the empty state. Takes `EventCtx` to request a paint pass (to

View File

@ -50,7 +50,10 @@ use crate::{
}, },
geometry, geometry,
layout::{ 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, model_tt::component::check_homescreen_format,
}, },
@ -1692,7 +1695,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// ///
/// def get_transition_out(self) -> AttachType: /// def get_transition_out(self) -> AttachType:
/// """Return the transition type.""" /// """Return the transition type."""
/// ///
/// def return_value(self) -> T: /// def return_value(self) -> T:
/// """Retrieve the return value of the layout object.""" /// """Retrieve the return value of the layout object."""
/// ///

View File

@ -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.ui.layouts import confirm_action, show_error_and_raise
from trezor.utils import sd_hotswap_enabled from trezor.utils import sd_hotswap_enabled

View File

@ -1,6 +1,5 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from trezor import utils
from trezor.crypto import rlp from trezor.crypto import rlp
from trezor.messages import EthereumTxRequest from trezor.messages import EthereumTxRequest
from trezor.utils import BufferReader from trezor.utils import BufferReader

View File

@ -1,7 +1,6 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from trezor import TR from trezor import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts.recovery import ( # noqa: F401 from trezor.ui.layouts.recovery import ( # noqa: F401
request_word_count, request_word_count,
show_group_share_success, show_group_share_success,
@ -11,7 +10,7 @@ from trezor.ui.layouts.recovery import ( # noqa: F401
from apps.common import backup_types from apps.common import backup_types
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Awaitable, Callable from typing import Awaitable
from trezor.enums import BackupType from trezor.enums import BackupType

View File

@ -1,15 +1,14 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import trezorui2 import trezorui2
from trezor import TR, io, loop, ui, utils from trezor import TR, ui, utils
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.messages import ButtonAck, ButtonRequest from trezor.wire import ActionCancelled
from trezor.wire import ActionCancelled, context
from ..common import draw_simple, interact, raise_if_not_confirmed, with_info from ..common import draw_simple, interact, raise_if_not_confirmed, with_info
if TYPE_CHECKING: 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 from ..common import ExceptionType, PropertyType

View File

@ -1,5 +1,3 @@
from typing import TYPE_CHECKING
import trezorui2 import trezorui2
from trezor import ui from trezor import ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType

View File

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import trezorui2 import trezorui2
from trezor import TR, ui from trezor import TR
from trezor.enums import ButtonRequestType, RecoveryType from trezor.enums import ButtonRequestType, RecoveryType
from ..common import interact from ..common import interact

View File

@ -8,7 +8,7 @@ from trezor.wire import ActionCancelled
from ..common import draw_simple, interact, raise_if_not_confirmed from ..common import draw_simple, interact, raise_if_not_confirmed
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, Awaitable, Iterable, NoReturn, Sequence from typing import Awaitable, Iterable, NoReturn, Sequence
from ..common import ExceptionType, PropertyType from ..common import ExceptionType, PropertyType

View File

@ -48,7 +48,7 @@ from .client import TrezorClient
from .exceptions import TrezorFailure from .exceptions import TrezorFailure
from .log import DUMP_BYTES from .log import DUMP_BYTES
from .messages import DebugWaitType from .messages import DebugWaitType
from .tools import expect, session from .tools import expect
if TYPE_CHECKING: if TYPE_CHECKING:
from typing_extensions import Protocol from typing_extensions import Protocol