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

style(core): remove unused type:ignore comments

This commit is contained in:
matejcik 2022-01-07 13:59:48 +01:00 committed by matejcik
parent 80f6463799
commit 5e1dce35b3
18 changed files with 44 additions and 44 deletions

View File

@ -14,7 +14,7 @@ if TYPE_CHECKING:
from apps.common.coininfo import CoinInfo from apps.common.coininfo import CoinInfo
from trezor.messages import TxInput from trezor.messages import TxInput
else: else:
IntEnum = object # type: ignore IntEnum = object
BITCOIN_NAMES = ("Bitcoin", "Regtest", "Testnet") BITCOIN_NAMES = ("Bitcoin", "Regtest", "Testnet")

View File

@ -14,8 +14,8 @@ if TYPE_CHECKING:
T = TypeVar("T") T = TypeVar("T")
else: else:
# typechecker cheat: Generic[T] will be `object` which is a valid parent type # typechecker cheat: Generic[T] will be `object` which is a valid parent type
Generic = [object] # type: ignore Generic = [object]
T = 0 # type: ignore T = 0
class MatchChecker(Generic[T]): class MatchChecker(Generic[T]):

View File

@ -10,10 +10,10 @@ if TYPE_CHECKING:
K = TypeVar("K") K = TypeVar("K")
V = TypeVar("V") V = TypeVar("V")
else: else:
T = 0 # type: ignore T = 0
K = 0 # type: ignore K = 0
V = 0 # type: ignore V = 0
Generic = {T: object, (K, V): object} # type: ignore Generic = {T: object, (K, V): object}
class HashBuilderCollection: class HashBuilderCollection:

View File

@ -19,8 +19,8 @@ if TYPE_CHECKING:
CborSequence = Union[list[Value], Tuple[Value, ...]] CborSequence = Union[list[Value], Tuple[Value, ...]]
else: else:
# typechecker cheat: Generic[K, V] will be `object` which is a valid parent type # typechecker cheat: Generic[K, V] will be `object` which is a valid parent type
Generic = {(0, 0): object} # type: ignore Generic = {(0, 0): object}
K = V = 0 # type: ignore K = V = 0
_CBOR_TYPE_MASK = const(0xE0) _CBOR_TYPE_MASK = const(0xE0)
_CBOR_INFO_BITS = const(0x1F) _CBOR_INFO_BITS = const(0x1F)

View File

@ -187,6 +187,6 @@ def find_registered_handler(iface: WireInterface, msg_type: int) -> Handler | No
modname = find_message_handler_module(msg_type) modname = find_message_handler_module(msg_type)
handler_name = modname[modname.rfind(".") + 1 :] handler_name = modname[modname.rfind(".") + 1 :]
module = __import__(modname, None, None, (handler_name,), 0) module = __import__(modname, None, None, (handler_name,), 0)
return getattr(module, handler_name) # type: ignore return getattr(module, handler_name)
except ValueError: except ValueError:
return None return None

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
OptionalTuple2 = Union[tuple[None, None], tuple[A, B]] OptionalTuple2 = Union[tuple[None, None], tuple[A, B]]
OptionalTuple3 = Union[tuple[None, None, None], tuple[A, B, C]] OptionalTuple3 = Union[tuple[None, None, None], tuple[A, B, C]]
else: else:
IntEnum = object # type: ignore IntEnum = object
class Encoding(IntEnum): class Encoding(IntEnum):

View File

@ -342,7 +342,7 @@ if __debug__:
return getattr(self.orig_display, key) return getattr(self.orig_display, key)
def __enter__(self) -> None: def __enter__(self) -> None:
ui.display = self # type: ignore ui.display = self
def __exit__(self, exc: Any, exc_type: Any, tb: Any) -> None: def __exit__(self, exc: Any, exc_type: Any, tb: Any) -> None:
ui.display = self.orig_display ui.display = self.orig_display

View File

@ -141,13 +141,13 @@ class InfoConfirm(ui.Layout):
self.content = content self.content = content
self.confirm = Button(ui.grid(14), confirm, confirm_style) self.confirm = Button(ui.grid(14), confirm, confirm_style)
self.confirm.on_click = self.on_confirm # type: ignore self.confirm.on_click = self.on_confirm
self.info = Button(ui.grid(13), info, info_style) self.info = Button(ui.grid(13), info, info_style)
self.info.on_click = self.on_info # type: ignore self.info.on_click = self.on_info
self.cancel = Button(ui.grid(12), cancel, cancel_style) self.cancel = Button(ui.grid(12), cancel, cancel_style)
self.cancel.on_click = self.on_cancel # type: ignore self.cancel.on_click = self.on_cancel
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
self.content.dispatch(event, x, y) self.content.dispatch(event, x, y)
@ -195,22 +195,22 @@ class HoldToConfirm(ui.Layout):
self.content = content self.content = content
self.loader = Loader(loader_style) self.loader = Loader(loader_style)
self.loader.on_start = self._on_loader_start # type: ignore self.loader.on_start = self._on_loader_start
if cancel: if cancel:
self.confirm = Button(ui.grid(17, n_x=4, cells_x=3), confirm, confirm_style) self.confirm = Button(ui.grid(17, n_x=4, cells_x=3), confirm, confirm_style)
else: else:
self.confirm = Button(ui.grid(4, n_x=1), confirm, confirm_style) self.confirm = Button(ui.grid(4, n_x=1), confirm, confirm_style)
self.confirm.on_press_start = self._on_press_start # type: ignore self.confirm.on_press_start = self._on_press_start
self.confirm.on_press_end = self._on_press_end # type: ignore self.confirm.on_press_end = self._on_press_end
self.confirm.on_click = self._on_click # type: ignore self.confirm.on_click = self._on_click
self.cancel = None self.cancel = None
if cancel: if cancel:
self.cancel = Button( self.cancel = Button(
ui.grid(16, n_x=4), res.load(ui.ICON_CANCEL), ButtonAbort ui.grid(16, n_x=4), res.load(ui.ICON_CANCEL), ButtonAbort
) )
self.cancel.on_click = self.on_cancel # type: ignore self.cancel.on_click = self.on_cancel
def _on_press_start(self) -> None: def _on_press_start(self) -> None:
self.loader.start() self.loader.start()

View File

@ -43,7 +43,7 @@ class InfoConfirm(ui.Layout):
self.panel_area = panel_area self.panel_area = panel_area
confirm_area = ui.grid(4, n_x=1) confirm_area = ui.grid(4, n_x=1)
self.confirm = Button(confirm_area, confirm, style.button) self.confirm = Button(confirm_area, confirm, style.button)
self.confirm.on_click = self.on_confirm # type: ignore self.confirm.on_click = self.on_confirm
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
if event == ui.RENDER: if event == ui.RENDER:

View File

@ -106,10 +106,10 @@ class Bip39Keyboard(ui.Layout):
icon_back = res.load(ui.ICON_BACK) icon_back = res.load(ui.ICON_BACK)
self.back = Button(ui.grid(0, n_x=3, n_y=4), icon_back, ButtonClear) self.back = Button(ui.grid(0, n_x=3, n_y=4), icon_back, ButtonClear)
self.back.on_click = self.on_back_click # type: ignore self.back.on_click = self.on_back_click
self.input = InputButton(ui.grid(1, n_x=3, n_y=4, cells_x=2), "", "") self.input = InputButton(ui.grid(1, n_x=3, n_y=4, cells_x=2), "", "")
self.input.on_click = self.on_input_click # type: ignore self.input.on_click = self.on_input_click
self.keys = [ self.keys = [
KeyButton(ui.grid(i + 3, n_y=4), k, self) KeyButton(ui.grid(i + 3, n_y=4), k, self)

View File

@ -109,10 +109,10 @@ class Slip39Keyboard(ui.Layout):
icon_back = res.load(ui.ICON_BACK) icon_back = res.load(ui.ICON_BACK)
self.back = Button(ui.grid(0, n_x=3, n_y=4), icon_back, ButtonClear) self.back = Button(ui.grid(0, n_x=3, n_y=4), icon_back, ButtonClear)
self.back.on_click = self.on_back_click # type: ignore self.back.on_click = self.on_back_click
self.input = InputButton(ui.grid(1, n_x=3, n_y=4, cells_x=2), self) self.input = InputButton(ui.grid(1, n_x=3, n_y=4, cells_x=2), self)
self.input.on_click = self.on_input_click # type: ignore self.input.on_click = self.on_input_click
self.keys = [ self.keys = [
KeyButton(ui.grid(i + 3, n_y=4), k, self, i + 1) KeyButton(ui.grid(i + 3, n_y=4), k, self, i + 1)

View File

@ -12,9 +12,9 @@ class NumInput(ui.Component):
self.min_count = min_count self.min_count = min_count
self.minus = Button(ui.grid(3), "-") self.minus = Button(ui.grid(3), "-")
self.minus.on_click = self.on_minus # type: ignore self.minus.on_click = self.on_minus
self.plus = Button(ui.grid(5), "+") self.plus = Button(ui.grid(5), "+")
self.plus.on_click = self.on_plus # type: ignore self.plus.on_click = self.on_plus
self.text = Label(ui.grid(4), "", LABEL_CENTER, ui.BOLD) self.text = Label(ui.grid(4), "", LABEL_CENTER, ui.BOLD)
self.edit(count) self.edit(count)

View File

@ -140,11 +140,11 @@ class PassphraseKeyboard(ui.Layout):
self.input = Input(ui.grid(0, n_x=1, n_y=6), "") self.input = Input(ui.grid(0, n_x=1, n_y=6), "")
self.back = Button(ui.grid(12), res.load(ui.ICON_BACK), ButtonClear) self.back = Button(ui.grid(12), res.load(ui.ICON_BACK), ButtonClear)
self.back.on_click = self.on_back_click # type: ignore self.back.on_click = self.on_back_click
self.back.disable() self.back.disable()
self.done = Button(ui.grid(14), res.load(ui.ICON_CONFIRM), ButtonConfirm) self.done = Button(ui.grid(14), res.load(ui.ICON_CONFIRM), ButtonConfirm)
self.done.on_click = self.on_confirm # type: ignore self.done.on_click = self.on_confirm
self.keys = key_buttons(KEYBOARD_KEYS[self.page], self) self.keys = key_buttons(KEYBOARD_KEYS[self.page], self)
self.pending_button: KeyButton | None = None self.pending_button: KeyButton | None = None

View File

@ -115,19 +115,19 @@ class PinDialog(ui.Layout):
icon_confirm = res.load(ui.ICON_CONFIRM) icon_confirm = res.load(ui.ICON_CONFIRM)
self.confirm_button = Button(ui.grid(14), icon_confirm, ButtonConfirm) self.confirm_button = Button(ui.grid(14), icon_confirm, ButtonConfirm)
self.confirm_button.on_click = self.on_confirm # type: ignore self.confirm_button.on_click = self.on_confirm
self.confirm_button.disable() self.confirm_button.disable()
icon_back = res.load(ui.ICON_BACK) icon_back = res.load(ui.ICON_BACK)
self.reset_button = Button(ui.grid(12), icon_back, ButtonClear) self.reset_button = Button(ui.grid(12), icon_back, ButtonClear)
self.reset_button.on_click = self.on_reset # type: ignore self.reset_button.on_click = self.on_reset
if allow_cancel: if allow_cancel:
icon_lock = res.load( icon_lock = res.load(
ui.ICON_CANCEL if config.is_unlocked() else ui.ICON_LOCK ui.ICON_CANCEL if config.is_unlocked() else ui.ICON_LOCK
) )
self.cancel_button = Button(ui.grid(12), icon_lock, ButtonCancel) self.cancel_button = Button(ui.grid(12), icon_lock, ButtonCancel)
self.cancel_button.on_click = self.on_cancel # type: ignore self.cancel_button.on_click = self.on_cancel
else: else:
self.cancel_button = Button(ui.grid(12), "") self.cancel_button = Button(ui.grid(12), "")
self.cancel_button.disable() self.cancel_button.disable()

View File

@ -31,7 +31,7 @@ class Slip39NumInput(ui.Component):
super().__init__() super().__init__()
self.step = step self.step = step
self.input = NumInput(count, min_count=min_count, max_count=max_count) self.input = NumInput(count, min_count=min_count, max_count=max_count)
self.input.on_change = self.on_change # type: ignore self.input.on_change = self.on_change
self.group_id = group_id self.group_id = group_id
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
@ -126,7 +126,7 @@ class MnemonicWordSelect(ui.Layout):
for i, word in enumerate(words): for i, word in enumerate(words):
area = ui.grid(i + 2, n_x=1) area = ui.grid(i + 2, n_x=1)
btn = Button(area, word) btn = Button(area, word)
btn.on_click = self.select(word) # type: ignore btn.on_click = self.select(word)
self.buttons.append(btn) self.buttons.append(btn)
if share_index is None: if share_index is None:
self.text: ui.Component = Text("Check seed") self.text: ui.Component = Text("Check seed")

View File

@ -73,7 +73,7 @@ class Paginated(ui.Layout):
area = ui.grid(16, n_x=4) area = ui.grid(16, n_x=4)
icon = res.load(ui.ICON_BACK) icon = res.load(ui.ICON_BACK)
self.back_button = Button(area, icon, ButtonDefault) self.back_button = Button(area, icon, ButtonDefault)
self.back_button.on_click = self.on_back_click # type: ignore self.back_button.on_click = self.on_back_click
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
pages = self.pages pages = self.pages
@ -169,7 +169,7 @@ class AskPaginated(ui.Component):
super().__init__() super().__init__()
self.content = content self.content = content
self.button = Button(ui.grid(3, n_x=1), button_text, ButtonDefault) self.button = Button(ui.grid(3, n_x=1), button_text, ButtonDefault)
self.button.on_click = self.on_show_paginated_click # type: ignore self.button.on_click = self.on_show_paginated_click
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
self.content.dispatch(event, x, y) self.content.dispatch(event, x, y)
@ -218,10 +218,10 @@ class PageWithButtons(ui.Component):
right_style = ButtonConfirm right_style = ButtonConfirm
self.left = Button(ui.grid(8, n_x=2), left, left_style) self.left = Button(ui.grid(8, n_x=2), left, left_style)
self.left.on_click = self.on_left # type: ignore self.left.on_click = self.on_left
self.right = Button(ui.grid(9, n_x=2), right, right_style) self.right = Button(ui.grid(9, n_x=2), right, right_style)
self.right.on_click = self.on_right # type: ignore self.right.on_click = self.on_right
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
self.content.dispatch(event, x, y) self.content.dispatch(event, x, y)

View File

@ -15,15 +15,15 @@ class WordSelector(ui.Layout):
super().__init__() super().__init__()
self.content = content self.content = content
self.w12 = Button(ui.grid(6, n_y=4), "12") self.w12 = Button(ui.grid(6, n_y=4), "12")
self.w12.on_click = self.on_w12 # type: ignore self.w12.on_click = self.on_w12
self.w18 = Button(ui.grid(7, n_y=4), "18") self.w18 = Button(ui.grid(7, n_y=4), "18")
self.w18.on_click = self.on_w18 # type: ignore self.w18.on_click = self.on_w18
self.w20 = Button(ui.grid(8, n_y=4), "20") self.w20 = Button(ui.grid(8, n_y=4), "20")
self.w20.on_click = self.on_w20 # type: ignore self.w20.on_click = self.on_w20
self.w24 = Button(ui.grid(9, n_y=4), "24") self.w24 = Button(ui.grid(9, n_y=4), "24")
self.w24.on_click = self.on_w24 # type: ignore self.w24.on_click = self.on_w24
self.w33 = Button(ui.grid(10, n_y=4), "33") self.w33 = Button(ui.grid(10, n_y=4), "33")
self.w33.on_click = self.on_w33 # type: ignore self.w33.on_click = self.on_w33
def dispatch(self, event: int, x: int, y: int) -> None: def dispatch(self, event: int, x: int, y: int) -> None:
self.content.dispatch(event, x, y) self.content.dispatch(event, x, y)

View File

@ -83,7 +83,7 @@ async def show_share_words(
words = [w for _, w in word_pages[paginated.page]] words = [w for _, w in word_pages[paginated.page]]
debug.reset_current_words.publish(words) debug.reset_current_words.publish(words)
paginated.on_change = export_displayed_words # type: ignore paginated.on_change = export_displayed_words
export_displayed_words() export_displayed_words()
# make sure we display correct data # make sure we display correct data