From 9058647b67dbce3631d13a61c93fc5fc01e8e9aa Mon Sep 17 00:00:00 2001 From: Carl Beekhuizen Date: Wed, 22 May 2019 10:28:03 +0200 Subject: [PATCH] flake8v3.7->flake8v3.5 --- Makefile | 5 +++-- specs/core/0_beacon-chain.md | 6 +++--- specs/core/1_custody-game.md | 2 +- test_libs/pyspec/eth2spec/phase1/state_transition.py | 4 ++-- .../phase0/block_processing/test_process_transfer.py | 4 ++-- test_libs/pyspec/tests/phase0/helpers.py | 6 +++--- .../test_process_early_derived_secret_reveal.py | 10 +++++----- test_libs/pyspec/tests/phase1/conftest.py | 11 ++++++----- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 443266bb4..d700d1900 100644 --- a/Makefile +++ b/Makefile @@ -52,11 +52,12 @@ citest: $(PY_SPEC_ALL_TARGETS) python -m pytest --junitxml=test-reports/eth2spec/test_results_phase0.xml tests/phase1 install_lint: - cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install flake8==3.7.0 + cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install flake8==3.5.0 lint: $(PY_SPEC_ALL_TARGETS) cd $(PY_SPEC_DIR); . venv/bin/activate; \ - flake8 --max-line-length=120 --per-file-ignores='./tests/*:F821,F403,F401,F405' ./eth2spec ./tests; + flake8 --max-line-length=120 ./eth2spec; \ + flake8 --max-line-length=120 --ignore=F401,F403,F405,F821 ./tests; # "make pyspec" to create the pyspec for all phases. pyspec: $(PY_SPEC_ALL_TARGETS) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 281c3d9ee..f69795926 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -962,7 +962,7 @@ def get_total_balance(state: BeaconState, indices: List[ValidatorIndex]) -> Gwei ```python def get_domain(state: BeaconState, domain_type: int, - message_epoch: int = None) -> int: + message_epoch: int=None) -> int: """ Return the signature domain (fork version concatenated with domain type) of a message. """ @@ -1150,7 +1150,7 @@ def initiate_validator_exit(state: BeaconState, index: ValidatorIndex) -> None: ```python def slash_validator(state: BeaconState, slashed_index: ValidatorIndex, - whistleblower_index: ValidatorIndex = None) -> None: + whistleblower_index: ValidatorIndex=None) -> None: """ Slash the validator with index ``slashed_index``. """ @@ -1223,7 +1223,7 @@ Let `genesis_block = BeaconBlock(state_root=hash_tree_root(genesis_state))`. The post-state corresponding to a pre-state `state` and a block `block` is defined as `state_transition(state, block)`. State transitions that trigger an unhandled excpetion (e.g. a failed `assert` or an out-of-range list access) are considered invalid. ```python -def state_transition(state: BeaconState, block: BeaconBlock, validate_state_root: bool = False) -> BeaconState: +def state_transition(state: BeaconState, block: BeaconBlock, validate_state_root: bool=False) -> BeaconState: # Process slots (including those with no blocks) since block process_slots(state, block.slot) # Process block diff --git a/specs/core/1_custody-game.md b/specs/core/1_custody-game.md index ee9867007..b96ea613a 100644 --- a/specs/core/1_custody-game.md +++ b/specs/core/1_custody-game.md @@ -306,7 +306,7 @@ def get_randao_epoch_for_custody_period(period: int, validator_index: ValidatorI ```python def get_validators_custody_reveal_period(state: BeaconState, validator_index: ValidatorIndex, - epoch: Epoch = None) -> int: + epoch: Epoch=None) -> int: ''' This function returns the reveal period for a given validator. If no epoch is supplied, the current epoch is assumed. diff --git a/test_libs/pyspec/eth2spec/phase1/state_transition.py b/test_libs/pyspec/eth2spec/phase1/state_transition.py index a2a78d273..87b2e1c12 100644 --- a/test_libs/pyspec/eth2spec/phase1/state_transition.py +++ b/test_libs/pyspec/eth2spec/phase1/state_transition.py @@ -32,7 +32,7 @@ def process_operations(state: BeaconState, block: BeaconBlock) -> None: def process_block(state: BeaconState, block: BeaconBlock, - verify_state_root: bool = False) -> None: + verify_state_root: bool=False) -> None: spec.process_block_header(state, block) spec.process_randao(state, block) spec.process_eth1_data(state, block) @@ -65,6 +65,6 @@ def state_transition_to(state: BeaconState, up_to: Slot) -> BeaconState: def state_transition(state: BeaconState, block: BeaconBlock, - verify_state_root: bool = False) -> BeaconState: + verify_state_root: bool=False) -> BeaconState: state_transition_to(state, block.slot) process_block(state, block, verify_state_root) diff --git a/test_libs/pyspec/tests/phase0/block_processing/test_process_transfer.py b/test_libs/pyspec/tests/phase0/block_processing/test_process_transfer.py index 2d37798e7..6c57c54f0 100644 --- a/test_libs/pyspec/tests/phase0/block_processing/test_process_transfer.py +++ b/test_libs/pyspec/tests/phase0/block_processing/test_process_transfer.py @@ -79,7 +79,7 @@ def test_active_but_transfer_past_effective_balance(state): def test_incorrect_slot(state): - transfer = helpers.get_valid_transfer(state, slot=state.slot+1) + transfer = helpers.get_valid_transfer(state, slot=state.slot + 1) # un-activate so validator can transfer state.validator_registry[transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH @@ -109,7 +109,7 @@ def test_no_dust(state): state, sender_index=sender_index, amount=balance - spec.MIN_DEPOSIT_AMOUNT + 1, - fee=0 + fee=0, ) # un-activate so validator can transfer diff --git a/test_libs/pyspec/tests/phase0/helpers.py b/test_libs/pyspec/tests/phase0/helpers.py index d41ddd59d..4d1973921 100644 --- a/test_libs/pyspec/tests/phase0/helpers.py +++ b/test_libs/pyspec/tests/phase0/helpers.py @@ -32,7 +32,7 @@ def set_bitfield_bit(bitfield, i): return ( bitfield[:byte_index] + bytes([bitfield[byte_index] | (1 << bit_index)]) + - bitfield[byte_index+1:] + bitfield[byte_index + 1:] ) @@ -265,7 +265,7 @@ def get_valid_attestation(state, slot=None): crosslink_committee = spec.get_crosslink_committee( state, attestation_data.target_epoch, - attestation_data.crosslink.shard + attestation_data.crosslink.shard, ) committee_size = len(crosslink_committee) @@ -362,7 +362,7 @@ def fill_aggregate_attestation(state, attestation): crosslink_committee = spec.get_crosslink_committee( state, attestation.data.target_epoch, - attestation.data.crosslink.shard + attestation.data.crosslink.shard, ) for i in range(len(crosslink_committee)): attestation.aggregation_bitfield = set_bitfield_bit(attestation.aggregation_bitfield, i) diff --git a/test_libs/pyspec/tests/phase1/block_processing_phase1/test_process_early_derived_secret_reveal.py b/test_libs/pyspec/tests/phase1/block_processing_phase1/test_process_early_derived_secret_reveal.py index 75c44697c..ad436ff29 100644 --- a/test_libs/pyspec/tests/phase1/block_processing_phase1/test_process_early_derived_secret_reveal.py +++ b/test_libs/pyspec/tests/phase1/block_processing_phase1/test_process_early_derived_secret_reveal.py @@ -63,7 +63,7 @@ def test_reveal_from_past_epoch(state): def test_reveal_with_custody_padding(state): randao_key_reveal = helpers.get_valid_early_derived_secret_reveal( state, - spec.get_current_epoch(state) + spec.CUSTODY_PERIOD_TO_RANDAO_PADDING + spec.get_current_epoch(state) + spec.CUSTODY_PERIOD_TO_RANDAO_PADDING, ) pre_state, post_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal, True) @@ -73,7 +73,7 @@ def test_reveal_with_custody_padding(state): def test_reveal_with_custody_padding_minus_one(state): randao_key_reveal = helpers.get_valid_early_derived_secret_reveal( state, - spec.get_current_epoch(state) + spec.CUSTODY_PERIOD_TO_RANDAO_PADDING - 1 + spec.get_current_epoch(state) + spec.CUSTODY_PERIOD_TO_RANDAO_PADDING - 1, ) pre_state, post_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal, True) @@ -83,13 +83,13 @@ def test_reveal_with_custody_padding_minus_one(state): def test_double_reveal(state): randao_key_reveal1 = helpers.get_valid_early_derived_secret_reveal( state, - spec.get_current_epoch(state) + spec.RANDAO_PENALTY_EPOCHS + 1 + spec.get_current_epoch(state) + spec.RANDAO_PENALTY_EPOCHS + 1, ) pre_state, intermediate_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal1) randao_key_reveal2 = helpers.get_valid_early_derived_secret_reveal( intermediate_state, - spec.get_current_epoch(pre_state) + spec.RANDAO_PENALTY_EPOCHS + 1 + spec.get_current_epoch(pre_state) + spec.RANDAO_PENALTY_EPOCHS + 1, ) _, post_state = run_early_derived_secret_reveal_processing(intermediate_state, randao_key_reveal2, False) @@ -108,7 +108,7 @@ def test_revealer_is_slashed(state): def test_far_future_epoch(state): randao_key_reveal = helpers.get_valid_early_derived_secret_reveal( state, - spec.get_current_epoch(state) + spec.EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS + spec.get_current_epoch(state) + spec.EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS, ) pre_state, post_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal, False) diff --git a/test_libs/pyspec/tests/phase1/conftest.py b/test_libs/pyspec/tests/phase1/conftest.py index 0e634cbf4..4226241d7 100644 --- a/test_libs/pyspec/tests/phase1/conftest.py +++ b/test_libs/pyspec/tests/phase1/conftest.py @@ -6,10 +6,6 @@ from preset_loader import loader from tests.phase0 import helpers as phase1_helpers from tests.phase1 import helpers as helpers -from tests.phase0.conftest import ( - deposit_data_leaves, -) - def pytest_addoption(parser): parser.addoption( @@ -34,5 +30,10 @@ def num_validators(config): @pytest.fixture -def state(num_validators, deposit_data_leaves): # noqa: F811 +def deposit_data_leaves(): + return list() + + +@pytest.fixture +def state(num_validators, deposit_data_leaves): return helpers.create_genesis_state(num_validators, deposit_data_leaves)