From 4d57a20ffd3afed446743c40410a78c6fe7a1a9d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 29 Mar 2021 18:13:11 -0700 Subject: [PATCH] clean up readlines_py2 --- src/flake8/processor.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 30c49ac..20a99de 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -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."""