mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
refactor(core): enable mypy for apps.management
This commit is contained in:
parent
e57027fc5c
commit
31052007ff
@ -109,6 +109,7 @@ mypy:
|
||||
src/main.py \
|
||||
src/apps/bitcoin \
|
||||
src/apps/cardano \
|
||||
src/apps/management \
|
||||
src/apps/misc \
|
||||
src/apps/webauthn \
|
||||
src/trezor/ui
|
||||
|
@ -3,8 +3,11 @@ from storage.device import set_flags
|
||||
from trezor import wire
|
||||
from trezor.messages import Success
|
||||
|
||||
if False:
|
||||
from trezor.messages import ApplyFlags
|
||||
|
||||
async def apply_flags(ctx, msg):
|
||||
|
||||
async def apply_flags(ctx: wire.GenericContext, msg: ApplyFlags) -> Success:
|
||||
if not storage.device.is_initialized():
|
||||
raise wire.NotInitialized("Device is not initialized")
|
||||
set_flags(msg.flags)
|
||||
|
@ -33,7 +33,7 @@ def validate_homescreen(homescreen: bytes) -> None:
|
||||
raise wire.DataError("Homescreen must be full-color TOIF image")
|
||||
|
||||
|
||||
async def apply_settings(ctx: wire.Context, msg: ApplySettings):
|
||||
async def apply_settings(ctx: wire.Context, msg: ApplySettings) -> Success:
|
||||
if not storage.device.is_initialized():
|
||||
raise wire.NotInitialized("Device is not initialized")
|
||||
if (
|
||||
@ -99,7 +99,7 @@ async def apply_settings(ctx: wire.Context, msg: ApplySettings):
|
||||
return Success(message="Settings applied")
|
||||
|
||||
|
||||
async def require_confirm_change_homescreen(ctx):
|
||||
async def require_confirm_change_homescreen(ctx: wire.GenericContext) -> None:
|
||||
await confirm_action(
|
||||
ctx,
|
||||
"set_homescreen",
|
||||
@ -109,7 +109,7 @@ async def require_confirm_change_homescreen(ctx):
|
||||
)
|
||||
|
||||
|
||||
async def require_confirm_change_label(ctx, label):
|
||||
async def require_confirm_change_label(ctx: wire.GenericContext, label: str) -> None:
|
||||
await confirm_action(
|
||||
ctx,
|
||||
"set_label",
|
||||
@ -120,7 +120,9 @@ async def require_confirm_change_label(ctx, label):
|
||||
)
|
||||
|
||||
|
||||
async def require_confirm_change_passphrase(ctx, use):
|
||||
async def require_confirm_change_passphrase(
|
||||
ctx: wire.GenericContext, use: bool
|
||||
) -> None:
|
||||
if use:
|
||||
description = "Do you really want to enable passphrase encryption?"
|
||||
else:
|
||||
@ -135,8 +137,8 @@ async def require_confirm_change_passphrase(ctx, use):
|
||||
|
||||
|
||||
async def require_confirm_change_passphrase_source(
|
||||
ctx, passphrase_always_on_device: bool
|
||||
):
|
||||
ctx: wire.GenericContext, passphrase_always_on_device: bool
|
||||
) -> None:
|
||||
if passphrase_always_on_device:
|
||||
description = "Do you really want to enter passphrase always on the device?"
|
||||
else:
|
||||
@ -150,7 +152,9 @@ async def require_confirm_change_passphrase_source(
|
||||
)
|
||||
|
||||
|
||||
async def require_confirm_change_display_rotation(ctx, rotation):
|
||||
async def require_confirm_change_display_rotation(
|
||||
ctx: wire.GenericContext, rotation: int
|
||||
) -> None:
|
||||
if rotation == 0:
|
||||
label = "north"
|
||||
elif rotation == 90:
|
||||
@ -171,7 +175,9 @@ async def require_confirm_change_display_rotation(ctx, rotation):
|
||||
)
|
||||
|
||||
|
||||
async def require_confirm_change_autolock_delay(ctx, delay_ms):
|
||||
async def require_confirm_change_autolock_delay(
|
||||
ctx: wire.GenericContext, delay_ms: int
|
||||
) -> None:
|
||||
await confirm_action(
|
||||
ctx,
|
||||
"set_autolock_delay",
|
||||
@ -182,7 +188,9 @@ async def require_confirm_change_autolock_delay(ctx, delay_ms):
|
||||
)
|
||||
|
||||
|
||||
async def require_confirm_safety_checks(ctx, level: SafetyCheckLevel) -> None:
|
||||
async def require_confirm_safety_checks(
|
||||
ctx: wire.GenericContext, level: SafetyCheckLevel
|
||||
) -> None:
|
||||
if level == SafetyCheckLevel.PromptAlways:
|
||||
await confirm_action(
|
||||
ctx,
|
||||
@ -220,7 +228,9 @@ async def require_confirm_safety_checks(ctx, level: SafetyCheckLevel) -> None:
|
||||
raise ValueError # enum value out of range
|
||||
|
||||
|
||||
async def require_confirm_experimental_features(ctx, enable: bool) -> None:
|
||||
async def require_confirm_experimental_features(
|
||||
ctx: wire.GenericContext, enable: bool
|
||||
) -> None:
|
||||
if enable:
|
||||
await confirm_action(
|
||||
ctx,
|
||||
|
@ -7,14 +7,19 @@ from apps.common import mnemonic
|
||||
|
||||
from .reset_device import backup_seed, layout
|
||||
|
||||
if False:
|
||||
from trezor.messages import BackupDevice
|
||||
|
||||
async def backup_device(ctx, msg):
|
||||
|
||||
async def backup_device(ctx: wire.Context, msg: BackupDevice) -> Success:
|
||||
if not storage.device.is_initialized():
|
||||
raise wire.NotInitialized("Device is not initialized")
|
||||
if not storage.device.needs_backup():
|
||||
raise wire.ProcessError("Seed already backed up")
|
||||
|
||||
mnemonic_secret, mnemonic_type = mnemonic.get()
|
||||
if mnemonic_secret is None:
|
||||
raise RuntimeError
|
||||
|
||||
storage.device.set_unfinished_backup(True)
|
||||
storage.device.set_backed_up()
|
||||
|
@ -11,6 +11,8 @@ from apps.common.request_pin import (
|
||||
)
|
||||
|
||||
if False:
|
||||
from typing import Awaitable
|
||||
|
||||
from trezor.messages import ChangePin
|
||||
|
||||
|
||||
@ -57,7 +59,7 @@ async def change_pin(ctx: wire.Context, msg: ChangePin) -> Success:
|
||||
return Success(message=msg_wire)
|
||||
|
||||
|
||||
def require_confirm_change_pin(ctx: wire.Context, msg: ChangePin) -> None:
|
||||
def require_confirm_change_pin(ctx: wire.Context, msg: ChangePin) -> Awaitable[None]:
|
||||
has_pin = config.has_pin()
|
||||
|
||||
if msg.remove and has_pin: # removing pin
|
||||
|
@ -6,8 +6,12 @@ from trezor.ui.layouts import confirm_action
|
||||
|
||||
from .apply_settings import reload_settings_from_storage
|
||||
|
||||
if False:
|
||||
from trezor import wire
|
||||
from trezor.messages import WipeDevice
|
||||
|
||||
async def wipe_device(ctx, msg):
|
||||
|
||||
async def wipe_device(ctx: wire.GenericContext, msg: WipeDevice) -> Success:
|
||||
await confirm_action(
|
||||
ctx,
|
||||
"confirm_wipe",
|
||||
|
@ -1093,7 +1093,7 @@ async def request_passphrase_on_device(ctx: wire.GenericContext, max_len: int) -
|
||||
async def request_pin_on_device(
|
||||
ctx: wire.GenericContext,
|
||||
prompt: str,
|
||||
attempts_remaining: int,
|
||||
attempts_remaining: Optional[int],
|
||||
allow_cancel: bool,
|
||||
) -> str:
|
||||
await button_request(ctx, "pin_device", code=ButtonRequestType.PinEntry)
|
||||
|
Loading…
Reference in New Issue
Block a user