summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2022-11-21 14:20:04 -0500
committerGitHub <noreply@github.com>2022-11-21 14:20:04 -0500
commit7498309c2d59ff2ac69e6fae264f507a4ee2feb3 (patch)
treee0d4dacf3d96f59f783c56b08d8319573f618599
parentc5308a75adb2c98a00228083ebe7cd87445a8c36 (diff)
parent956ab1fa7aeffdca4eb1c7b625f8921883e1bc0d (diff)
downloadpep8-7498309c2d59ff2ac69e6fae264f507a4ee2feb3.tar.gz
Merge pull request #1124 from PyCQA/py2-cruft
remove some leftover python 2 compat
-rwxr-xr-xpycodestyle.py12
-rw-r--r--testsuite/test_shell.py7
2 files changed, 8 insertions, 11 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index 7ee2375..b75eed0 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -47,7 +47,9 @@ W warnings
900 syntax error
"""
import bisect
+import configparser
import inspect
+import io
import keyword
import os
import re
@@ -59,12 +61,6 @@ from fnmatch import fnmatch
from functools import lru_cache
from optparse import OptionParser
-try:
- from configparser import RawConfigParser
- from io import TextIOWrapper
-except ImportError:
- from ConfigParser import RawConfigParser
-
# this is a performance hack. see https://bugs.python.org/issue43014
if (
sys.version_info < (3, 10) and
@@ -1769,7 +1765,7 @@ def readlines(filename):
def stdin_get_value():
"""Read the value from stdin."""
- return TextIOWrapper(sys.stdin.buffer, errors='ignore').read()
+ return io.TextIOWrapper(sys.stdin.buffer, errors='ignore').read()
noqa = lru_cache(512)(re.compile(r'# no(?:qa|pep8)\b', re.I).search)
@@ -2558,7 +2554,7 @@ def read_config(options, args, arglist, parser):
merged together (in that order) using the read method of
ConfigParser.
"""
- config = RawConfigParser()
+ config = configparser.RawConfigParser()
cli_conf = options.config
diff --git a/testsuite/test_shell.py b/testsuite/test_shell.py
index 059d882..a2fa35e 100644
--- a/testsuite/test_shell.py
+++ b/testsuite/test_shell.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import configparser
import os.path
import sys
import unittest
@@ -15,7 +16,7 @@ class ShellTestCase(unittest.TestCase):
self._saved_stdout = sys.stdout
self._saved_stderr = sys.stderr
self._saved_pconfig = pycodestyle.PROJECT_CONFIG
- self._saved_cpread = pycodestyle.RawConfigParser._read
+ self._saved_cpread = configparser.RawConfigParser._read
self._saved_stdin_get_value = pycodestyle.stdin_get_value
self._config_filenames = []
self.stdin = ''
@@ -25,7 +26,7 @@ class ShellTestCase(unittest.TestCase):
def fake_config_parser_read(cp, fp, filename):
self._config_filenames.append(filename)
- pycodestyle.RawConfigParser._read = fake_config_parser_read
+ configparser.RawConfigParser._read = fake_config_parser_read
pycodestyle.stdin_get_value = self.stdin_get_value
def tearDown(self):
@@ -33,7 +34,7 @@ class ShellTestCase(unittest.TestCase):
sys.stdout = self._saved_stdout
sys.stderr = self._saved_stderr
pycodestyle.PROJECT_CONFIG = self._saved_pconfig
- pycodestyle.RawConfigParser._read = self._saved_cpread
+ configparser.RawConfigParser._read = self._saved_cpread
pycodestyle.stdin_get_value = self._saved_stdin_get_value
def stdin_get_value(self):