Skip to content

Commit 1a35447

Browse files
committed
Merge bitcoin/bitcoin#31417: test: Avoid F541 (f-string without any placeholders)
fae7639 test: Avoid F541 (f-string without any placeholders) (MarcoFalke) Pull request description: An extra `f` string-prefix is mostly harmless, but could be confusing or hint to a mistake where a format argument was forgotten. Try to avoid the confusion and mistakes by applying the `F541` linter rule. ACKs for top commit: lucasbalieiro: **Tested ACK** [fae7639](bitcoin/bitcoin@fae7639) danielabrozzoni: ACK fae7639 tdb3: Code review ACK fae7639 Tree-SHA512: 4992a74fcf0c19b32e4d95f7333e087b4269b5c5259c556789fb86721617db81c7a4fe210ae136c92824976f07f71ad0f374655e7008b1967c02c73324862d9a
2 parents eb2ebe6 + fae7639 commit 1a35447

19 files changed

+30
-29
lines changed

contrib/tracing/log_raw_p2p_msgs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@
117117

118118

119119
def print_message(event, inbound):
120-
print(f"%s %s msg '%s' from peer %d (%s, %s) with %d bytes: %s" %
121-
(
122-
f"Warning: incomplete message (only %d out of %d bytes)!" % (
120+
print("{} {} msg '{}' from peer {} ({}, {}) with {} bytes: {}".format(
121+
122+
"Warning: incomplete message (only {} out of {} bytes)!".format(
123123
len(event.msg), event.msg_size) if len(event.msg) < event.msg_size else "",
124124
"inbound" if inbound else "outbound",
125125
event.msg_type.decode("utf-8"),

test/functional/feature_anchors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def run_test(self):
102102
self.nodes[0].addconnection(ONION_ADDR, 'block-relay-only', v2transport=False)
103103

104104
self.log.debug("Stop node")
105-
with self.nodes[0].assert_debug_log([f"DumpAnchors: Flush 1 outbound block-relay-only peer addresses to anchors.dat"]):
105+
with self.nodes[0].assert_debug_log(["DumpAnchors: Flush 1 outbound block-relay-only peer addresses to anchors.dat"]):
106106
self.stop_node(0)
107107
# Manually close keep_alive proxy connection
108108
onion_proxy.stop()

test/functional/feature_assumeutxo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def expected_error(log_msg="", error_msg=""):
165165
with self.nodes[0].assert_debug_log([log_msg]):
166166
self.nodes[0].assert_start_raises_init_error(expected_msg=error_msg)
167167

168-
expected_error_msg = f"Error: A fatal internal error occurred, see debug.log for details: Assumeutxo data not found for the given blockhash '7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a'."
169-
error_details = f"Assumeutxo data not found for the given blockhash"
168+
expected_error_msg = "Error: A fatal internal error occurred, see debug.log for details: Assumeutxo data not found for the given blockhash '7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a'."
169+
error_details = "Assumeutxo data not found for the given blockhash"
170170
expected_error(log_msg=error_details, error_msg=expected_error_msg)
171171

172172
# resurrect node again
@@ -417,7 +417,7 @@ def check_dump_output(output):
417417

418418
assert_equal(n0.getblockchaininfo()["blocks"], FINAL_HEIGHT)
419419

420-
self.log.info(f"Check that dumptxoutset works for past block heights")
420+
self.log.info("Check that dumptxoutset works for past block heights")
421421
# rollback defaults to the snapshot base height
422422
dump_output2 = n0.dumptxoutset('utxos2.dat', "rollback")
423423
check_dump_output(dump_output2)

test/functional/feature_config_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_negated_config(self):
7272

7373
self.log.debug('Verifying garbage in config can be detected')
7474
with open(conf_path, 'a', encoding='utf-8') as conf:
75-
conf.write(f'garbage\n')
75+
conf.write('garbage\n')
7676
self.nodes[0].assert_start_raises_init_error(
7777
extra_args=['-regtest'],
7878
expected_msg='Error: Error reading configuration file: parse error on line 1: garbage',
@@ -98,7 +98,7 @@ def test_config_file_parser(self):
9898

9999
# Check that startup fails if conf= is set in bitcoin.conf or in an included conf file
100100
bad_conf_file_path = self.nodes[0].datadir_path / "bitcoin_bad.conf"
101-
util.write_config(bad_conf_file_path, n=0, chain='', extra_config=f'conf=some.conf\n')
101+
util.write_config(bad_conf_file_path, n=0, chain='', extra_config='conf=some.conf\n')
102102
conf_in_config_file_err = 'Error: Error reading configuration file: conf cannot be set in the configuration file; use includeconf= if you want to include additional config files'
103103
self.nodes[0].assert_start_raises_init_error(
104104
extra_args=[f'-conf={bad_conf_file_path}'],

test/functional/feature_dersig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def run_test(self):
130130
block.hashMerkleRoot = block.calc_merkle_root()
131131
block.solve()
132132

133-
with self.nodes[0].assert_debug_log(expected_msgs=[f'Block validation error: mandatory-script-verify-flag-failed (Non-canonical DER signature)']):
133+
with self.nodes[0].assert_debug_log(expected_msgs=['Block validation error: mandatory-script-verify-flag-failed (Non-canonical DER signature)']):
134134
peer.send_and_ping(msg_block(block))
135135
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
136136
peer.sync_with_ping()

test/functional/feature_framework_miniwallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_tx_padding(self):
3434

3535
def test_wallet_tagging(self):
3636
"""Verify that tagged wallet instances are able to send funds."""
37-
self.log.info(f"Test tagged wallet instances...")
37+
self.log.info("Test tagged wallet instances...")
3838
node = self.nodes[0]
3939
untagged_wallet = self.wallets[0][1]
4040
for i in range(10):

test/functional/feature_loadblock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def run_test(self):
5151
cfg.write(f"port={node_url.port}\n")
5252
cfg.write(f"host={node_url.hostname}\n")
5353
cfg.write(f"output_file={bootstrap_file}\n")
54-
cfg.write(f"max_height=100\n")
55-
cfg.write(f"netmagic=fabfb5da\n")
54+
cfg.write("max_height=100\n")
55+
cfg.write("netmagic=fabfb5da\n")
5656
cfg.write(f"input={blocks_dir}\n")
5757
cfg.write(f"genesis={genesis_block}\n")
5858
cfg.write(f"hashlist={hash_list.name}\n")

test/functional/interface_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def run_test(self):
209209
self.test_rest_request(f"/getutxos/{spending[0]}-+1", ret_type=RetType.OBJ, status=400)
210210
self.test_rest_request(f"/getutxos/{spending[0]}--1", ret_type=RetType.OBJ, status=400)
211211
self.test_rest_request(f"/getutxos/{spending[0]}aa-1234", ret_type=RetType.OBJ, status=400)
212-
self.test_rest_request(f"/getutxos/aa-1234", ret_type=RetType.OBJ, status=400)
212+
self.test_rest_request("/getutxos/aa-1234", ret_type=RetType.OBJ, status=400)
213213

214214
# Test limits
215215
long_uri = '/'.join([f"{txid}-{n_}" for n_ in range(20)])

test/functional/interface_usdt_utxocache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,15 @@ def handle_utxocache_flush(_, data, __):
393393
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
394394
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)
395395

396-
self.log.info(f"prune blockchain to trigger a flush for pruning")
396+
self.log.info("prune blockchain to trigger a flush for pruning")
397397
expected_flushes.append({"mode": "NONE", "for_prune": True, "size": 0})
398398
self.nodes[0].pruneblockchain(315)
399399

400400
bpf.perf_buffer_poll(timeout=500)
401401
bpf.cleanup()
402402

403403
self.log.info(
404-
f"check that we don't expect additional flushes and that the handle_* function succeeded")
404+
"check that we don't expect additional flushes and that the handle_* function succeeded")
405405
assert_equal(0, len(expected_flushes))
406406
assert_equal(EXPECTED_HANDLE_FLUSH_SUCCESS, handle_flush_succeeds)
407407

test/functional/mempool_datacarrier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def set_test_params(self):
2626
[],
2727
["-datacarrier=0"],
2828
["-datacarrier=1", f"-datacarriersize={MAX_OP_RETURN_RELAY - 1}"],
29-
["-datacarrier=1", f"-datacarriersize=2"],
29+
["-datacarrier=1", "-datacarriersize=2"],
3030
]
3131

3232
def test_null_data_transaction(self, node: TestNode, data, success: bool) -> None:

0 commit comments

Comments
 (0)