mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 18:56:53 +00:00
clean up readlines_py2
This commit is contained in:
parent
3a85c8ce96
commit
4d57a20ffd
1 changed files with 2 additions and 16 deletions
|
|
@ -3,7 +3,6 @@ import argparse
|
|||
import ast
|
||||
import contextlib
|
||||
import logging
|
||||
import sys
|
||||
import tokenize
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
|
|
@ -352,13 +351,9 @@ class FileProcessor:
|
|||
lines = self.read_lines_from_filename()
|
||||
return lines
|
||||
|
||||
def _readlines_py2(self):
|
||||
# type: () -> List[str]
|
||||
with open(self.filename) as fd:
|
||||
return fd.readlines()
|
||||
|
||||
def _readlines_py3(self):
|
||||
def read_lines_from_filename(self):
|
||||
# type: () -> List[str]
|
||||
"""Read the lines for a file."""
|
||||
try:
|
||||
with tokenize.open(self.filename) as fd:
|
||||
return fd.readlines()
|
||||
|
|
@ -368,15 +363,6 @@ class FileProcessor:
|
|||
with open(self.filename, encoding="latin-1") as fd:
|
||||
return fd.readlines()
|
||||
|
||||
def read_lines_from_filename(self):
|
||||
# type: () -> List[str]
|
||||
"""Read the lines for a file."""
|
||||
if (2, 6) <= sys.version_info < (3, 0):
|
||||
readlines = self._readlines_py2
|
||||
elif (3, 0) <= sys.version_info < (4, 0):
|
||||
readlines = self._readlines_py3
|
||||
return readlines()
|
||||
|
||||
def read_lines_from_stdin(self):
|
||||
# type: () -> List[str]
|
||||
"""Read the lines from standard in."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue