Skip to content

Commit 14e3974

Browse files
ganpa3timabbott
authored andcommitted
minor: Change encoding to UTF-8 in open() calls.
open() calls were failing on Windows raising a UnicodeDecodeError error since some files contained Unicode characters. This commit fixes that and makes zulint to run on Windows.
1 parent 025b54f commit 14e3974

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

zulint/custom_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(
5151

5252
def get_line_info_from_file(self, fn: str) -> List[LineTup]:
5353
line_tups = []
54-
with open(fn) as f:
54+
with open(fn, encoding='utf8') as f:
5555
for i, line in enumerate(f):
5656
line_newline_stripped = line.strip('\n')
5757
line_fully_stripped = line_newline_stripped.strip()

zulint/lister.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_ftype(fpath: str, use_shebang: bool) -> str:
1717
return ext[1:]
1818
elif use_shebang:
1919
# opening a file may throw an OSError
20-
with open(fpath) as f:
20+
with open(fpath, encoding='utf8') as f:
2121
first_line = f.readline()
2222
if re.search(r'^#!.*\bpython', first_line):
2323
return 'py'

0 commit comments

Comments
 (0)