From 4bde8508f602271b3dc5cbd3b08fba6ed7ac7d67 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Fri, 24 Nov 2023 17:02:18 +0100 Subject: [PATCH] Removed old type hinting --- client/src/ledger_app_clients/ethereum/client.py | 4 ++-- client/src/ledger_app_clients/ethereum/command_builder.py | 5 ++--- .../src/ledger_app_clients/ethereum/eip712/InputData.py | 8 ++++---- client/src/ledger_app_clients/ethereum/keychain.py | 3 +-- client/src/ledger_app_clients/ethereum/settings.py | 4 ++-- tests/ragger/test_eip712.py | 3 +-- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/client/src/ledger_app_clients/ethereum/client.py b/client/src/ledger_app_clients/ethereum/client.py index 843d1b174e..9253c1f673 100644 --- a/client/src/ledger_app_clients/ethereum/client.py +++ b/client/src/ledger_app_clients/ethereum/client.py @@ -2,7 +2,7 @@ from enum import IntEnum from ragger.backend import BackendInterface from ragger.utils import RAPDU -from typing import List, Optional +from typing import Optional from .command_builder import CommandBuilder from .eip712 import EIP712FieldType @@ -53,7 +53,7 @@ def eip712_send_struct_def_struct_field(self, field_type: EIP712FieldType, type_name: str, type_size: int, - array_levels: List, + array_levels: list, key_name: str): return self._send(self._cmd_builder.eip712_send_struct_def_struct_field( field_type, diff --git a/client/src/ledger_app_clients/ethereum/command_builder.py b/client/src/ledger_app_clients/ethereum/command_builder.py index e460461a29..cba06a5c97 100644 --- a/client/src/ledger_app_clients/ethereum/command_builder.py +++ b/client/src/ledger_app_clients/ethereum/command_builder.py @@ -5,7 +5,6 @@ from enum import IntEnum from typing import Optional from ragger.bip import pack_derivation_path -from typing import List from .eip712 import EIP712FieldType @@ -76,7 +75,7 @@ def eip712_send_struct_def_struct_field(self, field_type: EIP712FieldType, type_name: str, type_size: int, - array_levels: List, + array_levels: list, key_name: str) -> bytes: data = bytearray() typedesc = 0 @@ -116,7 +115,7 @@ def eip712_send_struct_impl_array(self, size: int) -> bytes: P2Type.ARRAY, data) - def eip712_send_struct_impl_struct_field(self, data: bytearray) -> List[bytes]: + def eip712_send_struct_impl_struct_field(self, data: bytearray) -> list[bytes]: chunks = list() # Add a 16-bit integer with the data's byte length (network byte order) data_w_length = bytearray() diff --git a/client/src/ledger_app_clients/ethereum/eip712/InputData.py b/client/src/ledger_app_clients/ethereum/eip712/InputData.py index 47e7c35e01..1d0263af3c 100644 --- a/client/src/ledger_app_clients/ethereum/eip712/InputData.py +++ b/client/src/ledger_app_clients/ethereum/eip712/InputData.py @@ -4,7 +4,7 @@ import signal import sys import copy -from typing import Any, Callable, Dict, List, Optional +from typing import Any, Callable, Optional from ledger_app_clients.ethereum import keychain from ledger_app_clients.ethereum.client import EthAppClient, EIP712FieldType @@ -12,9 +12,9 @@ # global variables app_client: EthAppClient = None -filtering_paths: Dict = {} -current_path: List[str] = list() -sig_ctx: Dict[str, Any] = {} +filtering_paths: dict = {} +current_path: list[str] = list() +sig_ctx: dict[str, Any] = {} def default_handler(): diff --git a/client/src/ledger_app_clients/ethereum/keychain.py b/client/src/ledger_app_clients/ethereum/keychain.py index 433d65234a..0fc6712b17 100644 --- a/client/src/ledger_app_clients/ethereum/keychain.py +++ b/client/src/ledger_app_clients/ethereum/keychain.py @@ -3,7 +3,6 @@ from ecdsa import SigningKey from ecdsa.util import sigencode_der from enum import Enum, auto -from typing import Dict # Private key PEM files have to be named the same (lowercase) as their corresponding enum entries @@ -15,7 +14,7 @@ class Key(Enum): NFT = auto() -_keys: Dict[Key, SigningKey] = dict() +_keys: dict[Key, SigningKey] = dict() # Open the corresponding PEM file and load its key in the global dict diff --git a/client/src/ledger_app_clients/ethereum/settings.py b/client/src/ledger_app_clients/ethereum/settings.py index d9d3ed597c..6bd73e91ed 100644 --- a/client/src/ledger_app_clients/ethereum/settings.py +++ b/client/src/ledger_app_clients/ethereum/settings.py @@ -1,7 +1,7 @@ from enum import Enum, auto from ragger.firmware import Firmware from ragger.navigator import Navigator, NavInsID, NavIns -from typing import List, Union +from typing import Union class SettingID(Enum): @@ -44,7 +44,7 @@ def get_setting_position(device: str, setting: Union[NavInsID, SettingID]) -> tu def settings_toggle(fw: Firmware, nav: Navigator, to_toggle: list[SettingID]): - moves: List[Union[NavIns, NavInsID]] = list() + moves: list[Union[NavIns, NavInsID]] = list() settings = get_device_settings(fw.device) # Assume the app is on the home page if fw.device.startswith("nano"): diff --git a/tests/ragger/test_eip712.py b/tests/ragger/test_eip712.py index 320d0de6b3..0f5f45ba2f 100644 --- a/tests/ragger/test_eip712.py +++ b/tests/ragger/test_eip712.py @@ -8,7 +8,6 @@ from ragger.backend import BackendInterface from ragger.firmware import Firmware from ragger.navigator import Navigator, NavInsID -from typing import List import json import ledger_app_clients.ethereum.response_parser as ResponseParser @@ -20,7 +19,7 @@ BIP32_PATH = "m/44'/60'/0'/0/0" -def input_files() -> List[str]: +def input_files() -> list[str]: files = [] for file in os.scandir("%s/eip712_input_files" % (os.path.dirname(__file__))): if fnmatch.fnmatch(file, "*-data.json"):