From 015c47d5640350576784c3d871fd53cb1f611638 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 23 Jun 2021 10:02:09 +0200 Subject: [PATCH] chore(core): export PropertyType to fix mypy errors --- core/src/apps/cardano/layout.py | 6 ++++-- core/src/trezor/ui/layouts/common.py | 4 +++- core/src/trezor/ui/layouts/tt.py | 11 +++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/apps/cardano/layout.py b/core/src/apps/cardano/layout.py index 9ed33777e..69f37f5a7 100644 --- a/core/src/apps/cardano/layout.py +++ b/core/src/apps/cardano/layout.py @@ -37,6 +37,8 @@ if False: CardanoAssetGroupType, ) + from trezor.ui.layouts import PropertyType + ADDRESS_TYPE_NAMES = { CardanoAddressType.BYRON: "Legacy", @@ -217,7 +219,7 @@ async def confirm_transaction( validity_interval_start: int | None, is_network_id_verifiable: bool, ) -> None: - props = [ + props: list[PropertyType] = [ ("Transaction amount:", format_coin_amount(amount)), ("Transaction fee:", format_coin_amount(fee)), ] @@ -467,7 +469,7 @@ async def show_warning_address_foreign_staking_key( staking_account_path: list[int], staking_key_hash: bytes | None, ) -> None: - props: list[tuple[str, str | None]] = [ + props: list[PropertyType] = [ ( "Stake rights associated with this address do not match your account %s:" % format_account_number(account_path), diff --git a/core/src/trezor/ui/layouts/common.py b/core/src/trezor/ui/layouts/common.py index 4b11dc008..e5dd48352 100644 --- a/core/src/trezor/ui/layouts/common.py +++ b/core/src/trezor/ui/layouts/common.py @@ -3,9 +3,11 @@ from trezor.enums import ButtonRequestType from trezor.messages import ButtonAck, ButtonRequest if False: - from typing import Any, Awaitable + from typing import Any, Awaitable, Optional, Tuple, Type, Union LayoutType = Awaitable[Any] + PropertyType = Tuple[Optional[str], Union[str, bytes, None]] + ExceptionType = Union[BaseException, Type[BaseException]] if __debug__: diff --git a/core/src/trezor/ui/layouts/tt.py b/core/src/trezor/ui/layouts/tt.py index b26a16d3c..dd67a0567 100644 --- a/core/src/trezor/ui/layouts/tt.py +++ b/core/src/trezor/ui/layouts/tt.py @@ -1,5 +1,4 @@ from micropython import const - from ubinascii import hexlify from trezor import ui, wire @@ -14,11 +13,11 @@ from ..components.common.confirm import is_confirmed, raise_if_cancelled from ..components.tt.button import ButtonCancel, ButtonDefault from ..components.tt.confirm import Confirm, HoldToConfirm from ..components.tt.scroll import ( + PAGEBREAK, + PAGINATED_LINE_WIDTH, Paginated, paginate_paragraphs, paginate_text, - PAGINATED_LINE_WIDTH, - PAGEBREAK, ) from ..components.tt.text import Span, Text from ..constants.tt import ( @@ -36,15 +35,11 @@ if False: Awaitable, Iterator, NoReturn, - Optional, Sequence, Tuple, - Type, - Union, ) - ExceptionType = Union[BaseException, Type[BaseException]] - PropertyType = Tuple[Optional[str], Union[str, bytes, None]] + from .common import PropertyType, ExceptionType __all__ = (