mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-21 23:18:13 +00:00
style(python): modernize type annotations in cli/device.py
This commit is contained in:
parent
92e8bf5e60
commit
32d26933a6
@ -13,11 +13,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the License along with this library.
|
# You should have received a copy of the License along with this library.
|
||||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import secrets
|
import secrets
|
||||||
import sys
|
import sys
|
||||||
from typing import TYPE_CHECKING, BinaryIO, Optional, Sequence, Tuple
|
import typing as t
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import requests
|
import requests
|
||||||
@ -25,7 +26,7 @@ import requests
|
|||||||
from .. import debuglink, device, exceptions, messages, ui
|
from .. import debuglink, device, exceptions, messages, ui
|
||||||
from . import ChoiceType, with_client
|
from . import ChoiceType, with_client
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
from ..client import TrezorClient
|
from ..client import TrezorClient
|
||||||
from ..protobuf import MessageType
|
from ..protobuf import MessageType
|
||||||
from . import TrezorConnection
|
from . import TrezorConnection
|
||||||
@ -104,7 +105,7 @@ def wipe(client: "TrezorClient", bootloader: bool) -> str:
|
|||||||
@with_client
|
@with_client
|
||||||
def load(
|
def load(
|
||||||
client: "TrezorClient",
|
client: "TrezorClient",
|
||||||
mnemonic: Sequence[str],
|
mnemonic: t.Sequence[str],
|
||||||
pin: str,
|
pin: str,
|
||||||
passphrase_protection: bool,
|
passphrase_protection: bool,
|
||||||
label: str,
|
label: str,
|
||||||
@ -169,7 +170,7 @@ def recover(
|
|||||||
expand: bool,
|
expand: bool,
|
||||||
pin_protection: bool,
|
pin_protection: bool,
|
||||||
passphrase_protection: bool,
|
passphrase_protection: bool,
|
||||||
label: Optional[str],
|
label: str | None,
|
||||||
u2f_counter: int,
|
u2f_counter: int,
|
||||||
input_method: messages.RecoveryDeviceInputMethod,
|
input_method: messages.RecoveryDeviceInputMethod,
|
||||||
dry_run: bool,
|
dry_run: bool,
|
||||||
@ -218,10 +219,10 @@ def recover(
|
|||||||
def setup(
|
def setup(
|
||||||
client: "TrezorClient",
|
client: "TrezorClient",
|
||||||
show_entropy: bool,
|
show_entropy: bool,
|
||||||
strength: Optional[int],
|
strength: int | None,
|
||||||
passphrase_protection: bool,
|
passphrase_protection: bool,
|
||||||
pin_protection: bool,
|
pin_protection: bool,
|
||||||
label: Optional[str],
|
label: str | None,
|
||||||
u2f_counter: int,
|
u2f_counter: int,
|
||||||
skip_backup: bool,
|
skip_backup: bool,
|
||||||
no_backup: bool,
|
no_backup: bool,
|
||||||
@ -263,8 +264,8 @@ def setup(
|
|||||||
@with_client
|
@with_client
|
||||||
def backup(
|
def backup(
|
||||||
client: "TrezorClient",
|
client: "TrezorClient",
|
||||||
group_threshold: Optional[int] = None,
|
group_threshold: int | None = None,
|
||||||
groups: Sequence[Tuple[int, int]] = (),
|
groups: t.Sequence[tuple[int, int]] = (),
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Perform device seed backup."""
|
"""Perform device seed backup."""
|
||||||
|
|
||||||
@ -331,9 +332,7 @@ def unlock_bootloader(client: "TrezorClient") -> str:
|
|||||||
help="Dialog expiry in seconds.",
|
help="Dialog expiry in seconds.",
|
||||||
)
|
)
|
||||||
@with_client
|
@with_client
|
||||||
def set_busy(
|
def set_busy(client: "TrezorClient", enable: bool | None, expiry: int | None) -> str:
|
||||||
client: "TrezorClient", enable: Optional[bool], expiry: Optional[int]
|
|
||||||
) -> str:
|
|
||||||
"""Show a "Do not disconnect" dialog."""
|
"""Show a "Do not disconnect" dialog."""
|
||||||
if enable is False:
|
if enable is False:
|
||||||
return device.set_busy(client, None)
|
return device.set_busy(client, None)
|
||||||
@ -369,10 +368,10 @@ PUBKEY_WHITELIST_URL_TEMPLATE = (
|
|||||||
@with_client
|
@with_client
|
||||||
def authenticate(
|
def authenticate(
|
||||||
client: "TrezorClient",
|
client: "TrezorClient",
|
||||||
hex_challenge: Optional[str],
|
hex_challenge: str | None,
|
||||||
root: Optional[BinaryIO],
|
root: t.BinaryIO | None,
|
||||||
raw: Optional[bool],
|
raw: bool | None,
|
||||||
skip_whitelist: Optional[bool],
|
skip_whitelist: bool | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Verify the authenticity of the device.
|
"""Verify the authenticity of the device.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user