Fixed pep8 violations in bigchaindb source code

This commit is contained in:
Christian Gärtner 2016-10-18 17:38:44 +02:00 committed by Sylvain Bellemare
parent fdf3786a3b
commit 078d018395
10 changed files with 20 additions and 22 deletions

View File

@ -19,7 +19,7 @@ install:
before_script:
- rethinkdb --daemon
- flake8 .
- flake8 --max-line-length 119 bigchaindb/
script: py.test -n auto -s -v --cov=bigchaindb

View File

@ -11,8 +11,8 @@ config = {
# Note: this section supports all the Gunicorn settings:
# - http://docs.gunicorn.org/en/stable/settings.html
'bind': os.environ.get('BIGCHAINDB_SERVER_BIND') or 'localhost:9984',
'workers': None, # if none, the value will be cpu_count * 2 + 1
'threads': None, # if none, the value will be cpu_count * 2 + 1
'workers': None, # if none, the value will be cpu_count * 2 + 1
'threads': None, # if none, the value will be cpu_count * 2 + 1
},
'database': {
'host': os.environ.get('BIGCHAINDB_DATABASE_HOST', 'localhost'),

View File

@ -82,7 +82,6 @@ def run_configure(args, skip_if_exists=False):
conf,
bigchaindb.config_utils.env_config(bigchaindb.config))
print('Generating keypair', file=sys.stderr)
conf['keypair']['private'], conf['keypair']['public'] = \
crypto.generate_key_pair()
@ -162,7 +161,7 @@ def run_start(args):
if args.allow_temp_keypair:
if not (bigchaindb.config['keypair']['private'] or
bigchaindb.config['keypair']['public']):
bigchaindb.config['keypair']['public']):
private_key, public_key = crypto.generate_key_pair()
bigchaindb.config['keypair']['private'] = private_key
@ -170,7 +169,6 @@ def run_start(args):
else:
logger.warning('Keypair found, no need to create one on the fly.')
if args.start_rethinkdb:
try:
proc = utils.start_rethinkdb()

View File

@ -14,7 +14,6 @@ from bigchaindb import db
from bigchaindb.version import __version__
def start_rethinkdb():
"""Start RethinkDB as a child process and wait for it to be
available.

View File

@ -6,7 +6,7 @@ determined according to the following rules:
* If it's set by an environment variable, then use that value
* Otherwise, if it's set in a local config file, then use that
value
* Otherwise, use the default value (contained in
* Otherwise, use the default value (contained in
``bigchaindb.__init__``)
"""

View File

@ -6,7 +6,7 @@ from time import time
from itertools import compress
from bigchaindb.common import crypto, exceptions
from bigchaindb.common.util import gen_timestamp, serialize
from bigchaindb.common.transaction import TransactionLink, Metadata
from bigchaindb.common.transaction import TransactionLink
import rethinkdb as r
@ -218,7 +218,7 @@ class Bigchain(object):
if validity:
# Disregard invalid blocks, and return if there are no valid or undecided blocks
validity = {_id: status for _id, status in validity.items()
if status != Bigchain.BLOCK_INVALID}
if status != Bigchain.BLOCK_INVALID}
if validity:
tx_status = self.TX_UNDECIDED
@ -287,7 +287,7 @@ class Bigchain(object):
}
# NOTE: If there are multiple valid blocks with this transaction,
# something has gone wrong
# something has gone wrong
if list(validity.values()).count(Bigchain.BLOCK_VALID) > 1:
block_ids = str([block for block in validity
if validity[block] == Bigchain.BLOCK_VALID])
@ -366,8 +366,9 @@ class Bigchain(object):
if self.get_transaction(transaction['id']):
num_valid_transactions += 1
if num_valid_transactions > 1:
raise exceptions.DoubleSpend('`{}` was spent more then once. There is a problem with the chain'.format(
txid))
raise exceptions.DoubleSpend(
'`{}` was spent more then once. There is a problem with the chain'.format(
txid))
if num_valid_transactions:
return Transaction.from_dict(transactions[0])
@ -400,7 +401,7 @@ class Bigchain(object):
continue
# NOTE: It's OK to not serialize the transaction here, as we do not
# use it after the execution of this function.
# use it after the execution of this function.
# a transaction can contain multiple outputs (conditions) so we need to iterate over all of them
# to get a list of outputs available to spend
for index, cond in enumerate(tx['transaction']['conditions']):
@ -540,7 +541,7 @@ class Bigchain(object):
def vote(self, block_id, previous_block_id, decision, invalid_reason=None):
"""Create a signed vote for a block given the
:attr:`previous_block_id` and the :attr:`decision` (valid/invalid).
:attr:`previous_block_id` and the :attr:`decision` (valid/invalid).
Args:
block_id (str): The id of the block to vote on.
@ -599,12 +600,14 @@ class Bigchain(object):
voter_counts = collections.Counter([vote['node_pubkey'] for vote in votes])
for node in voter_counts:
if voter_counts[node] > 1:
raise exceptions.MultipleVotesError('Block {block_id} has multiple votes ({n_votes}) from voting node {node_id}'
.format(block_id=block_id, n_votes=str(voter_counts[node]), node_id=node))
raise exceptions.MultipleVotesError(
'Block {block_id} has multiple votes ({n_votes}) from voting node {node_id}'
.format(block_id=block_id, n_votes=str(voter_counts[node]), node_id=node))
if len(votes) > n_voters:
raise exceptions.MultipleVotesError('Block {block_id} has {n_votes} votes cast, but only {n_voters} voters'
.format(block_id=block_id, n_votes=str(len(votes)), n_voters=str(n_voters)))
.format(block_id=block_id, n_votes=str(len(votes)),
n_voters=str(n_voters)))
# vote_cast is the list of votes e.g. [True, True, False]
vote_cast = [vote['vote']['is_block_valid'] for vote in votes]

View File

@ -1,2 +1,2 @@
# TODO can we use explicit imports?
from bigchaindb.db.utils import *
from bigchaindb.db.utils import * # noqa: F401,F403

View File

@ -190,7 +190,7 @@ class Block(object):
def is_signature_valid(self):
block = self.to_dict()['block']
# cc only accepts bytesting messages
# cc only accepts bytesting messages
block_serialized = serialize(block).encode()
verifying_key = VerifyingKey(block['node_pubkey'])
try:

View File

@ -73,4 +73,3 @@ class ChangeFeed(Node):
self.outqueue.put(change['old_val'])
elif is_update and (self.operation & ChangeFeed.UPDATE):
self.outqueue.put(change['new_val'])

View File

@ -12,4 +12,3 @@ def make_error(status_code, message=None):
})
response.status_code = status_code
return response