Skip to content

Commit 67d89b9

Browse files
authored
Quick fix for --linecount-report if a file contains non-ASCII text. (#1949)
1 parent 0b82463 commit 67d89b9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mypy/report.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def __init__(self, reports: Reports, output_dir: str) -> None:
7676
stats.ensure_dir_exists(output_dir)
7777

7878
def on_file(self, tree: MypyFile, type_map: Dict[Node, Type]) -> None:
79-
physical_lines = len(open(tree.path).readlines())
79+
# Count physical lines. This assumes the file's encoding is a
80+
# superset of ASCII (or at least uses \n in its line endings).
81+
physical_lines = len(open(tree.path, 'rb').readlines())
8082

8183
func_counter = FuncCounterVisitor()
8284
tree.accept(func_counter)

0 commit comments

Comments
 (0)