diff --git a/.travis.yml b/.travis.yml index 3a63d543..ff3677fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/bigchaindb/__init__.py b/bigchaindb/__init__.py index 1276f9a5..dc31b148 100644 --- a/bigchaindb/__init__.py +++ b/bigchaindb/__init__.py @@ -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'), diff --git a/bigchaindb/commands/bigchain.py b/bigchaindb/commands/bigchain.py index 40891416..d52131ab 100644 --- a/bigchaindb/commands/bigchain.py +++ b/bigchaindb/commands/bigchain.py @@ -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() diff --git a/bigchaindb/commands/utils.py b/bigchaindb/commands/utils.py index 6619da6d..573ba785 100644 --- a/bigchaindb/commands/utils.py +++ b/bigchaindb/commands/utils.py @@ -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. diff --git a/bigchaindb/config_utils.py b/bigchaindb/config_utils.py index 3b571835..e678f4e9 100644 --- a/bigchaindb/config_utils.py +++ b/bigchaindb/config_utils.py @@ -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__``) """ diff --git a/bigchaindb/core.py b/bigchaindb/core.py index fed4eded..759e383a 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -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] diff --git a/bigchaindb/db/__init__.py b/bigchaindb/db/__init__.py index 9c299f48..28ebfc3a 100644 --- a/bigchaindb/db/__init__.py +++ b/bigchaindb/db/__init__.py @@ -1,2 +1,2 @@ # TODO can we use explicit imports? -from bigchaindb.db.utils import * +from bigchaindb.db.utils import * # noqa: F401,F403 diff --git a/bigchaindb/models.py b/bigchaindb/models.py index 1334b2de..6471b075 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -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: diff --git a/bigchaindb/pipelines/utils.py b/bigchaindb/pipelines/utils.py index 26984500..71f740ee 100644 --- a/bigchaindb/pipelines/utils.py +++ b/bigchaindb/pipelines/utils.py @@ -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']) - diff --git a/bigchaindb/web/views/base.py b/bigchaindb/web/views/base.py index 82fdc418..9282b5b9 100644 --- a/bigchaindb/web/views/base.py +++ b/bigchaindb/web/views/base.py @@ -12,4 +12,3 @@ def make_error(status_code, message=None): }) response.status_code = status_code return response -