Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eth/_utils/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Configurable(ConfigurableAPI):
"""
@classmethod
def configure(cls: Type[T],
__name__: str=None,
__name__: str = None,
**overrides: Any) -> Type[T]:

if __name__ is None:
Expand Down
28 changes: 15 additions & 13 deletions eth/_utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class empty:
pass


def get_env_value(name: str, required: bool=False, default: Any=empty) -> str:
def get_env_value(name: str, required: bool = False, default: Any = empty) -> str:
"""
Core function for extracting the environment variable.

Expand All @@ -56,7 +56,7 @@ def get_env_value(name: str, required: bool=False, default: Any=empty) -> str:
return value


def env_int(name: str, required: bool=False, default: Union[Type[empty], int]=empty) -> int:
def env_int(name: str, required: bool = False, default: Union[Type[empty], int] = empty) -> int:
"""Pulls an environment variable out of the environment and casts it to an
integer. If the name is not present in the environment and no default is
specified then a ``ValueError`` will be raised. Similarly, if the
Expand Down Expand Up @@ -84,7 +84,9 @@ def env_int(name: str, required: bool=False, default: Union[Type[empty], int]=em
return int(value)


def env_float(name: str, required: bool=False, default: Union[Type[empty], float]=empty) -> float:
def env_float(name: str,
required: bool = False,
default: Union[Type[empty], float] = empty) -> float:
"""Pulls an environment variable out of the environment and casts it to an
float. If the name is not present in the environment and no default is
specified then a ``ValueError`` will be raised. Similarly, if the
Expand Down Expand Up @@ -113,9 +115,9 @@ def env_float(name: str, required: bool=False, default: Union[Type[empty], float


def env_bool(name: str,
truthy_values: Iterable[Any]=TRUE_VALUES,
required: bool=False,
default: Union[Type[empty], bool]=empty) -> bool:
truthy_values: Iterable[Any] = TRUE_VALUES,
required: bool = False,
default: Union[Type[empty], bool] = empty) -> bool:
"""Pulls an environment variable out of the environment returning it as a
boolean. The strings ``'True'`` and ``'true'`` are the default *truthy*
values. If not present in the environment and no default is specified,
Expand Down Expand Up @@ -143,7 +145,7 @@ def env_bool(name: str,
return value in TRUE_VALUES


def env_string(name: str, required: bool=False, default: Union[Type[empty], str]=empty) -> str:
def env_string(name: str, required: bool = False, default: Union[Type[empty], str] = empty) -> str:
"""Pulls an environment variable out of the environment returning it as a
string. If not present in the environment and no default is specified, an
empty string is returned.
Expand All @@ -167,9 +169,9 @@ def env_string(name: str, required: bool=False, default: Union[Type[empty], str]


def env_list(name: str,
separator: str =',',
required: bool=False,
default: Union[Type[empty], List[Any]]=empty) -> List[Any]:
separator: str = ',',
required: bool = False,
default: Union[Type[empty], List[Any]] = empty) -> List[Any]:
"""Pulls an environment variable out of the environment, splitting it on a
separator, and returning it as a list. Extra whitespace on the list values
is stripped. List values that evaluate as falsy are removed. If not present
Expand Down Expand Up @@ -201,9 +203,9 @@ def env_list(name: str,


def get(name: str,
required: bool=False,
default: Union[Type[empty], T]=empty,
type: Type[T]=None) -> T:
required: bool = False,
default: Union[Type[empty], T] = empty,
type: Type[T] = None) -> T:
"""Generic getter for environment variables. Handles defaults,
required-ness, and what type to expect.

Expand Down
4 changes: 2 additions & 2 deletions eth/_utils/rlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def diff_rlp_object(left: BaseBlock,
@curry
def validate_rlp_equal(obj_a: BaseBlock,
obj_b: BaseBlock,
obj_a_name: str=None,
obj_b_name: str=None) -> None:
obj_a_name: str = None,
obj_b_name: str = None) -> None:
if obj_a == obj_b:
return

Expand Down
2 changes: 1 addition & 1 deletion eth/_utils/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def extract_signature_v(v: int) -> int:

def create_transaction_signature(unsigned_txn: UnsignedTransactionAPI,
private_key: datatypes.PrivateKey,
chain_id: int=None) -> VRS:
chain_id: int = None) -> VRS:

transaction_parts = rlp.decode(rlp.encode(unsigned_txn))

Expand Down
12 changes: 6 additions & 6 deletions eth/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ class AccountStorageDatabaseAPI(ABC):
merklized until :meth:`make_storage_root` is called.
"""
@abstractmethod
def get(self, slot: int, from_journal: bool=True) -> int:
def get(self, slot: int, from_journal: bool = True) -> int:
"""
Return the value at ``slot``. Lookups take the journal into consideration unless
``from_journal`` is explicitly set to ``False``.
Expand Down Expand Up @@ -1904,7 +1904,7 @@ def has_root(self, state_root: bytes) -> bool:
# Storage
#
@abstractmethod
def get_storage(self, address: Address, slot: int, from_journal: bool=True) -> int:
def get_storage(self, address: Address, slot: int, from_journal: bool = True) -> int:
"""
Return the value stored at ``slot`` for the given ``address``. Take the journal
into consideration unless ``from_journal`` is set to ``False``.
Expand Down Expand Up @@ -2165,7 +2165,7 @@ class ConfigurableAPI(ABC):
@classmethod
@abstractmethod
def configure(cls: Type[T],
__name__: str=None,
__name__: str = None,
**overrides: Any) -> Type[T]:
...

Expand Down Expand Up @@ -2286,7 +2286,7 @@ def make_state_root(self) -> Hash32:
...

@abstractmethod
def get_storage(self, address: Address, slot: int, from_journal: bool=True) -> int:
def get_storage(self, address: Address, slot: int, from_journal: bool = True) -> int:
"""
Return the storage at ``slot`` for ``address``.
"""
Expand Down Expand Up @@ -3220,7 +3220,7 @@ def get_chaindb_class(cls) -> Type[ChainDatabaseAPI]:
def from_genesis(cls,
base_db: AtomicDatabaseAPI,
genesis_params: Dict[str, HeaderParams],
genesis_state: AccountState=None) -> 'ChainAPI':
genesis_state: AccountState = None) -> 'ChainAPI':
"""
Initialize the Chain from a genesis state.
"""
Expand Down Expand Up @@ -3491,7 +3491,7 @@ def estimate_gas(
@abstractmethod
def import_block(self,
block: BlockAPI,
perform_validation: bool=True,
perform_validation: bool = True,
) -> BlockImportResult:
"""
Import the given ``block`` and return a 3-tuple
Expand Down
6 changes: 3 additions & 3 deletions eth/chains/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_chaindb_class(cls) -> Type[ChainDatabaseAPI]:
def from_genesis(cls,
base_db: AtomicDatabaseAPI,
genesis_params: Dict[str, HeaderParams],
genesis_state: AccountState=None) -> 'BaseChain':
genesis_state: AccountState = None) -> 'BaseChain':
genesis_vm_class = cls.get_vm_class_for_block_number(BlockNumber(0))

pre_genesis_header = BlockHeader(difficulty=0, block_number=-1, gas_limit=0)
Expand Down Expand Up @@ -455,7 +455,7 @@ def estimate_gas(

def import_block(self,
block: BlockAPI,
perform_validation: bool=True
perform_validation: bool = True
) -> BlockImportResult:

try:
Expand Down Expand Up @@ -659,7 +659,7 @@ def apply_transaction(self,

def import_block(self,
block: BlockAPI,
perform_validation: bool=True
perform_validation: bool = True
) -> BlockImportResult:
result = super().import_block(
block, perform_validation)
Expand Down
4 changes: 2 additions & 2 deletions eth/chains/tester/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_header_from_parent(cls,

@to_tuple
def _generate_vm_configuration(*fork_start_blocks: ForkStartBlocks,
dao_start_block: Union[int, bool]=None) -> Generator[VMStartBlock, None, None]: # noqa: E501
dao_start_block: Union[int, bool] = None) -> Generator[VMStartBlock, None, None]: # noqa: E501
"""
fork_start_blocks should be 2-tuples of (start_block, fork_name_or_vm_class)

Expand Down Expand Up @@ -154,7 +154,7 @@ def validate_seal(self, header: BlockHeaderAPI) -> None:

def configure_forks(self,
*fork_start_blocks: ForkStartBlocks,
dao_start_block: Union[int, bool]=None) -> None:
dao_start_block: Union[int, bool] = None) -> None:
"""
On demand configuration of fork rules. This is a foot gun that if used
incorrectly could cause weird VM errors.
Expand Down
4 changes: 2 additions & 2 deletions eth/db/accesslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class KeyAccessLoggerDB(BaseDB):

logger = logging.getLogger("eth.db.KeyAccessLoggerDB")

def __init__(self, wrapped_db: DatabaseAPI, log_missing_keys: bool=True) -> None:
def __init__(self, wrapped_db: DatabaseAPI, log_missing_keys: bool = True) -> None:
"""
:param log_missing_keys: True if a key is added to :attr:`keys_read` even if the
key/value does not exist in the database.
Expand Down Expand Up @@ -70,7 +70,7 @@ class KeyAccessLoggerAtomicDB(BaseAtomicDB):
"""
logger = logging.getLogger("eth.db.KeyAccessLoggerAtomicDB")

def __init__(self, wrapped_db: AtomicDatabaseAPI, log_missing_keys: bool=True) -> None:
def __init__(self, wrapped_db: AtomicDatabaseAPI, log_missing_keys: bool = True) -> None:
"""
:param log_missing_keys: True if a key is added to :attr:`keys_read` even if the
key/value does not exist in the database.
Expand Down
8 changes: 4 additions & 4 deletions eth/db/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
class AccountDB(AccountDatabaseAPI):
logger = get_extended_debug_logger('eth.db.account.AccountDB')

def __init__(self, db: AtomicDatabaseAPI, state_root: Hash32=BLANK_ROOT_HASH) -> None:
def __init__(self, db: AtomicDatabaseAPI, state_root: Hash32 = BLANK_ROOT_HASH) -> None:
r"""
Internal implementation details (subject to rapid change):
Database entries go through several pipes, like so...
Expand Down Expand Up @@ -152,7 +152,7 @@ def has_root(self, state_root: bytes) -> bool:
#
# Storage
#
def get_storage(self, address: Address, slot: int, from_journal: bool=True) -> int:
def get_storage(self, address: Address, slot: int, from_journal: bool = True) -> int:
validate_canonical_address(address, title="Storage Address")
validate_uint256(slot, title="Storage Slot")

Expand Down Expand Up @@ -333,7 +333,7 @@ def account_is_empty(self, address: Address) -> bool:
#
# Internal
#
def _get_encoded_account(self, address: Address, from_journal: bool=True) -> bytes:
def _get_encoded_account(self, address: Address, from_journal: bool = True) -> bytes:
self._accessed_accounts.add(address)
lookup_trie = self._journaltrie if from_journal else self._trie_cache

Expand All @@ -345,7 +345,7 @@ def _get_encoded_account(self, address: Address, from_journal: bool=True) -> byt
# In case the account is deleted in the JournalDB
return b''

def _get_account(self, address: Address, from_journal: bool=True) -> Account:
def _get_account(self, address: Address, from_journal: bool = True) -> Account:
if from_journal and address in self._account_cache:
return self._account_cache[address]

Expand Down
4 changes: 2 additions & 2 deletions eth/db/backends/level.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class LevelDB(BaseAtomicDB):

# Creates db as a class variable to avoid level db lock error
def __init__(self,
db_path: Path=None,
max_open_files: int=None) -> None:
db_path: Path = None,
max_open_files: int = None) -> None:
if not db_path:
raise TypeError("Please specifiy a valid path for your database.")
try:
Expand Down
2 changes: 1 addition & 1 deletion eth/db/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CacheDB(BaseDB):
Set and get decoded RLP objects, where the underlying db stores
encoded objects.
"""
def __init__(self, db: DatabaseAPI, cache_size: int=2048) -> None:
def __init__(self, db: DatabaseAPI, cache_size: int = 2048) -> None:
self._db = db
self._cache_size = cache_size
self.reset_cache()
Expand Down
2 changes: 1 addition & 1 deletion eth/db/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
# as an index to find the base trie from before the revert.
self._clear_count = JournalDB(MemoryDB({CLEAR_COUNT_KEY_NAME: to_bytes(0)}))

def get(self, slot: int, from_journal: bool=True) -> int:
def get(self, slot: int, from_journal: bool = True) -> int:
self._accessed_slots.add(slot)
key = int_to_big_endian(slot)
lookup_db = self._journal_storage if from_journal else self._locked_changes
Expand Down
4 changes: 3 additions & 1 deletion eth/estimators/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def _get_computation_error(state: StateAPI, transaction: SignedTransactionAPI) -


@curry
def binary_gas_search(state: StateAPI, transaction: SignedTransactionAPI, tolerance: int=1) -> int:
def binary_gas_search(state: StateAPI,
transaction: SignedTransactionAPI,
tolerance: int = 1) -> int:
"""
Run the transaction with various gas limits, progressively
approaching the minimum needed to succeed without an OutOfGas exception.
Expand Down
8 changes: 4 additions & 4 deletions eth/rlp/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Account(rlp.Serializable, AccountAPI):
]

def __init__(self,
nonce: int=0,
balance: int=0,
storage_root: bytes=BLANK_ROOT_HASH,
code_hash: bytes=EMPTY_SHA3,
nonce: int = 0,
balance: int = 0,
storage_root: bytes = BLANK_ROOT_HASH,
code_hash: bytes = EMPTY_SHA3,
**kwargs: Any) -> None:
super().__init__(nonce, balance, storage_root, code_hash, **kwargs)

Expand Down
58 changes: 29 additions & 29 deletions eth/rlp/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,36 @@ def __init__(self,
difficulty: int,
block_number: BlockNumber,
gas_limit: int,
timestamp: int=None,
coinbase: Address=ZERO_ADDRESS,
parent_hash: Hash32=ZERO_HASH32,
uncles_hash: Hash32=EMPTY_UNCLE_HASH,
state_root: Hash32=BLANK_ROOT_HASH,
transaction_root: Hash32=BLANK_ROOT_HASH,
receipt_root: Hash32=BLANK_ROOT_HASH,
bloom: int=0,
gas_used: int=0,
extra_data: bytes=b'',
mix_hash: Hash32=ZERO_HASH32,
nonce: bytes=GENESIS_NONCE) -> None:
timestamp: int = None,
coinbase: Address = ZERO_ADDRESS,
parent_hash: Hash32 = ZERO_HASH32,
uncles_hash: Hash32 = EMPTY_UNCLE_HASH,
state_root: Hash32 = BLANK_ROOT_HASH,
transaction_root: Hash32 = BLANK_ROOT_HASH,
receipt_root: Hash32 = BLANK_ROOT_HASH,
bloom: int = 0,
gas_used: int = 0,
extra_data: bytes = b'',
mix_hash: Hash32 = ZERO_HASH32,
nonce: bytes = GENESIS_NONCE) -> None:
...

def __init__(self, # type: ignore # noqa: F811
difficulty: int,
block_number: BlockNumber,
gas_limit: int,
timestamp: int=None,
coinbase: Address=ZERO_ADDRESS,
parent_hash: Hash32=ZERO_HASH32,
uncles_hash: Hash32=EMPTY_UNCLE_HASH,
state_root: Hash32=BLANK_ROOT_HASH,
transaction_root: Hash32=BLANK_ROOT_HASH,
receipt_root: Hash32=BLANK_ROOT_HASH,
bloom: int=0,
gas_used: int=0,
extra_data: bytes=b'',
mix_hash: Hash32=ZERO_HASH32,
nonce: bytes=GENESIS_NONCE) -> None:
timestamp: int = None,
coinbase: Address = ZERO_ADDRESS,
parent_hash: Hash32 = ZERO_HASH32,
uncles_hash: Hash32 = EMPTY_UNCLE_HASH,
state_root: Hash32 = BLANK_ROOT_HASH,
transaction_root: Hash32 = BLANK_ROOT_HASH,
receipt_root: Hash32 = BLANK_ROOT_HASH,
bloom: int = 0,
gas_used: int = 0,
extra_data: bytes = b'',
mix_hash: Hash32 = ZERO_HASH32,
nonce: bytes = GENESIS_NONCE) -> None:
if timestamp is None:
timestamp = int(time.time())
super().__init__(
Expand Down Expand Up @@ -166,11 +166,11 @@ def from_parent(cls,
gas_limit: int,
difficulty: int,
timestamp: int,
coinbase: Address=ZERO_ADDRESS,
nonce: bytes=None,
extra_data: bytes=None,
transaction_root: bytes=None,
receipt_root: bytes=None) -> 'BlockHeader':
coinbase: Address = ZERO_ADDRESS,
nonce: bytes = None,
extra_data: bytes = None,
transaction_root: bytes = None,
receipt_root: bytes = None) -> 'BlockHeader':
"""
Initialize a new block header with the `parent` header as the block's
parent hash.
Expand Down
Loading