mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-29 16:51:30 +00:00
style(python): improve type hints for input flows
This commit is contained in:
parent
6a5836708f
commit
79cc7a9693
@ -67,6 +67,8 @@ if TYPE_CHECKING:
|
||||
wait: bool | None = None,
|
||||
) -> "LayoutContent": ...
|
||||
|
||||
InputFlowType = Generator[None, messages.ButtonRequest, None]
|
||||
|
||||
|
||||
EXPECTED_RESPONSES_CONTEXT_LINES = 3
|
||||
|
||||
@ -1108,7 +1110,7 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
return msg
|
||||
|
||||
def set_input_flow(
|
||||
self, input_flow: Generator[None, messages.ButtonRequest | None, None]
|
||||
self, input_flow: InputFlowType | Callable[[], InputFlowType]
|
||||
) -> None:
|
||||
"""Configure a sequence of input events for the current with-block.
|
||||
|
||||
@ -1142,7 +1144,7 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
if not hasattr(input_flow, "send"):
|
||||
raise RuntimeError("input_flow should be a generator function")
|
||||
self.ui.input_flow = input_flow
|
||||
input_flow.send(None) # start the generator
|
||||
next(input_flow) # start the generator
|
||||
|
||||
def watch_layout(self, watch: bool = True) -> None:
|
||||
"""Enable or disable watching layout changes.
|
||||
@ -1190,7 +1192,8 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
input_flow.throw(exc_type, value, traceback)
|
||||
|
||||
def set_expected_responses(
|
||||
self, expected: list[Union["ExpectedMessage", Tuple[bool, "ExpectedMessage"]]]
|
||||
self,
|
||||
expected: Sequence[Union["ExpectedMessage", Tuple[bool, "ExpectedMessage"]]],
|
||||
) -> None:
|
||||
"""Set a sequence of expected responses to client calls.
|
||||
|
||||
|
@ -12,7 +12,7 @@ input flow details.
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from typing import Callable, Generator
|
||||
from typing import Callable, Generator, Sequence
|
||||
|
||||
from trezorlib import messages
|
||||
from trezorlib.debuglink import DebugLink, LayoutContent, LayoutType
|
||||
@ -2049,7 +2049,7 @@ class InputFlowSlip39BasicRecoveryDryRun(InputFlowBase):
|
||||
|
||||
|
||||
class InputFlowSlip39BasicRecovery(InputFlowBase):
|
||||
def __init__(self, client: Client, shares: list[str], pin: str | None = None):
|
||||
def __init__(self, client: Client, shares: Sequence[str], pin: str | None = None):
|
||||
super().__init__(client)
|
||||
self.shares = shares
|
||||
self.pin = pin
|
||||
|
@ -301,7 +301,7 @@ class RecoveryFlow:
|
||||
|
||||
def input_all_slip39_shares(
|
||||
self,
|
||||
shares: list[str],
|
||||
shares: t.Sequence[str],
|
||||
has_groups: bool = False,
|
||||
click_info: bool = False,
|
||||
) -> BRGeneratorType:
|
||||
|
Loading…
Reference in New Issue
Block a user