Fix pylint warnings about encoding not being specified in open() calls

This commit is contained in:
Kamil Śliwak
2021-08-23 19:24:35 +02:00
parent 941919e8ab
commit a6683e3226
7 changed files with 15 additions and 15 deletions
@@ -61,7 +61,7 @@ def get_checks(content, sol_file_path):
constructors.append(line)
if line.startswith("ABI_CHECK") or line.startswith("BOOST_REQUIRE"):
checks.append(line)
with open(sol_file_path, "r") as sol_file:
with open(sol_file_path, "r", encoding='utf8') as sol_file:
sol_constructors = []
sol_checks = []
inside_expectations = False
@@ -118,7 +118,7 @@ def get_tests(e2e_path):
def process_input_file(e2e_path, input_file, interactive):
tests = get_tests(e2e_path)
with open(input_file, "r") as cpp_file:
with open(input_file, "r", encoding='utf8') as cpp_file:
inside_test = False
test_name = ""
inside_extracted_test = False
@@ -7,7 +7,7 @@
# ./soltest --color_output=false --log_level=test_suite -t semanticTests/extracted/ -- --no-smt
# --evmonepath /Users/alex/evmone/lib/libevmone.dylib --show-messages > semanticTests.trace
#
# verify-testcases.py will compare both traces. If these traces are identical, the extracted tests where
# verify-testcases.py will compare both traces. If these traces are identical, the extracted tests were
# identical with the tests specified in SolidityEndToEndTest.cpp.
#
# pylint: disable=too-many-instance-attributes
@@ -75,7 +75,7 @@ class TraceAnalyser:
self.ready = False
def analyse(self):
with open(self.file, "r") as trace_file:
with open(self.file, "r", encoding='utf8') as trace_file:
trace = None
test_case = None
for line in trace_file.readlines():
+2 -2
View File
@@ -67,7 +67,7 @@ class regressor():
if not env:
env = os.environ.copy()
with open(logfile, 'w') as logfh:
with open(logfile, 'w', encoding='utf8') as logfh:
with subprocess.Popen(command, shell=True, executable='/bin/bash',
env=env, stdout=logfh,
stderr=subprocess.STDOUT) as proc:
@@ -88,7 +88,7 @@ class regressor():
## Log may contain non ASCII characters, so we simply stringify them
## since they don't matter for regular expression matching
with open(logfile, 'rb') as f:
with open(logfile, 'rb', encoding=None) as f:
rawtext = str(f.read())
return not re.search(self._re_sanitizer_log, rawtext)
+4 -4
View File
@@ -15,11 +15,11 @@ def comp(version_string):
return [int(c) for c in version_string.split('.')]
path = os.path.dirname(os.path.realpath(__file__))
with open(path + '/../docs/bugs.json') as bugsFile:
with open(path + '/../docs/bugs.json', encoding='utf8') as bugsFile:
bugs = json.load(bugsFile)
versions = {}
with open(path + '/../Changelog.md') as changelog:
with open(path + '/../Changelog.md', encoding='utf8') as changelog:
for line in changelog:
m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line)
if m:
@@ -36,8 +36,8 @@ for key, value in versions.items():
value['bugs'] += [bug['name']]
new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': '))
with open(path + '/../docs/bugs_by_version.json', 'r') as bugs_by_version:
with open(path + '/../docs/bugs_by_version.json', 'r', encoding='utf8') as bugs_by_version:
old_contents = bugs_by_version.read()
with open(path + '/../docs/bugs_by_version.json', 'w') as bugs_by_version:
with open(path + '/../docs/bugs_by_version.json', 'w', encoding='utf8') as bugs_by_version:
bugs_by_version.write(new_contents)
sys.exit(old_contents != new_contents)
@@ -36,7 +36,7 @@ def extract_test_cases(path):
def extract_and_write(f, path):
if f.endswith('.sol'):
with open(path, 'r') as _f:
with open(path, 'r', encoding='utf8') as _f:
cases = [_f.read()]
else:
cases = extract_test_cases(path)
@@ -46,7 +46,7 @@ def write_cases(f, tests):
cleaned_filename = f.replace(".","_").replace("-","_").replace(" ","_").lower()
for test in tests:
remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE)
with open('test_%s_%s.sol' % (hashlib.sha256(test).hexdigest(), cleaned_filename), 'w') as _f:
with open('test_%s_%s.sol' % (hashlib.sha256(test).hexdigest(), cleaned_filename), 'w', encoding='utf8') as _f:
_f.write(remainder)