diff --git a/planetmint/common/transaction.py b/planetmint/common/transaction.py index be5022c..c7301f6 100644 --- a/planetmint/common/transaction.py +++ b/planetmint/common/transaction.py @@ -205,7 +205,7 @@ def _fulfillment_from_details(data, _depth=0): if data['type'] == 'threshold-sha-256': threshold = ThresholdSha256(data['threshold']) for cond in data['subconditions']: - cond = _fulfillment_from_details(cond, _depth+1) + cond = _fulfillment_from_details(cond, _depth + 1) threshold.add_subfulfillment(cond) return threshold diff --git a/planetmint/config_utils.py b/planetmint/config_utils.py index 517f2c2..1401df7 100644 --- a/planetmint/config_utils.py +++ b/planetmint/config_utils.py @@ -55,7 +55,7 @@ def map_leafs(func, mapping): if isinstance(val, collections.abc.Mapping): _inner(val, path + [key]) else: - mapping[key] = func(val, path=path+[key]) + mapping[key] = func(val, path=path + [key]) return mapping diff --git a/planetmint/elections/election.py b/planetmint/elections/election.py index b0820a2..d73b319 100644 --- a/planetmint/elections/election.py +++ b/planetmint/elections/election.py @@ -209,8 +209,8 @@ class Election(Transaction): votes_current = self.count_votes(election_pk, current_votes) total_votes = sum(output.amount for output in self.outputs) - if (votes_committed < (2/3) * total_votes) and \ - (votes_committed + votes_current >= (2/3)*total_votes): + if (votes_committed < (2 / 3) * total_votes) and \ + (votes_committed + votes_current >= (2 / 3) * total_votes): return True return False diff --git a/planetmint/log.py b/planetmint/log.py index af5414f..d987fc6 100644 --- a/planetmint/log.py +++ b/planetmint/log.py @@ -40,7 +40,7 @@ DEFAULT_LOGGING_CONFIG = { 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(DEFAULT_LOG_DIR, 'planetmint.log'), 'mode': 'w', - 'maxBytes': 209715200, + 'maxBytes': 209715200, 'backupCount': 5, 'formatter': 'file', 'level': logging.INFO, @@ -49,7 +49,7 @@ DEFAULT_LOGGING_CONFIG = { 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(DEFAULT_LOG_DIR, 'planetmint-errors.log'), 'mode': 'w', - 'maxBytes': 209715200, + 'maxBytes': 209715200, 'backupCount': 5, 'formatter': 'file', 'level': logging.ERROR, diff --git a/planetmint/tendermint_utils.py b/planetmint/tendermint_utils.py index f613b63..84d967e 100644 --- a/planetmint/tendermint_utils.py +++ b/planetmint/tendermint_utils.py @@ -66,8 +66,8 @@ def merkleroot(hashes): if len(hashes) % 2 == 1: hashes.append(hashes[-1]) parent_hashes = [ - sha3_256(hashes[i] + hashes[i+1]).digest() - for i in range(0, len(hashes)-1, 2) + sha3_256(hashes[i] + hashes[i + 1]).digest() + for i in range(0, len(hashes) - 1, 2) ] return merkleroot(parent_hashes) diff --git a/planetmint/upsert_validator/validator_election.py b/planetmint/upsert_validator/validator_election.py index 6123683..5f26f92 100644 --- a/planetmint/upsert_validator/validator_election.py +++ b/planetmint/upsert_validator/validator_election.py @@ -27,7 +27,7 @@ class ValidatorElection(Election): super(ValidatorElection, self).validate(planet, current_transactions=current_transactions) # NOTE: change more than 1/3 of the current power is not allowed - if self.asset['data']['power'] >= (1/3)*sum(current_validators.values()): + if self.asset['data']['power'] >= (1 / 3) * sum(current_validators.values()): raise InvalidPowerChange('`power` change must be less than 1/3 of total power') return self diff --git a/tests/conftest.py b/tests/conftest.py index 9498c72..77e22cf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -321,7 +321,7 @@ def inputs(user_pk, b, alice): for _ in range(10) ] tx_ids = [tx.id for tx in transactions] - block = Block(app_hash='hash'+str(height), height=height, transactions=tx_ids) + block = Block(app_hash='hash' + str(height), height=height, transactions=tx_ids) b.store_block(block._asdict()) b.store_bulk_transactions(transactions) diff --git a/tests/tendermint/test_core.py b/tests/tendermint/test_core.py index 8406713..79c5f8c 100644 --- a/tests/tendermint/test_core.py +++ b/tests/tendermint/test_core.py @@ -497,7 +497,7 @@ def test_new_validator_set(b): for u in updates: updated_validators.append({'public_key': {'type': 'ed25519-base64', 'value': public_key_to_base64(u['public_key']['value'])}, - 'voting_power': u['power']}) + 'voting_power': u['power']}) assert updated_validator_set == updated_validators diff --git a/tests/upsert_validator/test_upsert_validator_vote.py b/tests/upsert_validator/test_upsert_validator_vote.py index 340d971..d2b950c 100644 --- a/tests/upsert_validator/test_upsert_validator_vote.py +++ b/tests/upsert_validator/test_upsert_validator_vote.py @@ -68,7 +68,7 @@ def test_upsert_validator_delegate_election_vote(b_mock, valid_upsert_validator_ key0 = ed25519_node_keys[public_key0] delegate_vote = Vote.generate([input0], - [([alice.public_key], 3), ([key0.public_key], votes-3)], + [([alice.public_key], 3), ([key0.public_key], votes - 3)], election_id=valid_upsert_validator_election.id)\ .sign([key0.private_key]) @@ -86,7 +86,7 @@ def test_upsert_validator_delegate_election_vote(b_mock, valid_upsert_validator_ key0_votes = delegate_vote.to_inputs()[1] key0_casted_vote = Vote.generate([key0_votes], - [([election_pub_key], votes-3)], + [([election_pub_key], votes - 3)], election_id=valid_upsert_validator_election.id)\ .sign([key0.private_key]) assert key0_casted_vote.validate(b_mock) @@ -104,7 +104,7 @@ def test_upsert_validator_invalid_election_vote(b_mock, valid_upsert_validator_e election_pub_key = ValidatorElection.to_public_key(valid_upsert_validator_election.id) vote = Vote.generate([input0], - [([election_pub_key], votes+1)], + [([election_pub_key], votes + 1)], election_id=valid_upsert_validator_election.id)\ .sign([key0.private_key]) @@ -125,7 +125,7 @@ def test_valid_election_votes_received(b_mock, valid_upsert_validator_election, # delegate some votes to alice delegate_vote = Vote.generate([input0], - [([alice.public_key], 4), ([key0.public_key], votes-4)], + [([alice.public_key], 4), ([key0.public_key], votes - 4)], election_id=valid_upsert_validator_election.id)\ .sign([key0.private_key]) b_mock.store_bulk_transactions([delegate_vote]) @@ -147,7 +147,7 @@ def test_valid_election_votes_received(b_mock, valid_upsert_validator_election, assert valid_upsert_validator_election.get_commited_votes(b_mock) == 2 key0_casted_vote = Vote.generate([key0_votes], - [([election_public_key], votes-4)], + [([election_public_key], votes - 4)], election_id=valid_upsert_validator_election.id)\ .sign([key0.private_key]) diff --git a/tests/web/test_websocket_server.py b/tests/web/test_websocket_server.py index 17c00e2..da83a4e 100644 --- a/tests/web/test_websocket_server.py +++ b/tests/web/test_websocket_server.py @@ -38,11 +38,13 @@ def test_eventify_block_works_with_any_transaction(): block = {'height': 1, 'transactions': [tx, tx_transfer]} - expected_events = [{ + expected_events = [ + { 'height': 1, 'asset_id': tx.id, 'transaction_id': tx.id - }, { + }, + { 'height': 1, 'asset_id': tx_transfer.asset['id'], 'transaction_id': tx_transfer.id diff --git a/tox.ini b/tox.ini index df3ff55..1ff0b15 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,9 @@ skip_install = True extras = None commands = flake8 planetmint tests +[flake8] +ignore = E126 E127 W504 E302 E126 E305 + [testenv:docsroot] basepython = {[base]basepython} changedir = docs/root/source