diff --git a/scripts/fix-lints.py b/scripts/fix-lints.py index e159532e9af66..f28eaeb018cfc 100755 --- a/scripts/fix-lints.py +++ b/scripts/fix-lints.py @@ -19,16 +19,17 @@ def getpos(line): # try to build log = subprocess.run( ['lake', 'build', leanmodule], - capture_output=True) + capture_output=True, encoding='utf8') if log.returncode == 0: print("no errors 🎉") exit(0) shutil.copyfile(leanfile, leanfile + '.bak') +with open(leanfile + '.bak', encoding='utf8') as fp: + f = list(fp) count = 0 -f = list(open(leanfile + '.bak')) -for l in reversed(log.stderr.decode().splitlines()): +for l in reversed(log.stderr.splitlines()): if 'linter.unusedVariables' in l: line, col = getpos(l) f[line-1] = f[line-1][0:col] + '_' + f[line-1][col:] @@ -42,5 +43,6 @@ def getpos(line): print(f'Fixed {count} warnings', file=sys.stderr) -open(leanfile, 'w').write(''.join(f)) +with open(leanfile, 'w', encoding='utf8') as fp: + fp.write(''.join(f)) os.remove(leanfile + '.bak')