Skip to content

Commit 4d57a20

Browse files
committedMar 31, 2021
clean up readlines_py2
1 parent 3a85c8c commit 4d57a20

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed
 

‎src/flake8/processor.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import ast
44
import contextlib
55
import logging
6-
import sys
76
import tokenize
87
from typing import Any
98
from typing import Dict
@@ -352,13 +351,9 @@ def read_lines(self):
352351
lines = self.read_lines_from_filename()
353352
return lines
354353

355-
def _readlines_py2(self):
356-
# type: () -> List[str]
357-
with open(self.filename) as fd:
358-
return fd.readlines()
359-
360-
def _readlines_py3(self):
354+
def read_lines_from_filename(self):
361355
# type: () -> List[str]
356+
"""Read the lines for a file."""
362357
try:
363358
with tokenize.open(self.filename) as fd:
364359
return fd.readlines()
@@ -368,15 +363,6 @@ def _readlines_py3(self):
368363
with open(self.filename, encoding="latin-1") as fd:
369364
return fd.readlines()
370365

371-
def read_lines_from_filename(self):
372-
# type: () -> List[str]
373-
"""Read the lines for a file."""
374-
if (2, 6) <= sys.version_info < (3, 0):
375-
readlines = self._readlines_py2
376-
elif (3, 0) <= sys.version_info < (4, 0):
377-
readlines = self._readlines_py3
378-
return readlines()
379-
380366
def read_lines_from_stdin(self):
381367
# type: () -> List[str]
382368
"""Read the lines from standard in."""

0 commit comments

Comments
 (0)
Please sign in to comment.