Skip to content

Commit f301bf5

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#26257: script, test: python linter flake8 E275 fixup, update dependencies
1e5e87c script: update python linter dependencies (Jon Atack) 459cb63 script, test: fix python linter E275 errors with flake8 5.0.4 (Jon Atack) Pull request description: It is helpful to be able to run the python linter locally to review PRs and check local diffs and work. Fix the errors raised by `./test/lint/lint-python.py` when run locally with flake8 5.0.4, which enforces rule E275 more strictly than previous versions, and update our python linter CI dependencies. ACKs for top commit: kristapsk: ACK 1e5e87c Tree-SHA512: c7da09396144b9fed4ce6405c0763b2e3e5651d49a5220b053da465aceca09f754fb70a8ab9647278ce2028dde803bea461a3cd93fb39868ead39d06187cd8af
2 parents cb552c5 + 1e5e87c commit f301bf5

29 files changed

+97
-97
lines changed

ci/lint/04_install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ ${CI_RETRY_EXE} apt-get install -y python3-pip curl git gawk jq
1717
)
1818

1919
${CI_RETRY_EXE} pip3 install codespell==2.2.1
20-
${CI_RETRY_EXE} pip3 install flake8==4.0.1
21-
${CI_RETRY_EXE} pip3 install mypy==0.942
22-
${CI_RETRY_EXE} pip3 install pyzmq==22.3.0
23-
${CI_RETRY_EXE} pip3 install vulture==2.3
20+
${CI_RETRY_EXE} pip3 install flake8==5.0.4
21+
${CI_RETRY_EXE} pip3 install mypy==0.971
22+
${CI_RETRY_EXE} pip3 install pyzmq==24.0.1
23+
${CI_RETRY_EXE} pip3 install vulture==2.6
2424

2525
SHELLCHECK_VERSION=v0.8.0
2626
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/

contrib/linearize/linearize-hashes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_block_hashes(settings, max_blocks_per_call=10000):
7878
if rpc.response_is_error(resp_obj):
7979
print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr)
8080
sys.exit(1)
81-
assert(resp_obj['id'] == x) # assume replies are in-sequence
81+
assert resp_obj['id'] == x # assume replies are in-sequence
8282
if settings['rev_hash_bytes'] == 'true':
8383
resp_obj['result'] = bytes.fromhex(resp_obj['result'])[::-1].hex()
8484
print(resp_obj['result'])

contrib/seeds/generate-seeds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def name_to_bip155(addr):
7070
if i == 0 or i == (len(addr)-1): # skip empty component at beginning or end
7171
continue
7272
x += 1 # :: skips to suffix
73-
assert(x < 2)
73+
assert x < 2
7474
else: # two bytes per component
7575
val = int(comp, 16)
7676
sub[x].append(val >> 8)
7777
sub[x].append(val & 0xff)
7878
nullbytes = 16 - len(sub[0]) - len(sub[1])
79-
assert((x == 0 and nullbytes == 0) or (x == 1 and nullbytes > 0))
79+
assert (x == 0 and nullbytes == 0) or (x == 1 and nullbytes > 0)
8080
addr_bytes = bytes(sub[0] + ([0] * nullbytes) + sub[1])
8181
if addr_bytes[0] == 0xfc:
8282
# Assume that seeds with fc00::/8 addresses belong to CJDNS,

test/functional/feature_coinstatsindex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _test_coin_stats_index(self):
221221

222222
self.generate(index_node, 1, sync_fun=self.no_op)
223223
res10 = index_node.gettxoutsetinfo('muhash')
224-
assert(res8['txouts'] < res10['txouts'])
224+
assert res8['txouts'] < res10['txouts']
225225

226226
self.log.info("Test that the index works with -reindex")
227227

@@ -268,12 +268,12 @@ def _test_reorg_index(self):
268268
res2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=112)
269269
assert_equal(res["bestblock"], block)
270270
assert_equal(res["muhash"], res2["muhash"])
271-
assert(res["muhash"] != res_invalid["muhash"])
271+
assert res["muhash"] != res_invalid["muhash"]
272272

273273
# Test that requesting reorged out block by hash is still returning correct results
274274
res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=reorg_block)
275275
assert_equal(res_invalid2["muhash"], res_invalid["muhash"])
276-
assert(res["muhash"] != res_invalid2["muhash"])
276+
assert res["muhash"] != res_invalid2["muhash"]
277277

278278
# Add another block, so we don't depend on reconsiderblock remembering which
279279
# blocks were touched by invalidateblock

test/functional/feature_index_prune.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_test(self):
6262
for node in filter_nodes:
6363
assert_greater_than(len(node.getblockfilter(tip)['filter']), 0)
6464
for node in stats_nodes:
65-
assert(node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash'])
65+
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash']
6666

6767
self.mine_batches(500)
6868
self.sync_index(height=700)
@@ -80,14 +80,14 @@ def run_test(self):
8080
for node in filter_nodes:
8181
assert_greater_than(len(node.getblockfilter(tip)['filter']), 0)
8282
for node in stats_nodes:
83-
assert(node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash'])
83+
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash']
8484

8585
self.log.info("check if we can access the blockfilter and coinstats of a pruned block")
8686
height_hash = self.nodes[0].getblockhash(2)
8787
for node in filter_nodes:
8888
assert_greater_than(len(node.getblockfilter(height_hash)['filter']), 0)
8989
for node in stats_nodes:
90-
assert(node.gettxoutsetinfo(hash_type="muhash", hash_or_height=height_hash)['muhash'])
90+
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=height_hash)['muhash']
9191

9292
# mine and sync index up to a height that will later be the pruneheight
9393
self.generate(self.nodes[0], 51)

test/functional/interface_usdt_utxocache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ def handle_utxocache_flush(_, data, __):
357357
"size": event.size
358358
})
359359
# sanity checks only
360-
assert(event.memory > 0)
361-
assert(event.duration > 0)
360+
assert event.memory > 0
361+
assert event.duration > 0
362362
handle_flush_succeeds += 1
363363

364364
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)

test/functional/interface_usdt_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def handle_blockconnected(_, data, __):
112112
assert_equal(len([tx["vin"] for tx in block["tx"]]), event.inputs)
113113
assert_equal(0, event.sigops) # no sigops in coinbase tx
114114
# only plausibility checks
115-
assert(event.duration > 0)
115+
assert event.duration > 0
116116
del expected_blocks[block_hash]
117117
blocks_checked += 1
118118

test/functional/mocks/invalid_signer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def perform_pre_checks():
1212
mock_result_path = os.path.join(os.getcwd(), "mock_result")
13-
if(os.path.isfile(mock_result_path)):
13+
if os.path.isfile(mock_result_path):
1414
with open(mock_result_path, "r", encoding="utf8") as f:
1515
mock_result = f.read()
1616
if mock_result[0]:

test/functional/mocks/signer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def perform_pre_checks():
1212
mock_result_path = os.path.join(os.getcwd(), "mock_result")
13-
if(os.path.isfile(mock_result_path)):
13+
if os.path.isfile(mock_result_path):
1414
with open(mock_result_path, "r", encoding="utf8") as f:
1515
mock_result = f.read()
1616
if mock_result[0]:

test/functional/p2p_addr_relay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, test_addr_contents=False, send_getaddr=True):
4949
def on_addr(self, message):
5050
for addr in message.addrs:
5151
self.num_ipv4_received += 1
52-
if(self.test_addr_contents):
52+
if self.test_addr_contents:
5353
# relay_tests checks the content of the addr messages match
5454
# expectations based on the message creation in setup_addr_msg
5555
assert_equal(addr.nServices, 9)

0 commit comments

Comments
 (0)