Skip to content

Commit 16e69e0

Browse files
authored
Issue #1942 remove linting error ignores (#1964)
- Remove Flake8 error code E252 from the ignore section of tox.ini - Add spaces around operators where errors are raised by tox/flake8 - Clarify reason why W503 is ignored in the flake8 section
1 parent 5b17702 commit 16e69e0

39 files changed

+136
-135
lines changed

eth/_utils/datatypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Configurable(ConfigurableAPI):
7272
"""
7373
@classmethod
7474
def configure(cls: Type[T],
75-
__name__: str=None,
75+
__name__: str = None,
7676
**overrides: Any) -> Type[T]:
7777

7878
if __name__ is None:

eth/_utils/env.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class empty:
3333
pass
3434

3535

36-
def get_env_value(name: str, required: bool=False, default: Any=empty) -> str:
36+
def get_env_value(name: str, required: bool = False, default: Any = empty) -> str:
3737
"""
3838
Core function for extracting the environment variable.
3939
@@ -56,7 +56,7 @@ def get_env_value(name: str, required: bool=False, default: Any=empty) -> str:
5656
return value
5757

5858

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

8686

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

114116

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

145147

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

168170

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

202204

203205
def get(name: str,
204-
required: bool=False,
205-
default: Union[Type[empty], T]=empty,
206-
type: Type[T]=None) -> T:
206+
required: bool = False,
207+
default: Union[Type[empty], T] = empty,
208+
type: Type[T] = None) -> T:
207209
"""Generic getter for environment variables. Handles defaults,
208210
required-ness, and what type to expect.
209211

eth/_utils/rlp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def diff_rlp_object(left: BaseBlock,
5656
@curry
5757
def validate_rlp_equal(obj_a: BaseBlock,
5858
obj_b: BaseBlock,
59-
obj_a_name: str=None,
60-
obj_b_name: str=None) -> None:
59+
obj_a_name: str = None,
60+
obj_b_name: str = None) -> None:
6161
if obj_a == obj_b:
6262
return
6363

eth/_utils/transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def extract_signature_v(v: int) -> int:
5656

5757
def create_transaction_signature(unsigned_txn: UnsignedTransactionAPI,
5858
private_key: datatypes.PrivateKey,
59-
chain_id: int=None) -> VRS:
59+
chain_id: int = None) -> VRS:
6060

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

eth/abc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ class AccountStorageDatabaseAPI(ABC):
17641764
merklized until :meth:`make_storage_root` is called.
17651765
"""
17661766
@abstractmethod
1767-
def get(self, slot: int, from_journal: bool=True) -> int:
1767+
def get(self, slot: int, from_journal: bool = True) -> int:
17681768
"""
17691769
Return the value at ``slot``. Lookups take the journal into consideration unless
17701770
``from_journal`` is explicitly set to ``False``.
@@ -1904,7 +1904,7 @@ def has_root(self, state_root: bytes) -> bool:
19041904
# Storage
19051905
#
19061906
@abstractmethod
1907-
def get_storage(self, address: Address, slot: int, from_journal: bool=True) -> int:
1907+
def get_storage(self, address: Address, slot: int, from_journal: bool = True) -> int:
19081908
"""
19091909
Return the value stored at ``slot`` for the given ``address``. Take the journal
19101910
into consideration unless ``from_journal`` is set to ``False``.
@@ -2165,7 +2165,7 @@ class ConfigurableAPI(ABC):
21652165
@classmethod
21662166
@abstractmethod
21672167
def configure(cls: Type[T],
2168-
__name__: str=None,
2168+
__name__: str = None,
21692169
**overrides: Any) -> Type[T]:
21702170
...
21712171

@@ -2286,7 +2286,7 @@ def make_state_root(self) -> Hash32:
22862286
...
22872287

22882288
@abstractmethod
2289-
def get_storage(self, address: Address, slot: int, from_journal: bool=True) -> int:
2289+
def get_storage(self, address: Address, slot: int, from_journal: bool = True) -> int:
22902290
"""
22912291
Return the storage at ``slot`` for ``address``.
22922292
"""
@@ -3220,7 +3220,7 @@ def get_chaindb_class(cls) -> Type[ChainDatabaseAPI]:
32203220
def from_genesis(cls,
32213221
base_db: AtomicDatabaseAPI,
32223222
genesis_params: Dict[str, HeaderParams],
3223-
genesis_state: AccountState=None) -> 'ChainAPI':
3223+
genesis_state: AccountState = None) -> 'ChainAPI':
32243224
"""
32253225
Initialize the Chain from a genesis state.
32263226
"""
@@ -3491,7 +3491,7 @@ def estimate_gas(
34913491
@abstractmethod
34923492
def import_block(self,
34933493
block: BlockAPI,
3494-
perform_validation: bool=True,
3494+
perform_validation: bool = True,
34953495
) -> BlockImportResult:
34963496
"""
34973497
Import the given ``block`` and return a 3-tuple

eth/chains/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_chaindb_class(cls) -> Type[ChainDatabaseAPI]:
221221
def from_genesis(cls,
222222
base_db: AtomicDatabaseAPI,
223223
genesis_params: Dict[str, HeaderParams],
224-
genesis_state: AccountState=None) -> 'BaseChain':
224+
genesis_state: AccountState = None) -> 'BaseChain':
225225
genesis_vm_class = cls.get_vm_class_for_block_number(BlockNumber(0))
226226

227227
pre_genesis_header = BlockHeader(difficulty=0, block_number=-1, gas_limit=0)
@@ -455,7 +455,7 @@ def estimate_gas(
455455

456456
def import_block(self,
457457
block: BlockAPI,
458-
perform_validation: bool=True
458+
perform_validation: bool = True
459459
) -> BlockImportResult:
460460

461461
try:
@@ -659,7 +659,7 @@ def apply_transaction(self,
659659

660660
def import_block(self,
661661
block: BlockAPI,
662-
perform_validation: bool=True
662+
perform_validation: bool = True
663663
) -> BlockImportResult:
664664
result = super().import_block(
665665
block, perform_validation)

eth/chains/tester/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def create_header_from_parent(cls,
6060

6161
@to_tuple
6262
def _generate_vm_configuration(*fork_start_blocks: ForkStartBlocks,
63-
dao_start_block: Union[int, bool]=None) -> Generator[VMStartBlock, None, None]: # noqa: E501
63+
dao_start_block: Union[int, bool] = None) -> Generator[VMStartBlock, None, None]: # noqa: E501
6464
"""
6565
fork_start_blocks should be 2-tuples of (start_block, fork_name_or_vm_class)
6666
@@ -154,7 +154,7 @@ def validate_seal(self, header: BlockHeaderAPI) -> None:
154154

155155
def configure_forks(self,
156156
*fork_start_blocks: ForkStartBlocks,
157-
dao_start_block: Union[int, bool]=None) -> None:
157+
dao_start_block: Union[int, bool] = None) -> None:
158158
"""
159159
On demand configuration of fork rules. This is a foot gun that if used
160160
incorrectly could cause weird VM errors.

eth/db/accesslog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class KeyAccessLoggerDB(BaseDB):
2626

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

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

73-
def __init__(self, wrapped_db: AtomicDatabaseAPI, log_missing_keys: bool=True) -> None:
73+
def __init__(self, wrapped_db: AtomicDatabaseAPI, log_missing_keys: bool = True) -> None:
7474
"""
7575
:param log_missing_keys: True if a key is added to :attr:`keys_read` even if the
7676
key/value does not exist in the database.

eth/db/account.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
class AccountDB(AccountDatabaseAPI):
8484
logger = get_extended_debug_logger('eth.db.account.AccountDB')
8585

86-
def __init__(self, db: AtomicDatabaseAPI, state_root: Hash32=BLANK_ROOT_HASH) -> None:
86+
def __init__(self, db: AtomicDatabaseAPI, state_root: Hash32 = BLANK_ROOT_HASH) -> None:
8787
r"""
8888
Internal implementation details (subject to rapid change):
8989
Database entries go through several pipes, like so...
@@ -152,7 +152,7 @@ def has_root(self, state_root: bytes) -> bool:
152152
#
153153
# Storage
154154
#
155-
def get_storage(self, address: Address, slot: int, from_journal: bool=True) -> int:
155+
def get_storage(self, address: Address, slot: int, from_journal: bool = True) -> int:
156156
validate_canonical_address(address, title="Storage Address")
157157
validate_uint256(slot, title="Storage Slot")
158158

@@ -333,7 +333,7 @@ def account_is_empty(self, address: Address) -> bool:
333333
#
334334
# Internal
335335
#
336-
def _get_encoded_account(self, address: Address, from_journal: bool=True) -> bytes:
336+
def _get_encoded_account(self, address: Address, from_journal: bool = True) -> bytes:
337337
self._accessed_accounts.add(address)
338338
lookup_trie = self._journaltrie if from_journal else self._trie_cache
339339

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

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

eth/db/backends/level.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class LevelDB(BaseAtomicDB):
3333

3434
# Creates db as a class variable to avoid level db lock error
3535
def __init__(self,
36-
db_path: Path=None,
37-
max_open_files: int=None) -> None:
36+
db_path: Path = None,
37+
max_open_files: int = None) -> None:
3838
if not db_path:
3939
raise TypeError("Please specifiy a valid path for your database.")
4040
try:

eth/db/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CacheDB(BaseDB):
99
Set and get decoded RLP objects, where the underlying db stores
1010
encoded objects.
1111
"""
12-
def __init__(self, db: DatabaseAPI, cache_size: int=2048) -> None:
12+
def __init__(self, db: DatabaseAPI, cache_size: int = 2048) -> None:
1313
self._db = db
1414
self._cache_size = cache_size
1515
self.reset_cache()

eth/db/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
297297
# as an index to find the base trie from before the revert.
298298
self._clear_count = JournalDB(MemoryDB({CLEAR_COUNT_KEY_NAME: to_bytes(0)}))
299299

300-
def get(self, slot: int, from_journal: bool=True) -> int:
300+
def get(self, slot: int, from_journal: bool = True) -> int:
301301
self._accessed_slots.add(slot)
302302
key = int_to_big_endian(slot)
303303
lookup_db = self._journal_storage if from_journal else self._locked_changes

eth/estimators/gas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def _get_computation_error(state: StateAPI, transaction: SignedTransactionAPI) -
2727

2828

2929
@curry
30-
def binary_gas_search(state: StateAPI, transaction: SignedTransactionAPI, tolerance: int=1) -> int:
30+
def binary_gas_search(state: StateAPI,
31+
transaction: SignedTransactionAPI,
32+
tolerance: int = 1) -> int:
3133
"""
3234
Run the transaction with various gas limits, progressively
3335
approaching the minimum needed to succeed without an OutOfGas exception.

eth/rlp/accounts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class Account(rlp.Serializable, AccountAPI):
2929
]
3030

3131
def __init__(self,
32-
nonce: int=0,
33-
balance: int=0,
34-
storage_root: bytes=BLANK_ROOT_HASH,
35-
code_hash: bytes=EMPTY_SHA3,
32+
nonce: int = 0,
33+
balance: int = 0,
34+
storage_root: bytes = BLANK_ROOT_HASH,
35+
code_hash: bytes = EMPTY_SHA3,
3636
**kwargs: Any) -> None:
3737
super().__init__(nonce, balance, storage_root, code_hash, **kwargs)
3838

eth/rlp/headers.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -91,36 +91,36 @@ def __init__(self,
9191
difficulty: int,
9292
block_number: BlockNumber,
9393
gas_limit: int,
94-
timestamp: int=None,
95-
coinbase: Address=ZERO_ADDRESS,
96-
parent_hash: Hash32=ZERO_HASH32,
97-
uncles_hash: Hash32=EMPTY_UNCLE_HASH,
98-
state_root: Hash32=BLANK_ROOT_HASH,
99-
transaction_root: Hash32=BLANK_ROOT_HASH,
100-
receipt_root: Hash32=BLANK_ROOT_HASH,
101-
bloom: int=0,
102-
gas_used: int=0,
103-
extra_data: bytes=b'',
104-
mix_hash: Hash32=ZERO_HASH32,
105-
nonce: bytes=GENESIS_NONCE) -> None:
94+
timestamp: int = None,
95+
coinbase: Address = ZERO_ADDRESS,
96+
parent_hash: Hash32 = ZERO_HASH32,
97+
uncles_hash: Hash32 = EMPTY_UNCLE_HASH,
98+
state_root: Hash32 = BLANK_ROOT_HASH,
99+
transaction_root: Hash32 = BLANK_ROOT_HASH,
100+
receipt_root: Hash32 = BLANK_ROOT_HASH,
101+
bloom: int = 0,
102+
gas_used: int = 0,
103+
extra_data: bytes = b'',
104+
mix_hash: Hash32 = ZERO_HASH32,
105+
nonce: bytes = GENESIS_NONCE) -> None:
106106
...
107107

108108
def __init__(self, # type: ignore # noqa: F811
109109
difficulty: int,
110110
block_number: BlockNumber,
111111
gas_limit: int,
112-
timestamp: int=None,
113-
coinbase: Address=ZERO_ADDRESS,
114-
parent_hash: Hash32=ZERO_HASH32,
115-
uncles_hash: Hash32=EMPTY_UNCLE_HASH,
116-
state_root: Hash32=BLANK_ROOT_HASH,
117-
transaction_root: Hash32=BLANK_ROOT_HASH,
118-
receipt_root: Hash32=BLANK_ROOT_HASH,
119-
bloom: int=0,
120-
gas_used: int=0,
121-
extra_data: bytes=b'',
122-
mix_hash: Hash32=ZERO_HASH32,
123-
nonce: bytes=GENESIS_NONCE) -> None:
112+
timestamp: int = None,
113+
coinbase: Address = ZERO_ADDRESS,
114+
parent_hash: Hash32 = ZERO_HASH32,
115+
uncles_hash: Hash32 = EMPTY_UNCLE_HASH,
116+
state_root: Hash32 = BLANK_ROOT_HASH,
117+
transaction_root: Hash32 = BLANK_ROOT_HASH,
118+
receipt_root: Hash32 = BLANK_ROOT_HASH,
119+
bloom: int = 0,
120+
gas_used: int = 0,
121+
extra_data: bytes = b'',
122+
mix_hash: Hash32 = ZERO_HASH32,
123+
nonce: bytes = GENESIS_NONCE) -> None:
124124
if timestamp is None:
125125
timestamp = int(time.time())
126126
super().__init__(
@@ -166,11 +166,11 @@ def from_parent(cls,
166166
gas_limit: int,
167167
difficulty: int,
168168
timestamp: int,
169-
coinbase: Address=ZERO_ADDRESS,
170-
nonce: bytes=None,
171-
extra_data: bytes=None,
172-
transaction_root: bytes=None,
173-
receipt_root: bytes=None) -> 'BlockHeader':
169+
coinbase: Address = ZERO_ADDRESS,
170+
nonce: bytes = None,
171+
extra_data: bytes = None,
172+
transaction_root: bytes = None,
173+
receipt_root: bytes = None) -> 'BlockHeader':
174174
"""
175175
Initialize a new block header with the `parent` header as the block's
176176
parent hash.

0 commit comments

Comments
 (0)