Skip to content

Commit

Permalink
List becomes list (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored Sep 1, 2024
1 parent c17acef commit a20685d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
14 changes: 7 additions & 7 deletions ethstaker_deposit/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import json
import concurrent.futures
from typing import Dict, List, Optional, Any, Sequence
from typing import Dict, Optional, Any, Sequence

from eth_typing import Address, HexAddress
from eth_utils import to_canonical_address
Expand Down Expand Up @@ -259,7 +259,7 @@ class CredentialList:
"""
A collection of multiple Credentials, one for each validator.
"""
def __init__(self, credentials: List[Credential]):
def __init__(self, credentials: list[Credential]):
self.credentials = credentials

@classmethod
Expand All @@ -268,7 +268,7 @@ def from_mnemonic(cls,
mnemonic: str,
mnemonic_password: str,
num_keys: int,
amounts: List[int],
amounts: list[int],
chain_setting: BaseChainSetting,
start_index: int,
hex_withdrawal_address: Optional[HexAddress],
Expand All @@ -279,7 +279,7 @@ def from_mnemonic(cls,
)
key_indices = range(start_index, start_index + num_keys)

credentials: List[Credential] = []
credentials: list[Credential] = []
with click.progressbar(length=num_keys, label=load_text(['msg_key_creation']), # type: ignore[var-annotated]
show_percent=False, show_pos=True) as bar:
executor_kwargs = [{
Expand All @@ -298,8 +298,8 @@ def from_mnemonic(cls,
bar.update(1)
return cls(credentials)

def export_keystores(self, password: str, folder: str, timestamp: float) -> List[str]:
filefolders: List[str] = []
def export_keystores(self, password: str, folder: str, timestamp: float) -> list[str]:
filefolders: list[str] = []
with click.progressbar(length=len(self.credentials), # type: ignore[var-annotated]
label=load_text(['msg_keystore_creation']),
show_percent=False, show_pos=True) as bar:
Expand Down Expand Up @@ -329,7 +329,7 @@ def export_deposit_data_json(self, folder: str, timestamp: float) -> str:

return export_deposit_data_json_util(folder, timestamp, deposit_data)

def verify_keystores(self, keystore_filefolders: List[str], password: str) -> bool:
def verify_keystores(self, keystore_filefolders: list[str], password: str) -> bool:
all_valid_keystores = True
with click.progressbar(length=len(self.credentials), # type: ignore[var-annotated]
label=load_text(['msg_keystore_verification']),
Expand Down
3 changes: 1 addition & 2 deletions ethstaker_deposit/deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import socket
import sys
from multiprocessing import freeze_support
from typing import List

from ethstaker_deposit.cli.existing_mnemonic import existing_mnemonic
from ethstaker_deposit.cli.exit_transaction_keystore import exit_transaction_keystore
Expand Down Expand Up @@ -61,7 +60,7 @@ def check_connectivity() -> None:

class SortedGroup(click.Group):

def list_commands(self, ctx: click.Context) -> List[str]:
def list_commands(self, ctx: click.Context) -> list[str]:
return [x.name for x in commands]


Expand Down
3 changes: 1 addition & 2 deletions ethstaker_deposit/key_handling/key_derivation/mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from unicodedata import normalize
from secrets import randbits
from typing import (
List,
Optional,
Sequence,
)
Expand Down Expand Up @@ -93,7 +92,7 @@ def _get_checksum(entropy: bytes) -> int:
return int.from_bytes(SHA256(entropy), 'big') >> (256 - checksum_length)


def abbreviate_words(words: Sequence[str]) -> List[str]:
def abbreviate_words(words: Sequence[str]) -> list[str]:
"""
Given a series of word strings, return the 4-letter version of each word (which is unique according to BIP39)
"""
Expand Down
4 changes: 1 addition & 3 deletions ethstaker_deposit/key_handling/key_derivation/path.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import List

from .mnemonic import get_seed
from .tree import (
derive_master_SK,
derive_child_SK,
)


def path_to_nodes(path: str) -> List[int]:
def path_to_nodes(path: str) -> list[int]:
"""
Maps from a path string to a list of indices where each index represents the corresponding level in the path.
"""
Expand Down
3 changes: 1 addition & 2 deletions ethstaker_deposit/key_handling/key_derivation/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
SHA256,
)
from py_ecc.optimized_bls12_381 import curve_order as bls_curve_order
from typing import List


def _flip_bits_256(input: int) -> int:
Expand All @@ -13,7 +12,7 @@ def _flip_bits_256(input: int) -> int:
return input ^ (2**256 - 1)


def _IKM_to_lamport_SK(*, IKM: bytes, salt: bytes) -> List[bytes]:
def _IKM_to_lamport_SK(*, IKM: bytes, salt: bytes) -> list[bytes]:
"""
Derives the lamport SK for a given `IKM` and `salt`.
Expand Down
3 changes: 1 addition & 2 deletions ethstaker_deposit/utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from typing import (
Dict,
List,
)


Expand Down Expand Up @@ -33,7 +32,7 @@
INTL_CONTENT_PATH = os.path.join('ethstaker_deposit', 'intl')


def _add_index_to_options(d: Dict[str, List[str]]) -> Dict[str, List[str]]:
def _add_index_to_options(d: Dict[str, list[str]]) -> Dict[str, list[str]]:
'''
Adds the (1 indexed) index (in the dict) to the first element of value list.
eg. {'en': ['English', 'en']} -> {'en': ['1. English', '1', 'English', 'en']}
Expand Down
5 changes: 2 additions & 3 deletions ethstaker_deposit/utils/intl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Any,
Dict,
Iterable,
List,
Mapping,
Sequence,
)
Expand Down Expand Up @@ -37,7 +36,7 @@ def _get_from_dict(dataDict: Dict[str, Any], mapList: Iterable[str]) -> str:
raise KeyError('The provided params (%s) were incomplete.' % mapList)


def load_text(params: List[str], file_path: str = '', func: str = '', lang: str = '') -> str:
def load_text(params: list[str], file_path: str = '', func: str = '', lang: str = '') -> str:
'''
Determine and return the appropriate internationalisation text for a given set of `params`.
'''
Expand Down Expand Up @@ -75,7 +74,7 @@ def load_text(params: List[str], file_path: str = '', func: str = '', lang: str
return load_text(params, file_path, func, 'en')


def get_first_options(options: Mapping[str, Sequence[str]]) -> List[str]:
def get_first_options(options: Mapping[str, Sequence[str]]) -> list[str]:
'''
Returns the first `option` in the values of the `options` dict.
'''
Expand Down

0 comments on commit a20685d

Please sign in to comment.