Skip to content

Commit 30f31c7

Browse files
Bhargavasomucburgdorf
authored andcommitted
Add type hints For eth/utils module
1 parent e68e7c3 commit 30f31c7

File tree

20 files changed

+262
-93
lines changed

20 files changed

+262
-93
lines changed

eth/beacon/aggregation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
pipe
77
)
88

9-
109
from eth_typing import (
1110
Hash32,
1211
)
@@ -62,7 +61,7 @@ def verify_votes(
6261
def aggregate_votes(bitfield: bytes,
6362
sigs: Iterable[bytes],
6463
voting_sigs: Iterable[bytes],
65-
voting_committee_indices: Iterable[int]) -> Tuple[bytes, Tuple[int]]:
64+
voting_committee_indices: Iterable[int]) -> Tuple[bytes, Tuple[int, int]]:
6665
"""
6766
Aggregate the votes.
6867
"""

eth/chains/base.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
iterate,
4141
take,
4242
)
43+
from mypy_extensions import (
44+
TypedDict,
45+
)
4346

4447
from eth.db.backends.base import BaseAtomicDB
4548
from eth.db.chain import (
@@ -105,11 +108,13 @@
105108
from eth.vm.base import BaseVM # noqa: F401
106109

107110

108-
# Mapping from address to account state.
109-
# 'balance', 'nonce' -> int
110-
# 'code' -> bytes
111-
# 'storage' -> Dict[int, int]
112-
AccountState = Dict[Address, Dict[str, Union[int, bytes, Dict[int, int]]]]
111+
AccountDetails = TypedDict('AccountDetails',
112+
{'balance': int,
113+
'nonce': int,
114+
'code': bytes,
115+
'storage': Dict[int, int]
116+
})
117+
AccountState = Dict[Address, AccountDetails]
113118

114119

115120
class BaseChain(Configurable, ABC):

eth/estimators/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
2-
from typing import Callable
2+
from typing import (
3+
Any,
4+
)
35

46
from eth.utils.module_loading import (
57
import_string,
68
)
79

810

9-
def get_gas_estimator() -> Callable:
11+
def get_gas_estimator() -> Any:
1012
import_path = os.environ.get(
1113
'GAS_ESTIMATOR_BACKEND_FUNC',
1214
'eth.estimators.gas.binary_gas_search_intrinsic_tolerance',

0 commit comments

Comments
 (0)