flake8v3.7->flake8v3.5

This commit is contained in:
Carl Beekhuizen
2019-05-22 10:28:03 +02:00
parent 24c4d21d5e
commit 9058647b67
8 changed files with 25 additions and 23 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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.

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)