From f9ccced691111130062606409608d42467c67f80 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Thu, 14 Nov 2024 15:12:55 +0100 Subject: [PATCH] refactor(core/python): update and unify type ignore statements [no changelog] --- core/src/trezor/log.py | 2 +- core/src/trezor/ui/layouts/common.py | 2 +- core/src/trezor/ui/layouts/mercury/__init__.py | 4 ++-- core/src/trezor/ui/layouts/tr/__init__.py | 2 +- core/src/trezor/ui/layouts/tr/reset.py | 7 ++++++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/src/trezor/log.py b/core/src/trezor/log.py index 4c3aa65d05..199ccd3efc 100644 --- a/core/src/trezor/log.py +++ b/core/src/trezor/log.py @@ -60,7 +60,7 @@ def exception(name: str, exc: BaseException) -> None: name, _DEBUG, "ui.Result: %s", - exc.value, # type: ignore[Cannot access attribute "value" for class "BaseException"] + exc.value, # type: ignore [Cannot access attribute "value" for class "BaseException"] ) elif exc.__class__.__name__ == "Cancelled": _log(name, _DEBUG, "ui.Cancelled") diff --git a/core/src/trezor/ui/layouts/common.py b/core/src/trezor/ui/layouts/common.py index 4374bba5b2..6fe1b16f99 100644 --- a/core/src/trezor/ui/layouts/common.py +++ b/core/src/trezor/ui/layouts/common.py @@ -64,7 +64,7 @@ def raise_if_not_confirmed( exc: ExceptionType = ActionCancelled, ) -> Awaitable[None]: action = interact(layout_obj, br_name, br_code, exc) - return action # type: ignore ["UiResult" is incompatible with "None"] + return action # type: ignore [Expression of type "Coroutine[Any, Any, UiResult]" is incompatible with return type "Awaitable[None]"] async def with_info( diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index 97cbd8d72d..729c8915f7 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -1114,7 +1114,7 @@ def request_passphrase_on_device(max_len: int) -> Awaitable[str]: ButtonRequestType.PassphraseEntry, raise_on_cancel=ActionCancelled("Passphrase entry cancelled"), ) - return result # type: ignore ["UiResult" is incompatible with "str"] + return result # type: ignore [Expression of type "Coroutine[Any, Any, str | UiResult]" is incompatible with return type "Awaitable[str]"] def request_pin_on_device( @@ -1143,7 +1143,7 @@ def request_pin_on_device( ButtonRequestType.PinEntry, raise_on_cancel=PinCancelled, ) - return result # type: ignore ["UiResult" is incompatible with "str"] + return result # type: ignore [Expression of type "Coroutine[Any, Any, str | UiResult]" is incompatible with return type "Awaitable[str]"] async def confirm_reenter_pin(is_wipe_code: bool = False) -> None: diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 3251804417..f723710a19 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1258,7 +1258,7 @@ def pin_mismatch_popup(is_wipe_code: bool = False) -> Awaitable[None]: TR.buttons__check_again, br_code=BR_CODE_OTHER, ) - return layout # type: ignore ["UiResult" is incompatible with "None"] + return layout # type: ignore [Expression of type "Awaitable[UiResult]" is incompatible with return type "Awaitable[None]"] def wipe_code_same_as_pin_popup() -> Awaitable[None]: diff --git a/core/src/trezor/ui/layouts/tr/reset.py b/core/src/trezor/ui/layouts/tr/reset.py index 0a5317c1ff..326f703752 100644 --- a/core/src/trezor/ui/layouts/tr/reset.py +++ b/core/src/trezor/ui/layouts/tr/reset.py @@ -1,4 +1,4 @@ -from typing import Awaitable, Sequence +from typing import TYPE_CHECKING import trezorui2 from trezor import TR @@ -9,6 +9,11 @@ from . import confirm_action, show_success, show_warning CONFIRMED = trezorui2.CONFIRMED # global_import_cache +if TYPE_CHECKING: + from typing import Awaitable, Sequence + + pass + async def show_share_words( share_words: Sequence[str],