mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix pylint warnings about the usage of f-strings
This commit is contained in:
parent
3f8023ace9
commit
66a540ea01
@ -101,12 +101,13 @@ class Statistics:
|
|||||||
self.missing_metadata_count += sum(1 for c in contract_reports if c.metadata is None)
|
self.missing_metadata_count += sum(1 for c in contract_reports if c.metadata is None)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return "test cases: {}, contracts: {}, errors: {}, missing bytecode: {}, missing metadata: {}".format(
|
contract_count = str(self.contract_count) + ('+' if self.error_count > 0 else '')
|
||||||
self.file_count,
|
return (
|
||||||
str(self.contract_count) + ('+' if self.error_count > 0 else ''),
|
f"test cases: {self.file_count}, "
|
||||||
self.error_count,
|
f"contracts: {contract_count}, "
|
||||||
self.missing_bytecode_count,
|
f"errors: {self.error_count}, "
|
||||||
self.missing_metadata_count,
|
f"missing bytecode: {self.missing_bytecode_count}, "
|
||||||
|
f"missing metadata: {self.missing_metadata_count}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ def extract_test_cases(_path):
|
|||||||
for l in lines:
|
for l in lines:
|
||||||
if inside:
|
if inside:
|
||||||
if l.strip().endswith(')' + delimiter + '";'):
|
if l.strip().endswith(')' + delimiter + '";'):
|
||||||
with open('%03d_%s.sol' % (ctr, test_name), mode='wb', encoding='utf8') as f:
|
with open(f'{ctr:03d}_{test_name}.sol', mode='wb', encoding='utf8') as f:
|
||||||
f.write(test)
|
f.write(test)
|
||||||
ctr += 1
|
ctr += 1
|
||||||
inside = False
|
inside = False
|
||||||
|
@ -58,7 +58,7 @@ def extract_yul_docs_cases(path):
|
|||||||
if line.startswith("//"):
|
if line.startswith("//"):
|
||||||
continue
|
continue
|
||||||
if not line.startswith("object") and not line.startswith("{"):
|
if not line.startswith("object") and not line.startswith("{"):
|
||||||
return indent("{{\n{}\n}}\n\n".format(code.rstrip()), " ")
|
return indent(f"{{\n{code.rstrip()}\n}}\n\n", " ")
|
||||||
break
|
break
|
||||||
|
|
||||||
return code
|
return code
|
||||||
@ -107,7 +107,8 @@ def write_cases(f, solidityTests, yulTests):
|
|||||||
# When code examples are extracted they are indented by 8 spaces, which violates the style guide,
|
# When code examples are extracted they are indented by 8 spaces, which violates the style guide,
|
||||||
# so before checking remove 4 spaces from each line.
|
# so before checking remove 4 spaces from each line.
|
||||||
remainder = dedent(test)
|
remainder = dedent(test)
|
||||||
sol_filename = 'test_%s_%s.%s' % (hashlib.sha256(test.encode("utf-8")).hexdigest(), cleaned_filename, language)
|
hash = hashlib.sha256(test.encode("utf-8")).hexdigest()
|
||||||
|
sol_filename = f'test_{hash}_{cleaned_filename}.{language}'
|
||||||
with open(sol_filename, mode='w', encoding='utf8', newline='') as fi:
|
with open(sol_filename, mode='w', encoding='utf8', newline='') as fi:
|
||||||
fi.write(remainder)
|
fi.write(remainder)
|
||||||
|
|
||||||
|
@ -101,22 +101,20 @@ class regressor():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
testStatus = []
|
testStatus = []
|
||||||
for fuzzer in glob.iglob("{}/*_ossfuzz".format(self._fuzzer_path)):
|
for fuzzer in glob.iglob(f"{self._fuzzer_path}/*_ossfuzz"):
|
||||||
basename = os.path.basename(fuzzer)
|
basename = os.path.basename(fuzzer)
|
||||||
logfile = os.path.join(self._logpath, "{}.log".format(basename))
|
logfile = os.path.join(self._logpath, f"{basename}.log")
|
||||||
corpus_dir = "/tmp/solidity-fuzzing-corpus/{0}_seed_corpus" \
|
corpus_dir = f"/tmp/solidity-fuzzing-corpus/{basename}_seed_corpus"
|
||||||
.format(basename)
|
cmd = f"find {corpus_dir} -type f | xargs -n1 sh -c '{fuzzer} $0 || exit 255'"
|
||||||
cmd = "find {0} -type f | xargs -n1 sh -c '{1} $0 || exit 255'".format(corpus_dir, fuzzer)
|
|
||||||
self.run_cmd(cmd, logfile=logfile)
|
self.run_cmd(cmd, logfile=logfile)
|
||||||
ret = self.process_log(logfile)
|
ret = self.process_log(logfile)
|
||||||
if not ret:
|
if not ret:
|
||||||
print(
|
print(
|
||||||
"\t[-] libFuzzer reported failure for {0}. "
|
f"\t[-] libFuzzer reported failure for {basename}. "
|
||||||
"Failure logged to test_results".format(
|
"Failure logged to test_results")
|
||||||
basename))
|
|
||||||
testStatus.append(False)
|
testStatus.append(False)
|
||||||
else:
|
else:
|
||||||
print("\t[+] {0} passed regression tests.".format(basename))
|
print(f"\t[+] {basename} passed regression tests.")
|
||||||
testStatus.append(True)
|
testStatus.append(True)
|
||||||
return all(testStatus)
|
return all(testStatus)
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ def write_cases(f, tests):
|
|||||||
cleaned_filename = f.replace(".","_").replace("-","_").replace(" ","_").lower()
|
cleaned_filename = f.replace(".","_").replace("-","_").replace(" ","_").lower()
|
||||||
for test in tests:
|
for test in tests:
|
||||||
remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE)
|
remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE)
|
||||||
with open('test_%s_%s.sol' % (hashlib.sha256(test).hexdigest(), cleaned_filename), 'w', encoding='utf8') as _f:
|
hash = hashlib.sha256(test).hexdigest()
|
||||||
|
with open(f'test_{hash}_{cleaned_filename}.sol', 'w', encoding='utf8') as _f:
|
||||||
_f.write(remainder)
|
_f.write(remainder)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user