diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -24,7 +24,7 @@ "type": "flake8", "include": "(\\.py$)", "flags": [ - "--select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,E901,E902,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W601,W602,W603,W604,W605,W606" + "--select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E711,E714,E721,E741,E742,E743,E901,E902,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W601,W602,W603,W604,W605,W606" ] }, "lint-format-strings": { diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -538,7 +538,7 @@ def file_already_has_bitcoin_copyright(file_lines): index, _ = get_updatable_copyright_line(file_lines) - return index != None + return index is not None ################################################################################ # insert header execution diff --git a/test/functional/abc-invalid-chains.py b/test/functional/abc-invalid-chains.py --- a/test/functional/abc-invalid-chains.py +++ b/test/functional/abc-invalid-chains.py @@ -24,7 +24,7 @@ self.extra_args = [["-whitelist=127.0.0.1"]] def next_block(self, number): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: diff --git a/test/functional/abc-mempool-accept-txn.py b/test/functional/abc-mempool-accept-txn.py --- a/test/functional/abc-mempool-accept-txn.py +++ b/test/functional/abc-mempool-accept-txn.py @@ -104,7 +104,7 @@ return tx def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE])): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: @@ -115,7 +115,7 @@ coinbase = create_coinbase(height, self.coinbase_pubkey) coinbase.vout[0].nValue += additional_coinbase_value coinbase.rehash() - if spend == None: + if spend is None: block = create_block(base_block_hash, coinbase, block_time) else: # all but one satoshi to fees diff --git a/test/functional/abc-mempool-coherence-on-activations.py b/test/functional/abc-mempool-coherence-on-activations.py --- a/test/functional/abc-mempool-coherence-on-activations.py +++ b/test/functional/abc-mempool-coherence-on-activations.py @@ -132,7 +132,7 @@ EXTRA_ARG]] def next_block(self, number): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = FIRST_BLOCK_TIME else: diff --git a/test/functional/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -116,7 +116,7 @@ return tx def next_block(self, number, spend=None, script=CScript([OP_TRUE]), block_size=0, extra_txns=0): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: @@ -126,7 +126,7 @@ height = self.block_heights[base_block_hash] + 1 coinbase = create_coinbase(height) coinbase.rehash() - if spend == None: + if spend is None: # We need to have something to spend to fill the block. assert_equal(block_size, 0) block = create_block(base_block_hash, coinbase, block_time) @@ -159,7 +159,7 @@ tx.rehash() # If a specific script is required, add it. - if script != None: + if script is not None: tx.vout.append(CTxOut(1, script)) # Put some random data into the first transaction of the chain to randomize ids. @@ -278,7 +278,7 @@ # Check that compact block also work for big blocks # Wait for SENDCMPCT def received_sendcmpct(): - return (test_p2p.last_sendcmpct != None) + return (test_p2p.last_sendcmpct is not None) wait_until(received_sendcmpct, timeout=30) sendcmpct = msg_sendcmpct() @@ -288,7 +288,7 @@ # Exchange headers def received_getheaders(): - return (test_p2p.last_getheaders != None) + return (test_p2p.last_getheaders is not None) wait_until(received_getheaders, timeout=30) # Return the favor @@ -296,7 +296,7 @@ # Wait for the header list def received_headers(): - return (test_p2p.last_headers != None) + return (test_p2p.last_headers is not None) wait_until(received_headers, timeout=30) # It's like we know about the same headers ! @@ -308,7 +308,7 @@ # Checks the node to forward it via compact block def received_block(): - return (test_p2p.last_cmpctblock != None) + return (test_p2p.last_cmpctblock is not None) wait_until(received_block, timeout=30) # Was it our block ? diff --git a/test/functional/abc-p2p-fullblocktest-sigops.py b/test/functional/abc-p2p-fullblocktest-sigops.py --- a/test/functional/abc-p2p-fullblocktest-sigops.py +++ b/test/functional/abc-p2p-fullblocktest-sigops.py @@ -90,7 +90,7 @@ return tx def next_block(self, number, spend=None, script=CScript([OP_TRUE]), block_size=0, extra_sigops=0): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: @@ -100,7 +100,7 @@ height = self.block_heights[base_block_hash] + 1 coinbase = create_coinbase(height) coinbase.rehash() - if spend == None: + if spend is None: # We need to have something to spend to fill the block. assert_equal(block_size, 0) block = create_block(base_block_hash, coinbase, block_time) @@ -133,7 +133,7 @@ base_tx_size = len(tx.serialize()) + 18 # If a specific script is required, add it. - if script != None: + if script is not None: tx.vout.append(CTxOut(1, script)) # Put some random data into the first transaction of the chain to randomize ids. diff --git a/test/functional/abc-p2p-fullblocktest.py b/test/functional/abc-p2p-fullblocktest.py --- a/test/functional/abc-p2p-fullblocktest.py +++ b/test/functional/abc-p2p-fullblocktest.py @@ -77,7 +77,7 @@ return tx def next_block(self, number, spend=None, script=CScript([OP_TRUE]), block_size=0): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: @@ -87,7 +87,7 @@ height = self.block_heights[base_block_hash] + 1 coinbase = create_coinbase(height) coinbase.rehash() - if spend == None: + if spend is None: # We need to have something to spend to fill the block. assert_equal(block_size, 0) block = create_block(base_block_hash, coinbase, block_time) @@ -120,7 +120,7 @@ base_tx_size = len(tx.serialize()) + 18 # If a specific script is required, add it. - if script != None: + if script is not None: tx.vout.append(CTxOut(1, script)) # Put some random data into the first transaction of the chain to randomize ids. diff --git a/test/functional/abc-replay-protection.py b/test/functional/abc-replay-protection.py --- a/test/functional/abc-replay-protection.py +++ b/test/functional/abc-replay-protection.py @@ -64,7 +64,7 @@ "-replayprotectionactivationtime={}".format(REPLAY_PROTECTION_START_TIME)]] def next_block(self, number): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: diff --git a/test/functional/abc-segwit-recovery.py b/test/functional/abc-segwit-recovery.py --- a/test/functional/abc-segwit-recovery.py +++ b/test/functional/abc-segwit-recovery.py @@ -83,7 +83,7 @@ ["-acceptnonstdtxn=0"]] def next_block(self, number): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = TEST_TIME else: diff --git a/test/functional/abc-transaction-ordering.py b/test/functional/abc-transaction-ordering.py --- a/test/functional/abc-transaction-ordering.py +++ b/test/functional/abc-transaction-ordering.py @@ -54,7 +54,7 @@ block.vtx.extend(tx_list) def next_block(self, number, spend=None, tx_count=0): - if self.tip == None: + if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 else: @@ -64,7 +64,7 @@ height = self.block_heights[base_block_hash] + 1 coinbase = create_coinbase(height) coinbase.rehash() - if spend == None: + if spend is None: # We need to have something to spend to fill the block. block = create_block(base_block_hash, coinbase, block_time) else: diff --git a/test/functional/interface_http.py b/test/functional/interface_http.py --- a/test/functional/interface_http.py +++ b/test/functional/interface_http.py @@ -33,7 +33,7 @@ conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert b'"error":null' in out1 - assert conn.sock != None + assert conn.sock is not None # according to http/1.1 connection must still be open! # send 2nd request without closing connection @@ -41,7 +41,7 @@ out1 = conn.getresponse().read() assert b'"error":null' in out1 # must also response with a correct json-rpc message - assert conn.sock != None + assert conn.sock is not None # according to http/1.1 connection must still be open! conn.close() @@ -55,7 +55,7 @@ conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert b'"error":null' in out1 - assert conn.sock != None + assert conn.sock is not None # according to http/1.1 connection must still be open! # send 2nd request without closing connection @@ -63,7 +63,7 @@ out1 = conn.getresponse().read() assert b'"error":null' in out1 # must also response with a correct json-rpc message - assert conn.sock != None + assert conn.sock is not None # according to http/1.1 connection must still be open! conn.close() @@ -76,7 +76,7 @@ conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert b'"error":null' in out1 - assert conn.sock == None + assert conn.sock is None # now the connection must be closed after the response # node1 (2nd node) is running with disabled keep-alive option @@ -101,7 +101,7 @@ conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert b'"error":null' in out1 - assert conn.sock != None + assert conn.sock is not None # connection must be closed because bitcoind should use # keep-alive by default diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -70,7 +70,7 @@ high_fee_tx = confirmed_transactions[1] # Something high-fee should have been mined! - assert high_fee_tx != None + assert high_fee_tx is not None # Add a prioritisation before a tx is in the mempool (de-prioritising a # high-fee transaction so that it's now low fee). diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -80,7 +80,7 @@ coinbaseoutput.nValue = 50 * COIN halvings = int(height / 150) # regtest coinbaseoutput.nValue >>= halvings - if (pubkey != None): + if (pubkey is not None): coinbaseoutput.scriptPubKey = CScript([pubkey, OP_CHECKSIG]) else: coinbaseoutput.scriptPubKey = CScript([OP_TRUE]) diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -647,7 +647,7 @@ self.shortids = [] self.prefilled_txn = [] - if p2pheaders_and_shortids != None: + if p2pheaders_and_shortids is not None: self.header = p2pheaders_and_shortids.header self.nonce = p2pheaders_and_shortids.nonce self.shortids = p2pheaders_and_shortids.shortids @@ -704,7 +704,7 @@ def __init__(self, blockhash=0, indexes=None): self.blockhash = blockhash - self.indexes = indexes if indexes != None else [] + self.indexes = indexes if indexes is not None else [] def deserialize(self, f): self.blockhash = deser_uint256(f) @@ -746,7 +746,7 @@ def __init__(self, blockhash=0, transactions=None): self.blockhash = blockhash - self.transactions = transactions if transactions != None else [] + self.transactions = transactions if transactions is not None else [] def deserialize(self, f): self.blockhash = deser_uint256(f) @@ -936,7 +936,7 @@ command = b"getdata" def __init__(self, inv=None): - self.inv = inv if inv != None else [] + self.inv = inv if inv is not None else [] def deserialize(self, f): self.inv = deser_vector(f, CInv) diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -174,7 +174,7 @@ while True: msg = self._on_data() - if msg == None: + if msg is None: break self.on_message(msg) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -70,7 +70,7 @@ raise FileNotFoundError( "Binary '{}' could not be found.\nTry setting it manually:\n\tBITCOIND= {}".format(self.binary, sys.argv[0])) self.coverage_dir = coverage_dir - if extra_conf != None: + if extra_conf is not None: append_config(datadir, extra_conf) # Most callers will just need to add extra args to the default list # below. diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -317,7 +317,7 @@ def rpc_url(datadir, host, port): rpc_u, rpc_p = get_auth_cookie(datadir) - if host == None: + if host is None: host = '127.0.0.1' return "http://{}:{}@{}:{}".format(rpc_u, rpc_p, host, int(port)) @@ -407,7 +407,7 @@ def connect_nodes(from_node, to_node): host = to_node.host - if host == None: + if host is None: host = '127.0.0.1' ip_port = host + ':' + str(to_node.p2p_port) from_node.addnode(ip_port, "onetry") diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -132,7 +132,7 @@ def on_ci(): - return os.getenv('TRAVIS') == 'true' or os.getenv('TEAMCITY_VERSION') != None + return os.getenv('TRAVIS') == 'true' or os.getenv('TEAMCITY_VERSION') is not None def main():