From 0f6f05e4b7e2881dc681db5fbead2723411c9058 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 9 Jul 2019 14:05:14 +0200 Subject: [PATCH] core/typing: fix extmod docs and mocks --- core/embed/extmod/modtrezorconfig/modtrezorconfig.c | 6 ++++-- .../extmod/modtrezorcrypto/modtrezorcrypto-secp256k1_zkp.h | 6 +++--- core/mocks/generated/trezorconfig.pyi | 6 ++++-- core/mocks/generated/trezorcrypto/secp256k1_zkp.pyi | 6 +++--- core/mocks/uctypes.pyi | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c b/core/embed/extmod/modtrezorconfig/modtrezorconfig.c index 55c6513b5..43572e78b 100644 --- a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c +++ b/core/embed/extmod/modtrezorconfig/modtrezorconfig.c @@ -141,7 +141,7 @@ STATIC mp_obj_t mod_trezorconfig_change_pin(mp_obj_t pin, mp_obj_t newpin) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorconfig_change_pin_obj, mod_trezorconfig_change_pin); -/// def get(app: int, key: int, public: bool = False) -> bytes: +/// def get(app: int, key: int, public: bool = False) -> Optional[bytes]: /// """ /// Gets the value of the given key for the given app (or None if not set). /// Raises a RuntimeError if decryption or authentication of the stored @@ -243,7 +243,9 @@ STATIC mp_obj_t mod_trezorconfig_set_counter(size_t n_args, STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorconfig_set_counter_obj, 3, 4, mod_trezorconfig_set_counter); -/// def next_counter(app: int, key: int, writable_locked: bool = False) -> bool: +/// def next_counter( +/// app: int, key: int, writable_locked: bool = False, +/// ) -> Optional[int]: /// """ /// Increments the counter stored under the given key of the given app and /// returns the new value. diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1_zkp.h b/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1_zkp.h index b00788ee1..e9d0bb06c 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1_zkp.h +++ b/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1_zkp.h @@ -52,7 +52,7 @@ typedef struct _mp_obj_secp256k1_context_t { uint8_t secp256k1_ctx_buf[0]; // to be allocate via m_new_obj_var_maybe(). } mp_obj_secp256k1_context_t; -/// def __init__(self): +/// def __init__(self) -> None: /// """ /// Allocate and initialize secp256k1_context. /// """ @@ -84,7 +84,7 @@ STATIC mp_obj_t mod_trezorcrypto_secp256k1_context_make_new( return MP_OBJ_FROM_PTR(o); } -/// def __del__(self): +/// def __del__(self) -> None: /// """ /// Destructor. /// """ @@ -98,7 +98,7 @@ STATIC mp_obj_t mod_trezorcrypto_secp256k1_context___del__(mp_obj_t self) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_secp256k1_context___del___obj, mod_trezorcrypto_secp256k1_context___del__); -/// def size(self): +/// def size(self) -> int: /// """ /// Return the size in bytes of the internal secp256k1_ctx_buf buffer. /// """ diff --git a/core/mocks/generated/trezorconfig.pyi b/core/mocks/generated/trezorconfig.pyi index 2dc0175b0..399ea4d95 100644 --- a/core/mocks/generated/trezorconfig.pyi +++ b/core/mocks/generated/trezorconfig.pyi @@ -55,7 +55,7 @@ def change_pin(pin: int, newpin: int) -> bool: # extmod/modtrezorconfig/modtrezorconfig.c -def get(app: int, key: int, public: bool = False) -> bytes: +def get(app: int, key: int, public: bool = False) -> Optional[bytes]: """ Gets the value of the given key for the given app (or None if not set). Raises a RuntimeError if decryption or authentication of the stored @@ -87,7 +87,9 @@ def set_counter( # extmod/modtrezorconfig/modtrezorconfig.c -def next_counter(app: int, key: int, writable_locked: bool = False) -> bool: +def next_counter( + app: int, key: int, writable_locked: bool = False, +) -> Optional[int]: """ Increments the counter stored under the given key of the given app and returns the new value. diff --git a/core/mocks/generated/trezorcrypto/secp256k1_zkp.pyi b/core/mocks/generated/trezorcrypto/secp256k1_zkp.pyi index c76ba90b7..ae185352c 100644 --- a/core/mocks/generated/trezorcrypto/secp256k1_zkp.pyi +++ b/core/mocks/generated/trezorcrypto/secp256k1_zkp.pyi @@ -8,17 +8,17 @@ class Context: Can be allocated once and re-used between subsequent operations. """ - def __init__(self): + def __init__(self) -> None: """ Allocate and initialize secp256k1_context. """ - def __del__(self): + def __del__(self) -> None: """ Destructor. """ - def size(self): + def size(self) -> int: """ Return the size in bytes of the internal secp256k1_ctx_buf buffer. """ diff --git a/core/mocks/uctypes.pyi b/core/mocks/uctypes.pyi index 792a34daf..b57da9585 100644 --- a/core/mocks/uctypes.pyi +++ b/core/mocks/uctypes.pyi @@ -27,4 +27,4 @@ class struct: def sizeof(struct: struct) -> int: ... def addressof(obj: bytes) -> int: ... def bytes_at(addr: int, size: int) -> bytes: ... -def bytearray_at(addr, size) -> bytearray: ... +def bytearray_at(addr: int, size: int) -> bytearray: ...