Skip to content

Commit 66a540e

Browse files
committed
Fix pylint warnings about the usage of f-strings
1 parent 3f8023a commit 66a540e

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

scripts/bytecodecompare/prepare_report.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ def aggregate(self, report: FileReport):
101101
self.missing_metadata_count += sum(1 for c in contract_reports if c.metadata is None)
102102

103103
def __str__(self) -> str:
104-
return "test cases: {}, contracts: {}, errors: {}, missing bytecode: {}, missing metadata: {}".format(
105-
self.file_count,
106-
str(self.contract_count) + ('+' if self.error_count > 0 else ''),
107-
self.error_count,
108-
self.missing_bytecode_count,
109-
self.missing_metadata_count,
104+
contract_count = str(self.contract_count) + ('+' if self.error_count > 0 else '')
105+
return (
106+
f"test cases: {self.file_count}, "
107+
f"contracts: {contract_count}, "
108+
f"errors: {self.error_count}, "
109+
f"missing bytecode: {self.missing_bytecode_count}, "
110+
f"missing metadata: {self.missing_metadata_count}"
110111
)
111112

112113

scripts/extract_test_cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def extract_test_cases(_path):
2323
for l in lines:
2424
if inside:
2525
if l.strip().endswith(')' + delimiter + '";'):
26-
with open('%03d_%s.sol' % (ctr, test_name), mode='wb', encoding='utf8') as f:
26+
with open(f'{ctr:03d}_{test_name}.sol', mode='wb', encoding='utf8') as f:
2727
f.write(test)
2828
ctr += 1
2929
inside = False

scripts/isolate_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def wrap_in_object(code):
5858
if line.startswith("//"):
5959
continue
6060
if not line.startswith("object") and not line.startswith("{"):
61-
return indent("{{\n{}\n}}\n\n".format(code.rstrip()), " ")
61+
return indent(f"{{\n{code.rstrip()}\n}}\n\n", " ")
6262
break
6363

6464
return code
@@ -107,7 +107,8 @@ def write_cases(f, solidityTests, yulTests):
107107
# When code examples are extracted they are indented by 8 spaces, which violates the style guide,
108108
# so before checking remove 4 spaces from each line.
109109
remainder = dedent(test)
110-
sol_filename = 'test_%s_%s.%s' % (hashlib.sha256(test.encode("utf-8")).hexdigest(), cleaned_filename, language)
110+
hash = hashlib.sha256(test.encode("utf-8")).hexdigest()
111+
sol_filename = f'test_{hash}_{cleaned_filename}.{language}'
111112
with open(sol_filename, mode='w', encoding='utf8', newline='') as fi:
112113
fi.write(remainder)
113114

scripts/regressions.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,20 @@ def run(self):
101101
"""
102102

103103
testStatus = []
104-
for fuzzer in glob.iglob("{}/*_ossfuzz".format(self._fuzzer_path)):
104+
for fuzzer in glob.iglob(f"{self._fuzzer_path}/*_ossfuzz"):
105105
basename = os.path.basename(fuzzer)
106-
logfile = os.path.join(self._logpath, "{}.log".format(basename))
107-
corpus_dir = "/tmp/solidity-fuzzing-corpus/{0}_seed_corpus" \
108-
.format(basename)
109-
cmd = "find {0} -type f | xargs -n1 sh -c '{1} $0 || exit 255'".format(corpus_dir, fuzzer)
106+
logfile = os.path.join(self._logpath, f"{basename}.log")
107+
corpus_dir = f"/tmp/solidity-fuzzing-corpus/{basename}_seed_corpus"
108+
cmd = f"find {corpus_dir} -type f | xargs -n1 sh -c '{fuzzer} $0 || exit 255'"
110109
self.run_cmd(cmd, logfile=logfile)
111110
ret = self.process_log(logfile)
112111
if not ret:
113112
print(
114-
"\t[-] libFuzzer reported failure for {0}. "
115-
"Failure logged to test_results".format(
116-
basename))
113+
f"\t[-] libFuzzer reported failure for {basename}. "
114+
"Failure logged to test_results")
117115
testStatus.append(False)
118116
else:
119-
print("\t[+] {0} passed regression tests.".format(basename))
117+
print(f"\t[+] {basename} passed regression tests.")
120118
testStatus.append(True)
121119
return all(testStatus)
122120

scripts/wasm-rebuild/docker-scripts/isolate_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def write_cases(f, tests):
4646
cleaned_filename = f.replace(".","_").replace("-","_").replace(" ","_").lower()
4747
for test in tests:
4848
remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE)
49-
with open('test_%s_%s.sol' % (hashlib.sha256(test).hexdigest(), cleaned_filename), 'w', encoding='utf8') as _f:
49+
hash = hashlib.sha256(test).hexdigest()
50+
with open(f'test_{hash}_{cleaned_filename}.sol', 'w', encoding='utf8') as _f:
5051
_f.write(remainder)
5152

5253

0 commit comments

Comments
 (0)