From 77d4f0b407d05db6fae645d629878afeefe9aeef Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 1 Jun 2019 01:53:50 +0200 Subject: [PATCH] update generator type hinting to use new type syntax --- .../eth2spec/test/sanity/test_blocks.py | 29 ++++++++++--------- .../pyspec/eth2spec/test/test_finality.py | 9 +++--- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py b/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py index 3d2234795..11ae4918e 100644 --- a/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py +++ b/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py @@ -1,4 +1,5 @@ from copy import deepcopy +from typing import List import eth2spec.phase0.spec as spec from eth2spec.utils.bls import bls_sign @@ -36,7 +37,7 @@ def test_empty_block_transition(state): yield 'pre', state block = build_empty_block_for_next_slot(state, signed=True) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -54,7 +55,7 @@ def test_skipped_slots(state): block = build_empty_block_for_next_slot(state) block.slot += 3 sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -72,7 +73,7 @@ def test_empty_epoch_transition(state): block = build_empty_block_for_next_slot(state) block.slot += spec.SLOTS_PER_EPOCH sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -91,7 +92,7 @@ def test_empty_epoch_transition(state): # block = build_empty_block_for_next_slot(state) # block.slot += spec.SLOTS_PER_EPOCH * 5 # sign_block(state, block, proposer_index=0) -# yield 'blocks', [block], [spec.BeaconBlock] +# yield 'blocks', [block], List[spec.BeaconBlock] # # state_transition(state, block) # yield 'post', state @@ -119,7 +120,7 @@ def test_proposer_slashing(state): block = build_empty_block_for_next_slot(state) block.body.proposer_slashings.append(proposer_slashing) sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -152,7 +153,7 @@ def test_attester_slashing(state): block = build_empty_block_for_next_slot(state) block.body.attester_slashings.append(attester_slashing) sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -189,7 +190,7 @@ def test_deposit_in_block(state): block.body.deposits.append(deposit) sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -216,7 +217,7 @@ def test_deposit_top_up(state): block.body.deposits.append(deposit) sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -252,7 +253,7 @@ def test_attestation(state): sign_block(state, epoch_block) state_transition(state, epoch_block) - yield 'blocks', [attestation_block, epoch_block], [spec.BeaconBlock] + yield 'blocks', [attestation_block, epoch_block], List[spec.BeaconBlock] yield 'post', state assert len(state.current_epoch_attestations) == 0 @@ -298,7 +299,7 @@ def test_voluntary_exit(state): sign_block(state, exit_block) state_transition(state, exit_block) - yield 'blocks', [initiate_exit_block, exit_block], [spec.BeaconBlock] + yield 'blocks', [initiate_exit_block, exit_block], List[spec.BeaconBlock] yield 'post', state assert state.validator_registry[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH @@ -326,7 +327,7 @@ def test_transfer(state): block.body.transfers.append(transfer) sign_block(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] state_transition(state, block) yield 'post', state @@ -355,7 +356,7 @@ def test_balance_driven_status_transitions(state): sign_block(state, block) state_transition(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] yield 'post', state assert state.validator_registry[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH @@ -371,7 +372,7 @@ def test_historical_batch(state): block = build_empty_block_for_next_slot(state, signed=True) state_transition(state, block) - yield 'blocks', [block], [spec.BeaconBlock] + yield 'blocks', [block], List[spec.BeaconBlock] yield 'post', state assert state.slot == block.slot @@ -399,7 +400,7 @@ def test_historical_batch(state): # # state_transition(state, block) # -# yield 'blocks', [block], [spec.BeaconBlock] +# yield 'blocks', [block], List[spec.BeaconBlock] # yield 'post', state # # assert state.slot % spec.SLOTS_PER_ETH1_VOTING_PERIOD == 0 diff --git a/test_libs/pyspec/eth2spec/test/test_finality.py b/test_libs/pyspec/eth2spec/test/test_finality.py index cdd09bf23..b1948ad8d 100644 --- a/test_libs/pyspec/eth2spec/test/test_finality.py +++ b/test_libs/pyspec/eth2spec/test/test_finality.py @@ -1,4 +1,5 @@ from copy import deepcopy +from typing import List import eth2spec.phase0.spec as spec from eth2spec.phase0.spec import ( @@ -86,7 +87,7 @@ def test_finality_rule_4(state): assert state.finalized_epoch == prev_state.current_justified_epoch assert state.finalized_root == prev_state.current_justified_root - yield 'blocks', blocks, [spec.BeaconBlock] + yield 'blocks', blocks, List[spec.BeaconBlock] yield 'post', state @@ -116,7 +117,7 @@ def test_finality_rule_1(state): assert state.finalized_epoch == prev_state.previous_justified_epoch assert state.finalized_root == prev_state.previous_justified_root - yield 'blocks', blocks, [spec.BeaconBlock] + yield 'blocks', blocks, List[spec.BeaconBlock] yield 'post', state @@ -148,7 +149,7 @@ def test_finality_rule_2(state): blocks += new_blocks - yield 'blocks', blocks, [spec.BeaconBlock] + yield 'blocks', blocks, List[spec.BeaconBlock] yield 'post', state @@ -197,5 +198,5 @@ def test_finality_rule_3(state): assert state.finalized_epoch == prev_state.current_justified_epoch assert state.finalized_root == prev_state.current_justified_root - yield 'blocks', blocks, [spec.BeaconBlock] + yield 'blocks', blocks, List[spec.BeaconBlock] yield 'post', state