Skip to content

Commit a6683e3

Browse files
committed
Fix pylint warnings about encoding not being specified in open() calls
1 parent 941919e commit a6683e3

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def setup(sphinx):
6969
# built documents.
7070
#
7171
# The short X.Y version.
72-
with open('../CMakeLists.txt', 'r') as f:
72+
with open('../CMakeLists.txt', 'r', encoding='utf8') as f:
7373
version = re.search('PROJECT_VERSION "([^"]+)"', f.read()).group(1)
7474
# The full version, including alpha/beta/rc tags.
7575
if os.path.isfile('../prerelease.txt') != True or os.path.getsize('../prerelease.txt') == 0:

docs/ext/html_extra_template_renderer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def render_html_extra_templates(app):
1414
if not os.path.isabs(template_config['target']):
1515
raise RuntimeError(f"Template target path is not absolute: {template_config['target']}")
1616

17-
with open(input_path, 'r') as input_file:
17+
with open(input_path, 'r', encoding='utf8') as input_file:
1818
# This runs Jinja2, which supports rendering {{ }} tags among other things.
1919
rendered_template = app.builder.templates.render_string(
2020
input_file.read(),
2121
template_config['context'],
2222
)
2323

24-
with open(template_config['target'], 'w') as target_file:
24+
with open(template_config['target'], 'w', encoding='utf8') as target_file:
2525
target_file.write(rendered_template)
2626

2727
app.config.html_extra_path.append(template_config['target'])

scripts/endToEndExtraction/remove-testcases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_checks(content, sol_file_path):
6161
constructors.append(line)
6262
if line.startswith("ABI_CHECK") or line.startswith("BOOST_REQUIRE"):
6363
checks.append(line)
64-
with open(sol_file_path, "r") as sol_file:
64+
with open(sol_file_path, "r", encoding='utf8') as sol_file:
6565
sol_constructors = []
6666
sol_checks = []
6767
inside_expectations = False
@@ -118,7 +118,7 @@ def get_tests(e2e_path):
118118

119119
def process_input_file(e2e_path, input_file, interactive):
120120
tests = get_tests(e2e_path)
121-
with open(input_file, "r") as cpp_file:
121+
with open(input_file, "r", encoding='utf8') as cpp_file:
122122
inside_test = False
123123
test_name = ""
124124
inside_extracted_test = False

scripts/endToEndExtraction/verify-testcases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ./soltest --color_output=false --log_level=test_suite -t semanticTests/extracted/ -- --no-smt
88
# --evmonepath /Users/alex/evmone/lib/libevmone.dylib --show-messages > semanticTests.trace
99
#
10-
# verify-testcases.py will compare both traces. If these traces are identical, the extracted tests where
10+
# verify-testcases.py will compare both traces. If these traces are identical, the extracted tests were
1111
# identical with the tests specified in SolidityEndToEndTest.cpp.
1212
#
1313
# pylint: disable=too-many-instance-attributes
@@ -75,7 +75,7 @@ def __init__(self, file):
7575
self.ready = False
7676

7777
def analyse(self):
78-
with open(self.file, "r") as trace_file:
78+
with open(self.file, "r", encoding='utf8') as trace_file:
7979
trace = None
8080
test_case = None
8181
for line in trace_file.readlines():

scripts/regressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def run_cmd(command, logfile=None, env=None):
6767
if not env:
6868
env = os.environ.copy()
6969

70-
with open(logfile, 'w') as logfh:
70+
with open(logfile, 'w', encoding='utf8') as logfh:
7171
with subprocess.Popen(command, shell=True, executable='/bin/bash',
7272
env=env, stdout=logfh,
7373
stderr=subprocess.STDOUT) as proc:
@@ -88,7 +88,7 @@ def process_log(self, logfile):
8888

8989
## Log may contain non ASCII characters, so we simply stringify them
9090
## since they don't matter for regular expression matching
91-
with open(logfile, 'rb') as f:
91+
with open(logfile, 'rb', encoding=None) as f:
9292
rawtext = str(f.read())
9393
return not re.search(self._re_sanitizer_log, rawtext)
9494

scripts/update_bugs_by_version.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def comp(version_string):
1515
return [int(c) for c in version_string.split('.')]
1616

1717
path = os.path.dirname(os.path.realpath(__file__))
18-
with open(path + '/../docs/bugs.json') as bugsFile:
18+
with open(path + '/../docs/bugs.json', encoding='utf8') as bugsFile:
1919
bugs = json.load(bugsFile)
2020

2121
versions = {}
22-
with open(path + '/../Changelog.md') as changelog:
22+
with open(path + '/../Changelog.md', encoding='utf8') as changelog:
2323
for line in changelog:
2424
m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line)
2525
if m:
@@ -36,8 +36,8 @@ def comp(version_string):
3636
value['bugs'] += [bug['name']]
3737

3838
new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': '))
39-
with open(path + '/../docs/bugs_by_version.json', 'r') as bugs_by_version:
39+
with open(path + '/../docs/bugs_by_version.json', 'r', encoding='utf8') as bugs_by_version:
4040
old_contents = bugs_by_version.read()
41-
with open(path + '/../docs/bugs_by_version.json', 'w') as bugs_by_version:
41+
with open(path + '/../docs/bugs_by_version.json', 'w', encoding='utf8') as bugs_by_version:
4242
bugs_by_version.write(new_contents)
4343
sys.exit(old_contents != new_contents)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def extract_test_cases(path):
3636

3737
def extract_and_write(f, path):
3838
if f.endswith('.sol'):
39-
with open(path, 'r') as _f:
39+
with open(path, 'r', encoding='utf8') as _f:
4040
cases = [_f.read()]
4141
else:
4242
cases = extract_test_cases(path)
@@ -46,7 +46,7 @@ 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') as _f:
49+
with open('test_%s_%s.sol' % (hashlib.sha256(test).hexdigest(), cleaned_filename), 'w', encoding='utf8') as _f:
5050
_f.write(remainder)
5151

5252

0 commit comments

Comments
 (0)