mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-12 00:10:58 +00:00
style(core): mypy: disable implicit Optional for function arguments
https://www.python.org/dev/peps/pep-0484/#union-types
This commit is contained in:
parent
bb30f5026c
commit
8b3ac659a0
@ -47,7 +47,7 @@ STATIC secbool wrapped_ui_wait_callback(uint32_t wait, uint32_t progress,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// def init(
|
/// def init(
|
||||||
/// ui_wait_callback: Callable[[int, int, str], bool] = None
|
/// ui_wait_callback: Optional[Callable[[int, int, str], bool]] = None
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Initializes the storage. Must be called before any other method is
|
/// Initializes the storage. Must be called before any other method is
|
||||||
|
@ -49,7 +49,12 @@ typedef struct _mp_obj_AES_t {
|
|||||||
uint8_t iv[AES_BLOCK_SIZE];
|
uint8_t iv[AES_BLOCK_SIZE];
|
||||||
} mp_obj_AES_t;
|
} mp_obj_AES_t;
|
||||||
|
|
||||||
/// def __init__(self, mode: int, key: bytes, iv: bytes = None) -> None:
|
/// def __init__(
|
||||||
|
/// self,
|
||||||
|
/// mode: int,
|
||||||
|
/// key: bytes,
|
||||||
|
/// iv: Optional[bytes] = None,
|
||||||
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Initialize AES context.
|
/// Initialize AES context.
|
||||||
/// """
|
/// """
|
||||||
|
@ -49,9 +49,9 @@ STATIC const mp_obj_type_t mod_trezorcrypto_HDNode_type;
|
|||||||
/// fingerprint: int,
|
/// fingerprint: int,
|
||||||
/// child_num: int,
|
/// child_num: int,
|
||||||
/// chain_code: bytes,
|
/// chain_code: bytes,
|
||||||
/// private_key: bytes = None,
|
/// private_key: Optional[bytes] = None,
|
||||||
/// public_key: bytes = None,
|
/// public_key: Optional[bytes] = None,
|
||||||
/// curve_name: str = None,
|
/// curve_name: Optional[str] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// """
|
/// """
|
||||||
|
@ -125,7 +125,7 @@ STATIC void wrapped_ui_wait_callback(uint32_t current, uint32_t total) {
|
|||||||
/// def seed(
|
/// def seed(
|
||||||
/// mnemonic: str,
|
/// mnemonic: str,
|
||||||
/// passphrase: str,
|
/// passphrase: str,
|
||||||
/// callback: Callable[[int, int], None] = None,
|
/// callback: Optional[Callable[[int, int], None]] = None,
|
||||||
/// ) -> bytes:
|
/// ) -> bytes:
|
||||||
/// """
|
/// """
|
||||||
/// Generate seed from mnemonic and passphrase.
|
/// Generate seed from mnemonic and passphrase.
|
||||||
|
@ -37,7 +37,7 @@ typedef struct _mp_obj_Blake256_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Blake256_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Blake256_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None) -> None:
|
/// def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -41,10 +41,10 @@ STATIC mp_obj_t mod_trezorcrypto_Blake2b_update(mp_obj_t self, mp_obj_t data);
|
|||||||
|
|
||||||
/// def __init__(
|
/// def __init__(
|
||||||
/// self,
|
/// self,
|
||||||
/// data: bytes = None,
|
/// data: Optional[bytes] = None,
|
||||||
/// outlen: int = blake2b.digest_size,
|
/// outlen: int = blake2b.digest_size,
|
||||||
/// key: bytes = None,
|
/// key: Optional[bytes] = None,
|
||||||
/// personal: bytes = None,
|
/// personal: Optional[bytes] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
|
@ -41,10 +41,10 @@ STATIC mp_obj_t mod_trezorcrypto_Blake2s_update(mp_obj_t self, mp_obj_t data);
|
|||||||
|
|
||||||
/// def __init__(
|
/// def __init__(
|
||||||
/// self,
|
/// self,
|
||||||
/// data: bytes = None,
|
/// data: Optional[bytes] = None,
|
||||||
/// outlen: int = blake2s.digest_size,
|
/// outlen: int = blake2s.digest_size,
|
||||||
/// key: bytes = None,
|
/// key: Optional[bytes] = None,
|
||||||
/// personal: bytes = None,
|
/// personal: Optional[bytes] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
|
@ -41,7 +41,7 @@ typedef struct _mp_obj_Groestl512_t {
|
|||||||
STATIC mp_obj_t mod_trezorcrypto_Groestl512_update(mp_obj_t self,
|
STATIC mp_obj_t mod_trezorcrypto_Groestl512_update(mp_obj_t self,
|
||||||
mp_obj_t data);
|
mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None) -> None:
|
/// def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -48,7 +48,7 @@ STATIC mp_obj_t mod_trezorcrypto_Hmac_update(mp_obj_t self, mp_obj_t data);
|
|||||||
/// self,
|
/// self,
|
||||||
/// hashtype: int,
|
/// hashtype: int,
|
||||||
/// key: bytes,
|
/// key: bytes,
|
||||||
/// message: bytes = None
|
/// message: Optional[bytes] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Create a HMAC context.
|
/// Create a HMAC context.
|
||||||
|
@ -49,7 +49,7 @@ STATIC mp_obj_t mod_trezorcrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t data);
|
|||||||
/// prf: int,
|
/// prf: int,
|
||||||
/// password: bytes,
|
/// password: bytes,
|
||||||
/// salt: bytes,
|
/// salt: bytes,
|
||||||
/// iterations: int = None,
|
/// iterations: Optional[int] = None,
|
||||||
/// blocknr: int = 1,
|
/// blocknr: int = 1,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
|
@ -37,7 +37,7 @@ typedef struct _mp_obj_Ripemd160_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None) -> None:
|
/// def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -113,7 +113,7 @@ enum {
|
|||||||
/// secret_key: bytes,
|
/// secret_key: bytes,
|
||||||
/// digest: bytes,
|
/// digest: bytes,
|
||||||
/// compressed: bool = True,
|
/// compressed: bool = True,
|
||||||
/// canonical: int = None,
|
/// canonical: Optional[int] = None,
|
||||||
/// ) -> bytes:
|
/// ) -> bytes:
|
||||||
/// """
|
/// """
|
||||||
/// Uses secret key to produce the signature of the digest.
|
/// Uses secret key to produce the signature of the digest.
|
||||||
|
@ -37,7 +37,7 @@ typedef struct _mp_obj_Sha1_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Sha1_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Sha1_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None) -> None:
|
/// def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -37,7 +37,7 @@ typedef struct _mp_obj_Sha256_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Sha256_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Sha256_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None) -> None:
|
/// def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -38,7 +38,11 @@ typedef struct _mp_obj_Sha3_256_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None, keccak: bool = False) -> None:
|
/// def __init__(
|
||||||
|
/// self,
|
||||||
|
/// data: Optional[bytes] = None,
|
||||||
|
/// keccak: bool = False,
|
||||||
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -38,7 +38,11 @@ typedef struct _mp_obj_Sha3_512_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None, keccak: bool = False) -> None:
|
/// def __init__(
|
||||||
|
/// self,
|
||||||
|
/// data: Optional[bytes] = None,
|
||||||
|
/// keccak: bool = False,
|
||||||
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -37,7 +37,7 @@ typedef struct _mp_obj_Sha512_t {
|
|||||||
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_Sha512_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_trezorcrypto_Sha512_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def __init__(self, data: bytes = None) -> None:
|
/// def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Creates a hash context object.
|
/// Creates a hash context object.
|
||||||
/// """
|
/// """
|
||||||
|
@ -93,8 +93,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_bar_obj, 6, 6,
|
|||||||
/// w: int,
|
/// w: int,
|
||||||
/// h: int,
|
/// h: int,
|
||||||
/// fgcolor: int,
|
/// fgcolor: int,
|
||||||
/// bgcolor: int = None,
|
/// bgcolor: Optional[int] = None,
|
||||||
/// radius: int = None,
|
/// radius: Optional[int] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Renders a rounded bar at position (x,y = upper left corner) with width w
|
/// Renders a rounded bar at position (x,y = upper left corner) with width w
|
||||||
@ -243,8 +243,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_icon_obj, 6, 6,
|
|||||||
/// yoffset: int,
|
/// yoffset: int,
|
||||||
/// fgcolor: int,
|
/// fgcolor: int,
|
||||||
/// bgcolor: int,
|
/// bgcolor: int,
|
||||||
/// icon: bytes = None,
|
/// icon: Optional[bytes] = None,
|
||||||
/// iconfgcolor: int = None,
|
/// iconfgcolor: Optional[int] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Renders a rotating loader graphic.
|
/// Renders a rotating loader graphic.
|
||||||
@ -317,8 +317,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorui_Display_print_obj,
|
|||||||
/// font: int,
|
/// font: int,
|
||||||
/// fgcolor: int,
|
/// fgcolor: int,
|
||||||
/// bgcolor: int,
|
/// bgcolor: int,
|
||||||
/// text_offset: int = None,
|
/// text_offset: Optional[int] = None,
|
||||||
/// text_len: int = None,
|
/// text_len: Optional[int] = None,
|
||||||
/// ) -> None:
|
/// ) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Renders left-aligned text at position (x,y) where x is left position and
|
/// Renders left-aligned text at position (x,y) where x is left position and
|
||||||
@ -421,8 +421,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_text_right_obj,
|
|||||||
/// self,
|
/// self,
|
||||||
/// text: str,
|
/// text: str,
|
||||||
/// font: int,
|
/// font: int,
|
||||||
/// text_offset: int = None,
|
/// text_offset: Optional[int] = None,
|
||||||
/// text_len: int = None,
|
/// text_len: Optional[int] = None,
|
||||||
/// ) -> int:
|
/// ) -> int:
|
||||||
/// """
|
/// """
|
||||||
/// Returns a width of text in pixels. Font font is used for rendering.
|
/// Returns a width of text in pixels. Font font is used for rendering.
|
||||||
@ -499,7 +499,7 @@ STATIC mp_obj_t mod_trezorui_Display_qrcode(size_t n_args,
|
|||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_qrcode_obj, 5,
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_qrcode_obj, 5,
|
||||||
5, mod_trezorui_Display_qrcode);
|
5, mod_trezorui_Display_qrcode);
|
||||||
|
|
||||||
/// def orientation(self, degrees: int = None) -> int:
|
/// def orientation(self, degrees: Optional[int] = None) -> int:
|
||||||
/// """
|
/// """
|
||||||
/// Sets display orientation to 0, 90, 180 or 270 degrees.
|
/// Sets display orientation to 0, 90, 180 or 270 degrees.
|
||||||
/// Everything needs to be redrawn again when this function is used.
|
/// Everything needs to be redrawn again when this function is used.
|
||||||
@ -524,7 +524,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_orientation_obj,
|
|||||||
1, 2,
|
1, 2,
|
||||||
mod_trezorui_Display_orientation);
|
mod_trezorui_Display_orientation);
|
||||||
|
|
||||||
/// def backlight(self, val: int = None) -> int:
|
/// def backlight(self, val: Optional[int] = None) -> int:
|
||||||
/// """
|
/// """
|
||||||
/// Sets backlight intensity to the value specified in val.
|
/// Sets backlight intensity to the value specified in val.
|
||||||
/// Call without the val parameter to just perform the read of the value.
|
/// Call without the val parameter to just perform the read of the value.
|
||||||
@ -547,7 +547,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_backlight_obj,
|
|||||||
1, 2,
|
1, 2,
|
||||||
mod_trezorui_Display_backlight);
|
mod_trezorui_Display_backlight);
|
||||||
|
|
||||||
/// def offset(self, xy: Tuple[int, int] = None) -> Tuple[int, int]:
|
/// def offset(self, xy: Optional[Tuple[int, int]] = None) -> Tuple[int, int]:
|
||||||
/// """
|
/// """
|
||||||
/// Sets offset (x, y) for all subsequent drawing calls.
|
/// Sets offset (x, y) for all subsequent drawing calls.
|
||||||
/// Call without the xy parameter to just perform the read of the value.
|
/// Call without the xy parameter to just perform the read of the value.
|
||||||
|
@ -62,7 +62,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorutils_consteq_obj,
|
|||||||
/// dst_ofs: int,
|
/// dst_ofs: int,
|
||||||
/// src: bytes,
|
/// src: bytes,
|
||||||
/// src_ofs: int,
|
/// src_ofs: int,
|
||||||
/// n: int = None,
|
/// n: Optional[int] = None,
|
||||||
/// ) -> int:
|
/// ) -> int:
|
||||||
/// """
|
/// """
|
||||||
/// Copies at most `n` bytes from `src` at offset `src_ofs` to
|
/// Copies at most `n` bytes from `src` at offset `src_ofs` to
|
||||||
@ -99,7 +99,7 @@ STATIC mp_obj_t mod_trezorutils_memcpy(size_t n_args, const mp_obj_t *args) {
|
|||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_memcpy_obj, 4, 5,
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_memcpy_obj, 4, 5,
|
||||||
mod_trezorutils_memcpy);
|
mod_trezorutils_memcpy);
|
||||||
|
|
||||||
/// def halt(msg: str = None) -> None:
|
/// def halt(msg: Optional[str] = None) -> None:
|
||||||
/// """
|
/// """
|
||||||
/// Halts execution.
|
/// Halts execution.
|
||||||
/// """
|
/// """
|
||||||
|
@ -3,7 +3,7 @@ from typing import *
|
|||||||
|
|
||||||
# extmod/modtrezorconfig/modtrezorconfig.c
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
||||||
def init(
|
def init(
|
||||||
ui_wait_callback: Callable[[int, int, str], bool] = None
|
ui_wait_callback: Optional[Callable[[int, int, str], bool]] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initializes the storage. Must be called before any other method is
|
Initializes the storage. Must be called before any other method is
|
||||||
|
@ -12,7 +12,12 @@ class aes:
|
|||||||
OFB: int
|
OFB: int
|
||||||
CTR: int
|
CTR: int
|
||||||
|
|
||||||
def __init__(self, mode: int, key: bytes, iv: bytes = None) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
mode: int,
|
||||||
|
key: bytes,
|
||||||
|
iv: Optional[bytes] = None,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize AES context.
|
Initialize AES context.
|
||||||
"""
|
"""
|
||||||
@ -36,7 +41,7 @@ class blake256:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None) -> None:
|
def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -62,10 +67,10 @@ class blake2b:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data: bytes = None,
|
data: Optional[bytes] = None,
|
||||||
outlen: int = blake2b.digest_size,
|
outlen: int = blake2b.digest_size,
|
||||||
key: bytes = None,
|
key: Optional[bytes] = None,
|
||||||
personal: bytes = None,
|
personal: Optional[bytes] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
@ -92,10 +97,10 @@ class blake2s:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data: bytes = None,
|
data: Optional[bytes] = None,
|
||||||
outlen: int = blake2s.digest_size,
|
outlen: int = blake2s.digest_size,
|
||||||
key: bytes = None,
|
key: Optional[bytes] = None,
|
||||||
personal: bytes = None,
|
personal: Optional[bytes] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
@ -157,7 +162,7 @@ class groestl512:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None) -> None:
|
def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -185,7 +190,7 @@ class hmac:
|
|||||||
self,
|
self,
|
||||||
hashtype: int,
|
hashtype: int,
|
||||||
key: bytes,
|
key: bytes,
|
||||||
message: bytes = None
|
message: Optional[bytes] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Create a HMAC context.
|
Create a HMAC context.
|
||||||
@ -215,7 +220,7 @@ class pbkdf2:
|
|||||||
prf: int,
|
prf: int,
|
||||||
password: bytes,
|
password: bytes,
|
||||||
salt: bytes,
|
salt: bytes,
|
||||||
iterations: int = None,
|
iterations: Optional[int] = None,
|
||||||
blocknr: int = 1,
|
blocknr: int = 1,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
@ -241,7 +246,7 @@ class ripemd160:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None) -> None:
|
def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -265,7 +270,7 @@ class sha1:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None) -> None:
|
def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -289,7 +294,7 @@ class sha256:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None) -> None:
|
def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -313,7 +318,11 @@ class sha3_256:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None, keccak: bool = False) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
data: Optional[bytes] = None,
|
||||||
|
keccak: bool = False,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -342,7 +351,11 @@ class sha3_512:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None, keccak: bool = False) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
data: Optional[bytes] = None,
|
||||||
|
keccak: bool = False,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
@ -371,7 +384,7 @@ class sha512:
|
|||||||
block_size: int
|
block_size: int
|
||||||
digest_size: int
|
digest_size: int
|
||||||
|
|
||||||
def __init__(self, data: bytes = None) -> None:
|
def __init__(self, data: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a hash context object.
|
Creates a hash context object.
|
||||||
"""
|
"""
|
||||||
|
@ -13,9 +13,9 @@ class HDNode:
|
|||||||
fingerprint: int,
|
fingerprint: int,
|
||||||
child_num: int,
|
child_num: int,
|
||||||
chain_code: bytes,
|
chain_code: bytes,
|
||||||
private_key: bytes = None,
|
private_key: Optional[bytes] = None,
|
||||||
public_key: bytes = None,
|
public_key: Optional[bytes] = None,
|
||||||
curve_name: str = None,
|
curve_name: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
@ -42,7 +42,7 @@ def check(mnemonic: str) -> bool:
|
|||||||
def seed(
|
def seed(
|
||||||
mnemonic: str,
|
mnemonic: str,
|
||||||
passphrase: str,
|
passphrase: str,
|
||||||
callback: Callable[[int, int], None] = None,
|
callback: Optional[Callable[[int, int], None]] = None,
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
"""
|
"""
|
||||||
Generate seed from mnemonic and passphrase.
|
Generate seed from mnemonic and passphrase.
|
||||||
|
@ -22,7 +22,7 @@ def sign(
|
|||||||
secret_key: bytes,
|
secret_key: bytes,
|
||||||
digest: bytes,
|
digest: bytes,
|
||||||
compressed: bool = True,
|
compressed: bool = True,
|
||||||
canonical: int = None,
|
canonical: Optional[int] = None,
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
"""
|
"""
|
||||||
Uses secret key to produce the signature of the digest.
|
Uses secret key to produce the signature of the digest.
|
||||||
|
@ -40,8 +40,8 @@ class Display:
|
|||||||
w: int,
|
w: int,
|
||||||
h: int,
|
h: int,
|
||||||
fgcolor: int,
|
fgcolor: int,
|
||||||
bgcolor: int = None,
|
bgcolor: Optional[int] = None,
|
||||||
radius: int = None,
|
radius: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Renders a rounded bar at position (x,y = upper left corner) with width w
|
Renders a rounded bar at position (x,y = upper left corner) with width w
|
||||||
@ -89,8 +89,8 @@ class Display:
|
|||||||
yoffset: int,
|
yoffset: int,
|
||||||
fgcolor: int,
|
fgcolor: int,
|
||||||
bgcolor: int,
|
bgcolor: int,
|
||||||
icon: bytes = None,
|
icon: Optional[bytes] = None,
|
||||||
iconfgcolor: int = None,
|
iconfgcolor: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Renders a rotating loader graphic.
|
Renders a rotating loader graphic.
|
||||||
@ -114,8 +114,8 @@ class Display:
|
|||||||
font: int,
|
font: int,
|
||||||
fgcolor: int,
|
fgcolor: int,
|
||||||
bgcolor: int,
|
bgcolor: int,
|
||||||
text_offset: int = None,
|
text_offset: Optional[int] = None,
|
||||||
text_len: int = None,
|
text_len: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Renders left-aligned text at position (x,y) where x is left position and
|
Renders left-aligned text at position (x,y) where x is left position and
|
||||||
@ -159,8 +159,8 @@ class Display:
|
|||||||
self,
|
self,
|
||||||
text: str,
|
text: str,
|
||||||
font: int,
|
font: int,
|
||||||
text_offset: int = None,
|
text_offset: Optional[int] = None,
|
||||||
text_len: int = None,
|
text_len: Optional[int] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""
|
"""
|
||||||
Returns a width of text in pixels. Font font is used for rendering.
|
Returns a width of text in pixels. Font font is used for rendering.
|
||||||
@ -181,7 +181,7 @@ class Display:
|
|||||||
Scale determines a zoom factor.
|
Scale determines a zoom factor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def orientation(self, degrees: int = None) -> int:
|
def orientation(self, degrees: Optional[int] = None) -> int:
|
||||||
"""
|
"""
|
||||||
Sets display orientation to 0, 90, 180 or 270 degrees.
|
Sets display orientation to 0, 90, 180 or 270 degrees.
|
||||||
Everything needs to be redrawn again when this function is used.
|
Everything needs to be redrawn again when this function is used.
|
||||||
@ -189,13 +189,13 @@ class Display:
|
|||||||
value.
|
value.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def backlight(self, val: int = None) -> int:
|
def backlight(self, val: Optional[int] = None) -> int:
|
||||||
"""
|
"""
|
||||||
Sets backlight intensity to the value specified in val.
|
Sets backlight intensity to the value specified in val.
|
||||||
Call without the val parameter to just perform the read of the value.
|
Call without the val parameter to just perform the read of the value.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def offset(self, xy: Tuple[int, int] = None) -> Tuple[int, int]:
|
def offset(self, xy: Optional[Tuple[int, int]] = None) -> Tuple[int, int]:
|
||||||
"""
|
"""
|
||||||
Sets offset (x, y) for all subsequent drawing calls.
|
Sets offset (x, y) for all subsequent drawing calls.
|
||||||
Call without the xy parameter to just perform the read of the value.
|
Call without the xy parameter to just perform the read of the value.
|
||||||
|
@ -17,7 +17,7 @@ def memcpy(
|
|||||||
dst_ofs: int,
|
dst_ofs: int,
|
||||||
src: bytes,
|
src: bytes,
|
||||||
src_ofs: int,
|
src_ofs: int,
|
||||||
n: int = None,
|
n: Optional[int] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""
|
"""
|
||||||
Copies at most `n` bytes from `src` at offset `src_ofs` to
|
Copies at most `n` bytes from `src` at offset `src_ofs` to
|
||||||
@ -28,7 +28,7 @@ def memcpy(
|
|||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorutils/modtrezorutils.c
|
# extmod/modtrezorutils/modtrezorutils.c
|
||||||
def halt(msg: str = None) -> None:
|
def halt(msg: Optional[str] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Halts execution.
|
Halts execution.
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,7 @@ from .multisig import multisig_get_pubkeys, multisig_pubkey_index
|
|||||||
from .scripts import output_script_multisig, output_script_native_p2wpkh_or_p2wsh
|
from .scripts import output_script_multisig, output_script_native_p2wpkh_or_p2wsh
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
from trezor.messages.TxInputType import EnumTypeInputScriptType
|
from trezor.messages.TxInputType import EnumTypeInputScriptType
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ def get_address(
|
|||||||
script_type: EnumTypeInputScriptType,
|
script_type: EnumTypeInputScriptType,
|
||||||
coin: CoinInfo,
|
coin: CoinInfo,
|
||||||
node: bip32.HDNode,
|
node: bip32.HDNode,
|
||||||
multisig: MultisigRedeemScriptType = None,
|
multisig: Optional[MultisigRedeemScriptType] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
if multisig:
|
if multisig:
|
||||||
# Ensure that our public key is included in the multisig.
|
# Ensure that our public key is included in the multisig.
|
||||||
|
@ -63,9 +63,9 @@ PATTERN_UNCHAINED_DEPRECATED = "m/45'/coin_type'/account'/[0-1000000]/address_in
|
|||||||
|
|
||||||
def validate_path_against_script_type(
|
def validate_path_against_script_type(
|
||||||
coin: coininfo.CoinInfo,
|
coin: coininfo.CoinInfo,
|
||||||
msg: MsgWithAddressScriptType = None,
|
msg: Optional[MsgWithAddressScriptType] = None,
|
||||||
address_n: Bip32Path = None,
|
address_n: Optional[Bip32Path] = None,
|
||||||
script_type: EnumTypeInputScriptType = None,
|
script_type: Optional[EnumTypeInputScriptType] = None,
|
||||||
multisig: bool = False,
|
multisig: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
patterns = []
|
patterns = []
|
||||||
|
@ -252,7 +252,7 @@ def confirm_nondefault_locktime(lock_time: int, lock_time_disabled: bool) -> Awa
|
|||||||
return (yield UiConfirmNonDefaultLocktime(lock_time, lock_time_disabled))
|
return (yield UiConfirmNonDefaultLocktime(lock_time, lock_time_disabled))
|
||||||
|
|
||||||
|
|
||||||
def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes = None) -> Awaitable[PrevTx]: # type: ignore
|
def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: Optional[bytes] = None) -> Awaitable[PrevTx]: # type: ignore
|
||||||
assert tx_req.details is not None
|
assert tx_req.details is not None
|
||||||
tx_req.request_type = TXMETA
|
tx_req.request_type = TXMETA
|
||||||
tx_req.details.tx_hash = tx_hash
|
tx_req.details.tx_hash = tx_hash
|
||||||
@ -262,7 +262,7 @@ def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes = None) ->
|
|||||||
|
|
||||||
|
|
||||||
def request_tx_extra_data( # type: ignore
|
def request_tx_extra_data( # type: ignore
|
||||||
tx_req: TxRequest, offset: int, size: int, tx_hash: bytes = None
|
tx_req: TxRequest, offset: int, size: int, tx_hash: Optional[bytes] = None
|
||||||
) -> Awaitable[bytearray]:
|
) -> Awaitable[bytearray]:
|
||||||
assert tx_req.details is not None
|
assert tx_req.details is not None
|
||||||
tx_req.request_type = TXEXTRADATA
|
tx_req.request_type = TXEXTRADATA
|
||||||
@ -287,7 +287,7 @@ def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: Optiona
|
|||||||
return sanitize_tx_input(ack.tx.input, coin)
|
return sanitize_tx_input(ack.tx.input, coin)
|
||||||
|
|
||||||
|
|
||||||
def request_tx_prev_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes = None) -> Awaitable[PrevInput]: # type: ignore
|
def request_tx_prev_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: Optional[bytes] = None) -> Awaitable[PrevInput]: # type: ignore
|
||||||
assert tx_req.details is not None
|
assert tx_req.details is not None
|
||||||
tx_req.request_type = TXINPUT
|
tx_req.request_type = TXINPUT
|
||||||
tx_req.details.request_index = i
|
tx_req.details.request_index = i
|
||||||
@ -310,7 +310,7 @@ def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: Option
|
|||||||
return sanitize_tx_output(ack.tx.output, coin)
|
return sanitize_tx_output(ack.tx.output, coin)
|
||||||
|
|
||||||
|
|
||||||
def request_tx_prev_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes = None) -> Awaitable[PrevOutput]: # type: ignore
|
def request_tx_prev_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: Optional[bytes] = None) -> Awaitable[PrevOutput]: # type: ignore
|
||||||
assert tx_req.details is not None
|
assert tx_req.details is not None
|
||||||
tx_req.request_type = TXOUTPUT
|
tx_req.request_type = TXOUTPUT
|
||||||
tx_req.details.request_index = i
|
tx_req.details.request_index = i
|
||||||
|
@ -399,7 +399,7 @@ async def show_address(
|
|||||||
address: str,
|
address: str,
|
||||||
address_type: EnumTypeCardanoAddressType,
|
address_type: EnumTypeCardanoAddressType,
|
||||||
path: List[int],
|
path: List[int],
|
||||||
network: str = None,
|
network: Optional[str] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Custom show_address function is needed because cardano addresses don't
|
Custom show_address function is needed because cardano addresses don't
|
||||||
|
@ -25,7 +25,7 @@ def can_lock_device() -> bool:
|
|||||||
async def request_pin(
|
async def request_pin(
|
||||||
ctx: wire.GenericContext,
|
ctx: wire.GenericContext,
|
||||||
prompt: str = "Enter your PIN",
|
prompt: str = "Enter your PIN",
|
||||||
attempts_remaining: int = None,
|
attempts_remaining: Optional[int] = None,
|
||||||
allow_cancel: bool = True,
|
allow_cancel: bool = True,
|
||||||
) -> str:
|
) -> str:
|
||||||
await button_request(ctx, code=ButtonRequestType.PinEntry)
|
await button_request(ctx, code=ButtonRequestType.PinEntry)
|
||||||
|
@ -6,6 +6,8 @@ from . import mnemonic
|
|||||||
from .passphrase import get as get_passphrase
|
from .passphrase import get as get_passphrase
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from .paths import Bip32Path, Slip21Path
|
from .paths import Bip32Path, Slip21Path
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +17,9 @@ class Slip21Node:
|
|||||||
https://github.com/satoshilabs/slips/blob/master/slip-0021.md.
|
https://github.com/satoshilabs/slips/blob/master/slip-0021.md.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, seed: bytes = None, data: bytes = None) -> None:
|
def __init__(
|
||||||
|
self, seed: Optional[bytes] = None, data: Optional[bytes] = None
|
||||||
|
) -> None:
|
||||||
assert seed is None or data is None, "Specify exactly one of: seed, data"
|
assert seed is None or data is None, "Specify exactly one of: seed, data"
|
||||||
if data is not None:
|
if data is not None:
|
||||||
self.data = data
|
self.data = data
|
||||||
|
@ -2,6 +2,8 @@ from trezor.crypto.slip39 import Share
|
|||||||
from trezor.messages import BackupType
|
from trezor.messages import BackupType
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from trezor.messages.ResetDevice import EnumTypeBackupType
|
from trezor.messages.ResetDevice import EnumTypeBackupType
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +28,9 @@ def is_slip39_backup_type(backup_type: EnumTypeBackupType) -> bool:
|
|||||||
return backup_type in (BackupType.Slip39_Basic, BackupType.Slip39_Advanced)
|
return backup_type in (BackupType.Slip39_Basic, BackupType.Slip39_Advanced)
|
||||||
|
|
||||||
|
|
||||||
def infer_backup_type(is_slip39: bool, share: Share = None) -> EnumTypeBackupType:
|
def infer_backup_type(
|
||||||
|
is_slip39: bool, share: Optional[Share] = None
|
||||||
|
) -> EnumTypeBackupType:
|
||||||
if not is_slip39: # BIP-39
|
if not is_slip39: # BIP-39
|
||||||
return BackupType.Bip39
|
return BackupType.Bip39
|
||||||
elif not share or share.group_count < 1: # invalid parameters
|
elif not share or share.group_count < 1: # invalid parameters
|
||||||
|
@ -172,7 +172,7 @@ class Bip39Keyboard(ui.Layout):
|
|||||||
# Word was confirmed by the user.
|
# Word was confirmed by the user.
|
||||||
raise ui.Result(word)
|
raise ui.Result(word)
|
||||||
|
|
||||||
def edit(self, text: str, button: Button = None, index: int = 0) -> None:
|
def edit(self, text: str, button: Optional[Button] = None, index: int = 0) -> None:
|
||||||
self.pending_button = button
|
self.pending_button = button
|
||||||
self.pending_index = index
|
self.pending_index = index
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ class Slip39Keyboard(ui.Layout):
|
|||||||
# Word was confirmed by the user.
|
# Word was confirmed by the user.
|
||||||
raise ui.Result(word)
|
raise ui.Result(word)
|
||||||
|
|
||||||
def edit(self, button: Button = None, index: int = 0) -> None:
|
def edit(self, button: Optional[Button] = None, index: int = 0) -> None:
|
||||||
self.pending_button = button
|
self.pending_button = button
|
||||||
self.pending_index = index
|
self.pending_index = index
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ async def show_group_threshold_reached(ctx: wire.GenericContext) -> None:
|
|||||||
|
|
||||||
|
|
||||||
class RecoveryHomescreen(ui.Component):
|
class RecoveryHomescreen(ui.Component):
|
||||||
def __init__(self, text: str, subtext: str = None):
|
def __init__(self, text: str, subtext: Optional[str] = None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.text = text
|
self.text = text
|
||||||
self.subtext = subtext
|
self.subtext = subtext
|
||||||
@ -248,7 +248,7 @@ async def homescreen_dialog(
|
|||||||
ctx: wire.GenericContext,
|
ctx: wire.GenericContext,
|
||||||
homepage: RecoveryHomescreen,
|
homepage: RecoveryHomescreen,
|
||||||
button_label: str,
|
button_label: str,
|
||||||
info_func: Callable = None,
|
info_func: Optional[Callable] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
while True:
|
while True:
|
||||||
if info_func:
|
if info_func:
|
||||||
|
@ -4,7 +4,18 @@ bytes, string, embedded message and repeated fields.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Any, Callable, Dict, Iterable, List, Tuple, Type, TypeVar, Union
|
from typing import (
|
||||||
|
Any,
|
||||||
|
Callable,
|
||||||
|
Dict,
|
||||||
|
Iterable,
|
||||||
|
List,
|
||||||
|
Optional,
|
||||||
|
Tuple,
|
||||||
|
Type,
|
||||||
|
TypeVar,
|
||||||
|
Union,
|
||||||
|
)
|
||||||
from typing_extensions import Protocol
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
class Reader(Protocol):
|
class Reader(Protocol):
|
||||||
@ -200,7 +211,7 @@ if False:
|
|||||||
def load_message(
|
def load_message(
|
||||||
reader: Reader,
|
reader: Reader,
|
||||||
msg_type: Type[LoadedMessageType],
|
msg_type: Type[LoadedMessageType],
|
||||||
field_cache: FieldCache = None,
|
field_cache: Optional[FieldCache] = None,
|
||||||
experimental_enabled: bool = True,
|
experimental_enabled: bool = True,
|
||||||
) -> LoadedMessageType:
|
) -> LoadedMessageType:
|
||||||
if field_cache is None:
|
if field_cache is None:
|
||||||
@ -295,7 +306,7 @@ def load_message(
|
|||||||
|
|
||||||
|
|
||||||
def dump_message(
|
def dump_message(
|
||||||
writer: Writer, msg: MessageType, field_cache: FieldCache = None
|
writer: Writer, msg: MessageType, field_cache: Optional[FieldCache] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
repvalue = [0]
|
repvalue = [0]
|
||||||
|
|
||||||
@ -360,7 +371,7 @@ def dump_message(
|
|||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
|
|
||||||
def count_message(msg: MessageType, field_cache: FieldCache = None) -> int:
|
def count_message(msg: MessageType, field_cache: Optional[FieldCache] = None) -> int:
|
||||||
nbytes = 0
|
nbytes = 0
|
||||||
repvalue = [0]
|
repvalue = [0]
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ def _move_session_ids_queue(session_id: bytes) -> None:
|
|||||||
_session_ids.insert(0, session_id)
|
_session_ids.insert(0, session_id)
|
||||||
|
|
||||||
|
|
||||||
def start_session(received_session_id: bytes = None) -> bytes:
|
def start_session(received_session_id: Optional[bytes] = None) -> bytes:
|
||||||
if received_session_id and received_session_id in _session_ids:
|
if received_session_id and received_session_id in _session_ids:
|
||||||
session_id = received_session_id
|
session_id = received_session_id
|
||||||
else:
|
else:
|
||||||
|
@ -59,8 +59,8 @@ TASK_CLOSED = TaskClosed()
|
|||||||
def schedule(
|
def schedule(
|
||||||
task: Task,
|
task: Task,
|
||||||
value: Any = None,
|
value: Any = None,
|
||||||
deadline: int = None,
|
deadline: Optional[int] = None,
|
||||||
finalizer: Finalizer = None,
|
finalizer: Optional[Finalizer] = None,
|
||||||
reschedule: bool = False,
|
reschedule: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
@ -322,7 +322,7 @@ class race(Syscall):
|
|||||||
scheduled.append(child_task)
|
scheduled.append(child_task)
|
||||||
# TODO: document the types here
|
# TODO: document the types here
|
||||||
|
|
||||||
def exit(self, except_for: Task = None) -> None:
|
def exit(self, except_for: Optional[Task] = None) -> None:
|
||||||
for task in self.scheduled:
|
for task in self.scheduled:
|
||||||
if task != except_for:
|
if task != except_for:
|
||||||
close(task)
|
close(task)
|
||||||
|
@ -191,7 +191,9 @@ class PassphraseKeyboard(ui.Layout):
|
|||||||
# Timeout occurred, let's just reset the pending marker.
|
# Timeout occurred, let's just reset the pending marker.
|
||||||
self.edit(self.input.text)
|
self.edit(self.input.text)
|
||||||
|
|
||||||
def edit(self, text: str, button: KeyButton = None, index: int = 0) -> None:
|
def edit(
|
||||||
|
self, text: str, button: Optional[KeyButton] = None, index: int = 0
|
||||||
|
) -> None:
|
||||||
if len(text) > self.max_length:
|
if len(text) > self.max_length:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from micropython import const
|
|||||||
from trezor import io, loop, ui
|
from trezor import io, loop, ui
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Generator
|
from typing import Generator, Optional
|
||||||
|
|
||||||
SWIPE_UP = const(0x01)
|
SWIPE_UP = const(0x01)
|
||||||
SWIPE_DOWN = const(0x02)
|
SWIPE_DOWN = const(0x02)
|
||||||
@ -18,7 +18,9 @@ _SWIPE_TRESHOLD = const(30)
|
|||||||
|
|
||||||
|
|
||||||
class Swipe(ui.Component):
|
class Swipe(ui.Component):
|
||||||
def __init__(self, directions: int = SWIPE_ALL, area: ui.Area = None) -> None:
|
def __init__(
|
||||||
|
self, directions: int = SWIPE_ALL, area: Optional[ui.Area] = None
|
||||||
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
if area is None:
|
if area is None:
|
||||||
area = (0, 0, ui.WIDTH, ui.HEIGHT)
|
area = (0, 0, ui.WIDTH, ui.HEIGHT)
|
||||||
|
@ -62,7 +62,7 @@ def unimport_end(mods: Iterable[str]) -> None:
|
|||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
def ensure(cond: bool, msg: str = None) -> None:
|
def ensure(cond: bool, msg: Optional[str] = None) -> None:
|
||||||
if not cond:
|
if not cond:
|
||||||
if msg is None:
|
if msg is None:
|
||||||
raise AssertionError
|
raise AssertionError
|
||||||
|
@ -123,7 +123,7 @@ if False:
|
|||||||
def _wrap_protobuf_load(
|
def _wrap_protobuf_load(
|
||||||
reader: protobuf.Reader,
|
reader: protobuf.Reader,
|
||||||
expected_type: Type[protobuf.LoadedMessageType],
|
expected_type: Type[protobuf.LoadedMessageType],
|
||||||
field_cache: protobuf.FieldCache = None,
|
field_cache: Optional[protobuf.FieldCache] = None,
|
||||||
) -> protobuf.LoadedMessageType:
|
) -> protobuf.LoadedMessageType:
|
||||||
try:
|
try:
|
||||||
return protobuf.load_message(
|
return protobuf.load_message(
|
||||||
@ -169,7 +169,7 @@ class Context:
|
|||||||
self,
|
self,
|
||||||
msg: protobuf.MessageType,
|
msg: protobuf.MessageType,
|
||||||
expected_type: Type[protobuf.LoadedMessageType],
|
expected_type: Type[protobuf.LoadedMessageType],
|
||||||
field_cache: protobuf.FieldCache = None,
|
field_cache: Optional[protobuf.FieldCache] = None,
|
||||||
) -> protobuf.LoadedMessageType:
|
) -> protobuf.LoadedMessageType:
|
||||||
await self.write(msg, field_cache)
|
await self.write(msg, field_cache)
|
||||||
del msg
|
del msg
|
||||||
@ -189,7 +189,7 @@ class Context:
|
|||||||
async def read(
|
async def read(
|
||||||
self,
|
self,
|
||||||
expected_type: Type[protobuf.LoadedMessageType],
|
expected_type: Type[protobuf.LoadedMessageType],
|
||||||
field_cache: protobuf.FieldCache = None,
|
field_cache: Optional[protobuf.FieldCache] = None,
|
||||||
) -> protobuf.LoadedMessageType:
|
) -> protobuf.LoadedMessageType:
|
||||||
if __debug__:
|
if __debug__:
|
||||||
log.debug(
|
log.debug(
|
||||||
@ -256,7 +256,9 @@ class Context:
|
|||||||
return _wrap_protobuf_load(msg.data, exptype)
|
return _wrap_protobuf_load(msg.data, exptype)
|
||||||
|
|
||||||
async def write(
|
async def write(
|
||||||
self, msg: protobuf.MessageType, field_cache: protobuf.FieldCache = None
|
self,
|
||||||
|
msg: protobuf.MessageType,
|
||||||
|
field_cache: Optional[protobuf.FieldCache] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
if __debug__:
|
if __debug__:
|
||||||
log.debug(
|
log.debug(
|
||||||
|
@ -45,7 +45,7 @@ disallow_untyped_decorators = True
|
|||||||
disallow_untyped_defs = True
|
disallow_untyped_defs = True
|
||||||
disallow_incomplete_defs = True
|
disallow_incomplete_defs = True
|
||||||
namespace_packages = True
|
namespace_packages = True
|
||||||
# no_implicit_optional = True
|
no_implicit_optional = True
|
||||||
warn_redundant_casts = True
|
warn_redundant_casts = True
|
||||||
warn_return_any = True
|
warn_return_any = True
|
||||||
warn_unused_configs = True
|
warn_unused_configs = True
|
||||||
|
Loading…
Reference in New Issue
Block a user