diff --git a/tests/device_tests/signtx.py b/tests/device_tests/signtx.py index be75084ab..1b4da1ce0 100644 --- a/tests/device_tests/signtx.py +++ b/tests/device_tests/signtx.py @@ -3,46 +3,46 @@ from trezorlib import messages T = messages.RequestType -def request_input(n, tx_hash=None): +def request_input(n: int, tx_hash: bytes = None) -> messages.TxRequest: return messages.TxRequest( request_type=T.TXINPUT, details=messages.TxRequestDetailsType(request_index=n, tx_hash=tx_hash), ) -def request_output(n, tx_hash=None): +def request_output(n: int, tx_hash: bytes = None) -> messages.TxRequest: return messages.TxRequest( request_type=T.TXOUTPUT, details=messages.TxRequestDetailsType(request_index=n, tx_hash=tx_hash), ) -def request_orig_input(n, tx_hash): +def request_orig_input(n: int, tx_hash: bytes) -> messages.TxRequest: return messages.TxRequest( request_type=T.TXORIGINPUT, details=messages.TxRequestDetailsType(request_index=n, tx_hash=tx_hash), ) -def request_orig_output(n, tx_hash): +def request_orig_output(n: int, tx_hash: bytes) -> messages.TxRequest: return messages.TxRequest( request_type=T.TXORIGOUTPUT, details=messages.TxRequestDetailsType(request_index=n, tx_hash=tx_hash), ) -def request_meta(tx_hash): +def request_meta(tx_hash: bytes) -> messages.TxRequest: return messages.TxRequest( request_type=T.TXMETA, details=messages.TxRequestDetailsType(tx_hash=tx_hash), ) -def request_finished(): +def request_finished() -> messages.TxRequest: return messages.TxRequest(request_type=T.TXFINISHED) -def request_extra_data(ofs, len, tx_hash): +def request_extra_data(ofs: int, len: int, tx_hash: bytes) -> messages.TxRequest: return messages.TxRequest( request_type=T.TXEXTRADATA, details=messages.TxRequestDetailsType( diff --git a/tests/tx_cache.py b/tests/tx_cache.py index a802ffb38..f43a05b82 100755 --- a/tests/tx_cache.py +++ b/tests/tx_cache.py @@ -52,10 +52,10 @@ BLOCKBOOKS = _get_blockbooks() class TxCache: - def __init__(self, coin_name): + def __init__(self, coin_name: str) -> None: self.slug = coin_name.lower().replace(" ", "_") - def get_tx(self, txhash): + def get_tx(self, txhash: str) -> messages.TransactionType: try: (CACHE_PATH / self.slug).mkdir() except Exception: @@ -71,10 +71,10 @@ class TxCache: txdict = json.loads(cache_file.read_text()) return protobuf.dict_to_proto(messages.TransactionType, txdict) - def __getitem__(self, key): + def __getitem__(self, key: bytes) -> messages.TransactionType: return self.get_tx(key.hex()) - def __contains__(self, key): + def __contains__(self, key: bytes) -> bool: try: self.get_tx(key.hex()) return True