Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 606c64f

Browse files
committed
lint/flake8: fix edgy assert use and local var not used.
SQUASHED: lint/flake8: fix B011 (Do not call assert False...) ...since python -O removes these calls. Instead callers should raise AssertionError(). I did as the tool said, without thinking too much. lint/flake8: fix F841 (local variable is assigned to but never used). ... When used in try/except blocks, with blank `raise`. lint/flake8: re-fix F841 (local variable assigned but never used).
1 parent e1907e7 commit 606c64f

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

eth/consensus/clique/snapshot_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def create_snapshot_for(self,
182182
try:
183183
new_snapshot = self.get_snapshot(
184184
current_header.block_number, current_header.parent_hash)
185-
except SnapshotNotFound as e:
185+
except SnapshotNotFound:
186186
current_header = self._lookup_header(current_header.parent_hash, cached_parents)
187187

188188
if is_checkpoint(current_header.block_number, self._epoch_length):
@@ -262,7 +262,7 @@ def get_snapshot_from_db(self, block_hash: Hash32) -> Snapshot:
262262
except KeyError as e:
263263
raise SnapshotNotFound(
264264
f"Can not get on-disk snapshot for {block_hash!r}"
265-
)
265+
) from e
266266
else:
267267
return decode_snapshot(encoded_key)
268268

eth/vm/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def apply_all_transactions(
245245
previous_header,
246246
transaction,
247247
)
248-
except EVMMissingData as exc:
248+
except EVMMissingData:
249249
self.state.revert(snapshot)
250250
raise
251251

@@ -368,7 +368,7 @@ def finalize_block(self, block: BlockAPI) -> BlockAndMetaWitness:
368368
snapshot = self.state.snapshot()
369369
try:
370370
self._assign_block_rewards(block)
371-
except EVMMissingData as exc:
371+
except EVMMissingData:
372372
self.state.revert(snapshot)
373373
raise
374374
else:

tests/core/vm/test_mainnet_dao_fork.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,4 @@ def test_mainnet_dao_fork_header_validation(VM, header, previous_header, valid):
289289
except ValidationError:
290290
pass
291291
else:
292-
assert False, "The invalid header %r must fail" % header
292+
raise AssertionError("The invalid header %r must fail" % header)

tests/database/test_db_diff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_database_api_missing_key_retrieval(db):
6161
except DiffMissingError as exc:
6262
assert not exc.is_deleted
6363
else:
64-
assert False, f"key should be missing, but was retrieved as {val}"
64+
raise AssertionError(f"key should be missing, but was retrieved as {val}")
6565

6666

6767
def test_database_api_missing_key_for_deletion(db):
@@ -73,7 +73,7 @@ def test_database_api_missing_key_for_deletion(db):
7373
except DiffMissingError as exc:
7474
assert exc.is_deleted
7575
else:
76-
assert False, f"key should be missing, but was retrieved as {val}"
76+
raise AssertionError(f"key should be missing, but was retrieved as {val}")
7777

7878

7979
def test_db_diff_equality(db):
@@ -98,7 +98,7 @@ def test_database_api_deleted_key_for_deletion(db):
9898
except DiffMissingError as exc:
9999
assert exc.is_deleted
100100
else:
101-
assert False, f"key should be missing, but was retrieved as {val}"
101+
raise AssertionError(f"key should be missing, but was retrieved as {val}")
102102

103103

104104
@pytest.mark.parametrize(

tests/json-fixtures/test_blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def test_blockchain_fixtures(fixture_data, fixture):
297297
else:
298298
try:
299299
apply_fixture_block_to_chain(block_fixture, chain)
300-
except (TypeError, rlp.DecodingError, rlp.DeserializationError, ValidationError) as err:
300+
except (TypeError, rlp.DecodingError, rlp.DeserializationError, ValidationError):
301301
# failure is expected on this bad block
302302
pass
303303
else:

tests/json-fixtures/test_virtual_machine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def vm_class(request):
137137
elif request.param == 'SpuriousDragon':
138138
pytest.skip('Only the Homestead VM rules are currently supported')
139139
else:
140-
assert False, f"Unsupported VM: {request.param}"
140+
raise AssertionError(f"Unsupported VM: {request.param}")
141141

142142

143143
def fixture_to_computation(fixture, code, vm):

0 commit comments

Comments
 (0)