summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSushobhit <31987769+sushobhit27@users.noreply.github.com>2018-05-27 10:42:14 +0530
committerClaudiu Popa <pcmanticore@gmail.com>2018-05-27 13:12:14 +0800
commit8c5256dd2d3dc3cc24fe6b307bf8d683ba38b798 (patch)
treeae70434438a38d11f5b628996b8646102b02cbd1
parent1d4b8c7f17b7b5bdaab26e17a00fd5a434f4b382 (diff)
downloadpylint-git-8c5256dd2d3dc3cc24fe6b307bf8d683ba38b798.tar.gz
Remove six package usages. (#2151)
-rw-r--r--pylint/config.py1
-rwxr-xr-xpylint/epylint.py5
-rw-r--r--pylint/extensions/redefined_variable_type.py4
-rw-r--r--pylint/lint.py22
-rw-r--r--pylint/pyreverse/diadefslib.py4
-rw-r--r--pylint/reporters/__init__.py18
-rw-r--r--pylint/reporters/text.py4
-rw-r--r--pylint/reporters/ureports/__init__.py4
-rw-r--r--pylint/reporters/ureports/nodes.py4
-rw-r--r--pylint/test/test_self.py44
-rw-r--r--pylint/test/unittest_checker_similar.py14
-rw-r--r--pylint/test/unittest_lint.py15
-rw-r--r--pylint/test/unittest_pyreverse_diadefs.py4
-rw-r--r--pylint/test/unittest_reporters_json.py4
-rw-r--r--pylint/test/unittest_reporting.py6
-rw-r--r--pylint/testutils.py9
-rw-r--r--pylint/utils.py31
17 files changed, 79 insertions, 114 deletions
diff --git a/pylint/config.py b/pylint/config.py
index 51294deb7..f2f218e23 100644
--- a/pylint/config.py
+++ b/pylint/config.py
@@ -47,7 +47,6 @@ import sys
import time
import configparser
-from six.moves import range
from pylint import utils
diff --git a/pylint/epylint.py b/pylint/epylint.py
index 0fa21ae7a..9e8f31437 100755
--- a/pylint/epylint.py
+++ b/pylint/epylint.py
@@ -55,8 +55,7 @@ import os.path as osp
import sys
import shlex
from subprocess import Popen, PIPE
-
-import six
+from io import StringIO
def _get_env():
@@ -158,7 +157,7 @@ def py_run(command_options='', return_std=False, stdout=None, stderr=None):
proc_stdout, proc_stderr = process.communicate()
# Return standard output and error
if return_std:
- return six.moves.StringIO(proc_stdout), six.moves.StringIO(proc_stderr)
+ return StringIO(proc_stdout), StringIO(proc_stderr)
return None
diff --git a/pylint/extensions/redefined_variable_type.py b/pylint/extensions/redefined_variable_type.py
index 695c072c7..15478da69 100644
--- a/pylint/extensions/redefined_variable_type.py
+++ b/pylint/extensions/redefined_variable_type.py
@@ -4,15 +4,13 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
-import six
-
import astroid
from pylint.checkers import BaseChecker
from pylint.checkers.utils import check_messages, is_none, node_type
from pylint.interfaces import IAstroidChecker
-BUILTINS = six.moves.builtins.__name__
+BUILTINS = 'builtins'
class MultipleTypesChecker(BaseChecker):
diff --git a/pylint/lint.py b/pylint/lint.py
index 1de6e7e84..8a0c1f222 100644
--- a/pylint/lint.py
+++ b/pylint/lint.py
@@ -61,8 +61,6 @@ import sys
import tokenize
import warnings
-import six
-
import astroid
from astroid.__pkginfo__ import version as astroid_version
from astroid import modutils
@@ -117,7 +115,7 @@ def _merge_stats(stats):
message_stats = stat.pop('by_msg', {})
by_msg.update(message_stats)
- for key, item in six.iteritems(stat):
+ for key, item in stat.items():
if key not in merged:
merged[key] = item
else:
@@ -600,7 +598,7 @@ class PyLinter(config.OptionsManagerMixIn,
self.disable(checker.name)
def disable_noerror_messages(self):
- for msgcat, msgids in six.iteritems(self.msgs_store._msgs_by_category):
+ for msgcat, msgids in self.msgs_store._msgs_by_category.items():
# enable only messages with 'error' severity and above ('fatal')
if msgcat in ['E', 'F']:
for msgid in msgids:
@@ -611,7 +609,7 @@ class PyLinter(config.OptionsManagerMixIn,
def disable_reporters(self):
"""disable all reporters"""
- for _reporters in six.itervalues(self._reports):
+ for _reporters in self._reports.values():
for report_id, _, _ in _reporters:
self.disable_report(report_id)
@@ -723,7 +721,7 @@ class PyLinter(config.OptionsManagerMixIn,
def get_checkers(self):
"""return all available checkers as a list"""
- return [self] + [c for _checkers in six.itervalues(self._checkers)
+ return [self] + [c for _checkers in self._checkers.values()
for c in _checkers if c is not self]
def prepare_checkers(self):
@@ -791,7 +789,7 @@ class PyLinter(config.OptionsManagerMixIn,
child_config = collections.OrderedDict()
filter_options = {'long-help'}
filter_options.update((opt_name for opt_name, _ in self._external_opts))
- for opt_providers in six.itervalues(self._all_options):
+ for opt_providers in self._all_options.values():
for optname, optdict, val in opt_providers.options_and_values():
if optdict.get('deprecated'):
continue
@@ -950,7 +948,7 @@ class PyLinter(config.OptionsManagerMixIn,
self.current_file = filepath or modname
self.stats['by_module'][modname] = {}
self.stats['by_module'][modname]['statement'] = 0
- for msg_cat in six.itervalues(utils.MSG_TYPES):
+ for msg_cat in utils.MSG_TYPES.values():
self.stats['by_module'][modname][msg_cat] = 0
def get_ast(self, filepath, modname):
@@ -1008,7 +1006,7 @@ class PyLinter(config.OptionsManagerMixIn,
MANAGER.always_load_extensions = self.config.unsafe_load_any_extension
MANAGER.extension_package_whitelist.update(
self.config.extension_pkg_whitelist)
- for msg_cat in six.itervalues(utils.MSG_TYPES):
+ for msg_cat in utils.MSG_TYPES.values():
self.stats[msg_cat] = 0
def generate_reports(self):
@@ -1079,7 +1077,7 @@ def report_messages_stats(sect, stats, _):
# don't print this report when we didn't detected any errors
raise exceptions.EmptyReportError()
in_order = sorted([(value, msg_id)
- for msg_id, value in six.iteritems(stats['by_msg'])
+ for msg_id, value in stats['by_msg'].items()
if not msg_id.startswith('I')])
in_order.reverse()
lines = ('message id', 'occurrences')
@@ -1095,7 +1093,7 @@ def report_messages_by_module_stats(sect, stats, _):
by_mod = collections.defaultdict(dict)
for m_type in ('fatal', 'error', 'warning', 'refactor', 'convention'):
total = stats[m_type]
- for module in six.iterkeys(stats['by_module']):
+ for module in stats['by_module'].keys():
mod_total = stats['by_module'][module][m_type]
if total == 0:
percent = 0
@@ -1103,7 +1101,7 @@ def report_messages_by_module_stats(sect, stats, _):
percent = float((mod_total)*100) / total
by_mod[module][m_type] = percent
sorted_result = []
- for module, mod_info in six.iteritems(by_mod):
+ for module, mod_info in by_mod.items():
sorted_result.append((mod_info['error'],
mod_info['warning'],
mod_info['refactor'],
diff --git a/pylint/pyreverse/diadefslib.py b/pylint/pyreverse/diadefslib.py
index eb52bf006..ea2de5866 100644
--- a/pylint/pyreverse/diadefslib.py
+++ b/pylint/pyreverse/diadefslib.py
@@ -14,14 +14,12 @@
"""handle diagram generation options for class diagram or default diagrams
"""
-from six.moves import builtins
-
import astroid
from pylint.pyreverse.diagrams import PackageDiagram, ClassDiagram
from pylint.pyreverse.utils import LocalsVisitor
-BUILTINS_NAME = builtins.__name__
+BUILTINS_NAME = 'builtins'
# diagram generators ##########################################################
diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py
index b39e6654c..004f873bc 100644
--- a/pylint/reporters/__init__.py
+++ b/pylint/reporters/__init__.py
@@ -21,7 +21,6 @@ import locale
import os
import warnings
-import six
CMPS = ['=', '-', '+']
@@ -63,24 +62,9 @@ class BaseReporter(object):
"""set output stream"""
self.out = output or sys.stdout
- if six.PY3:
- encode = lambda self, string: string
- else:
- def encode(self, string):
- if not isinstance(string, six.text_type):
- return string
-
- encoding = (getattr(self.out, 'encoding', None) or
- locale.getpreferredencoding(do_setlocale=False) or
- sys.getdefaultencoding())
- # errors=replace, we don't want to crash when attempting to show
- # source code line that can't be encoded with the current locale
- # settings
- return string.encode(encoding, 'replace')
-
def writeln(self, string=''):
"""write a line in the output buffer"""
- print(self.encode(string), file=self.out)
+ print(string, file=self.out)
def display_reports(self, layout):
"""display results encapsulated in the layout tree"""
diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py
index 563824abc..90f47c769 100644
--- a/pylint/reporters/text.py
+++ b/pylint/reporters/text.py
@@ -21,8 +21,6 @@ import os
import warnings
import sys
-import six
-
from pylint.interfaces import IReporter
from pylint.reporters import BaseReporter
from pylint import utils
@@ -132,7 +130,7 @@ class TextReporter(BaseReporter):
self._template = None
def on_set_current_module(self, module, filepath):
- self._template = six.text_type(self.linter.config.msg_template or self.line_format)
+ self._template = str(self.linter.config.msg_template or self.line_format)
def write_message(self, msg):
"""Convenience method to write a formated message with class default template"""
diff --git a/pylint/reporters/ureports/__init__.py b/pylint/reporters/ureports/__init__.py
index a1dfcd935..eb6fab9f6 100644
--- a/pylint/reporters/ureports/__init__.py
+++ b/pylint/reporters/ureports/__init__.py
@@ -11,7 +11,7 @@ formatted as text and html.
import os
import sys
-import six
+from io import StringIO
class BaseWriter(object):
@@ -86,7 +86,7 @@ class BaseWriter(object):
out = self.out
try:
for child in layout.children:
- stream = six.StringIO()
+ stream = StringIO()
self.out = stream
child.accept(self)
yield stream.getvalue()
diff --git a/pylint/reporters/ureports/nodes.py b/pylint/reporters/ureports/nodes.py
index 740aa15c5..577b1a97e 100644
--- a/pylint/reporters/ureports/nodes.py
+++ b/pylint/reporters/ureports/nodes.py
@@ -8,8 +8,6 @@
A micro report is a tree of layout and content objects.
"""
-from six import string_types
-
class VNode(object):
@@ -97,7 +95,7 @@ class Text(VNode):
super(Text, self).__init__(**kwargs)
#if isinstance(data, unicode):
# data = data.encode('ascii')
- assert isinstance(data, string_types), data.__class__
+ assert isinstance(data, str), data.__class__
self.escaped = escaped
self.data = data
diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py
index 1cc9eeff2..8a46eabe9 100644
--- a/pylint/test/test_self.py
+++ b/pylint/test/test_self.py
@@ -24,8 +24,8 @@ import os
from os.path import join, dirname, abspath
import tempfile
import textwrap
-
-import six
+import configparser
+from io import StringIO
from pylint.lint import Run
from pylint.reporters import BaseReporter
@@ -96,7 +96,7 @@ class TestRunTC(object):
def _runtest(self, args, reporter=None, out=None, code=None):
if out is None:
- out = six.StringIO()
+ out = StringIO()
pylint_code = self._run_pylint(args, reporter=reporter, out=out)
if reporter:
output = reporter.out.getvalue()
@@ -123,22 +123,22 @@ class TestRunTC(object):
return re.sub('^py.+/site-packages/', '', output.replace('\\', '/'), flags=re.MULTILINE)
def _test_output(self, args, expected_output):
- out = six.StringIO()
+ out = StringIO()
self._run_pylint(args, out=out)
actual_output = self._clean_paths(out.getvalue())
assert expected_output.strip() in actual_output.strip()
def test_pkginfo(self):
"""Make pylint check itself."""
- self._runtest(['pylint.__pkginfo__'], reporter=TextReporter(six.StringIO()),
+ self._runtest(['pylint.__pkginfo__'], reporter=TextReporter(StringIO()),
code=0)
def test_all(self):
"""Make pylint check itself."""
reporters = [
- TextReporter(six.StringIO()),
- ColorizedTextReporter(six.StringIO()),
- JSONReporter(six.StringIO())
+ TextReporter(StringIO()),
+ ColorizedTextReporter(StringIO()),
+ JSONReporter(StringIO())
]
self._runtest([join(HERE, 'functional/arguments.py')],
reporter=MultiReporter(reporters), code=2)
@@ -159,8 +159,8 @@ class TestRunTC(object):
self._runtest(['--generate-rcfile'], code=0)
def test_generate_config_option_order(self):
- out1 = six.StringIO()
- out2 = six.StringIO()
+ out1 = StringIO()
+ out2 = StringIO()
self._runtest(['--generate-rcfile'], code=0, out=out1)
self._runtest(['--generate-rcfile'], code=0, out=out2)
output1 = out1.getvalue()
@@ -171,27 +171,27 @@ class TestRunTC(object):
# Test that --generate-rcfile puts symbolic names in the --disable
# option.
- out = six.StringIO()
+ out = StringIO()
self._run_pylint(["--generate-rcfile", "--rcfile="], out=out)
output = out.getvalue()
# Get rid of the pesky messages that pylint emits if the
# configuration file is not found.
master = re.search(r"\[MASTER", output)
- out = six.StringIO(output[master.start():])
- parser = six.moves.configparser.RawConfigParser()
+ out = StringIO(output[master.start():])
+ parser = configparser.RawConfigParser()
parser.readfp(out)
messages = utils._splitstrip(parser.get('MESSAGES CONTROL', 'disable'))
assert 'suppressed-message' in messages
def test_generate_rcfile_no_obsolete_methods(self):
- out = six.StringIO()
+ out = StringIO()
self._run_pylint(["--generate-rcfile"], out=out)
output = out.getvalue()
assert "profile" not in output
def test_inexisting_rcfile(self):
- out = six.StringIO()
+ out = StringIO()
with pytest.raises(IOError) as excinfo:
self._run_pylint(["--rcfile=/tmp/norcfile.txt"], out=out)
assert "The config file /tmp/norcfile.txt doesn't exist!" == str(excinfo.value)
@@ -214,7 +214,7 @@ class TestRunTC(object):
if sys.version_info < (3, 0):
strio = tempfile.TemporaryFile()
else:
- strio = six.StringIO()
+ strio = StringIO()
assert strio.encoding is None
self._runtest([join(HERE, 'regrtest_data/no_stdout_encoding.py'),
'--enable=all'],
@@ -230,13 +230,13 @@ class TestRunTC(object):
def test_py3k_option(self):
# Test that --py3k flag works.
- rc_code = 2 if six.PY2 else 0
+ rc_code = 0
self._runtest([join(HERE, 'functional', 'unpacked_exceptions.py'),
'--py3k'],
code=rc_code)
def test_py3k_jobs_option(self):
- rc_code = 2 if six.PY2 else 0
+ rc_code = 0
self._runtest([join(HERE, 'functional', 'unpacked_exceptions.py'),
'--py3k', '-j 2'],
code=rc_code)
@@ -325,7 +325,7 @@ class TestRunTC(object):
args = [module2, module1,
"--disable=all", "--enable=wrong-import-position",
"-rn", "-sn"]
- out = six.StringIO()
+ out = StringIO()
self._run_pylint(args, out=out)
actual_output = self._clean_paths(out.getvalue().strip())
@@ -351,7 +351,7 @@ class TestRunTC(object):
expected_output=expected)
def test_json_report_when_file_has_syntax_error(self):
- out = six.StringIO()
+ out = StringIO()
module = join(HERE, 'regrtest_data', 'syntax_error.py')
self._runtest([module], code=2, reporter=JSONReporter(out))
output = json.loads(out.getvalue())
@@ -373,7 +373,7 @@ class TestRunTC(object):
assert 'invalid syntax' in message['message'].lower()
def test_json_report_when_file_is_missing(self):
- out = six.StringIO()
+ out = StringIO()
module = join(HERE, 'regrtest_data', 'totally_missing.py')
self._runtest([module], code=1, reporter=JSONReporter(out))
output = json.loads(out.getvalue())
@@ -458,7 +458,7 @@ class TestRunTC(object):
expected_output=expected)
def test_no_crash_with_formatting_regex_defaults(self):
- self._runtest(["--ignore-patterns=a"], reporter=TextReporter(six.StringIO()),
+ self._runtest(["--ignore-patterns=a"], reporter=TextReporter(StringIO()),
code=32)
def test_getdefaultencoding_crashes_with_lc_ctype_utf8(self):
diff --git a/pylint/test/unittest_checker_similar.py b/pylint/test/unittest_checker_similar.py
index 8157b5146..9f3aaa4fe 100644
--- a/pylint/test/unittest_checker_similar.py
+++ b/pylint/test/unittest_checker_similar.py
@@ -11,7 +11,7 @@
import sys
from os.path import join, dirname, abspath
-import six
+from io import StringIO
import pytest
from pylint.checkers import similar
@@ -21,7 +21,7 @@ SIMILAR2 = join(dirname(abspath(__file__)), 'input', 'similar2')
def test_ignore_comments():
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
with pytest.raises(SystemExit) as ex:
similar.Run(['--ignore-comments', SIMILAR1, SIMILAR2])
assert ex.value.code == 0
@@ -46,7 +46,7 @@ TOTAL lines=44 duplicates=10 percent=22.73
def test_ignore_docsrings():
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
with pytest.raises(SystemExit) as ex:
similar.Run(['--ignore-docstrings', SIMILAR1, SIMILAR2])
assert ex.value.code == 0
@@ -78,7 +78,7 @@ TOTAL lines=44 duplicates=13 percent=29.55
def test_ignore_imports():
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
with pytest.raises(SystemExit) as ex:
similar.Run(['--ignore-imports', SIMILAR1, SIMILAR2])
assert ex.value.code == 0
@@ -90,7 +90,7 @@ TOTAL lines=44 duplicates=0 percent=0.00
def test_ignore_nothing():
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
with pytest.raises(SystemExit) as ex:
similar.Run([SIMILAR1, SIMILAR2])
assert ex.value.code == 0
@@ -110,7 +110,7 @@ TOTAL lines=44 duplicates=5 percent=11.36
def test_help():
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
try:
similar.Run(['--help'])
except SystemExit as ex:
@@ -122,7 +122,7 @@ def test_help():
def test_no_args():
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
try:
similar.Run([])
except SystemExit as ex:
diff --git a/pylint/test/unittest_lint.py b/pylint/test/unittest_lint.py
index 22742af63..b8a153f86 100644
--- a/pylint/test/unittest_lint.py
+++ b/pylint/test/unittest_lint.py
@@ -28,9 +28,8 @@ import tempfile
from shutil import rmtree
from os import getcwd, chdir
from os.path import join, basename, dirname, isdir, abspath, sep
-
-import six
-from six.moves import reload_module
+from importlib import reload
+from io import StringIO
from pylint import config, lint
from pylint.lint import PyLinter, Run, preprocess_options, ArgumentPreprocessingError
@@ -244,7 +243,7 @@ def test_pylint_visit_method_taken_in_account(linter):
linter.register_checker(CustomChecker(linter))
linter.open()
- out = six.moves.StringIO()
+ out = StringIO()
linter.set_reporter(text.TextReporter(out))
linter.check('abc')
@@ -510,7 +509,7 @@ def test_python3_checker_disabled(linter):
def test_full_documentation(linter):
- out = six.StringIO()
+ out = StringIO()
linter.print_full_documentation(out)
output = out.getvalue()
# A few spot checks only
@@ -545,7 +544,7 @@ def test_pylint_home():
pylintd = join(tempfile.gettempdir(), '.pylint.d')
os.environ['PYLINTHOME'] = pylintd
try:
- reload_module(config)
+ reload(config)
assert config.PYLINT_HOME == pylintd
finally:
try:
@@ -573,7 +572,7 @@ def test_pylintrc():
assert config.find_pylintrc() is None
finally:
chdir(current_dir)
- reload_module(config)
+ reload(config)
@pytest.mark.usefixtures("pop_pylintrc")
@@ -697,7 +696,7 @@ class TestMessagesStore(object):
msg, checkerref=False)
def test_list_messages(self, store):
- sys.stdout = six.StringIO()
+ sys.stdout = StringIO()
try:
store.list_messages()
output = sys.stdout.getvalue()
diff --git a/pylint/test/unittest_pyreverse_diadefs.py b/pylint/test/unittest_pyreverse_diadefs.py
index 6cdffe649..d8ee000e7 100644
--- a/pylint/test/unittest_pyreverse_diadefs.py
+++ b/pylint/test/unittest_pyreverse_diadefs.py
@@ -12,8 +12,6 @@
unit test for the extensions.diadefslib modules
"""
-import six
-
import pytest
import astroid
@@ -31,7 +29,7 @@ def _process_classes(classes):
def _process_relations(relations):
"""extract relation indices from a relation list"""
result = []
- for rel_type, rels in six.iteritems(relations):
+ for rel_type, rels in relations.items():
for rel in rels:
result.append( (rel_type, rel.from_object.title,
rel.to_object.title) )
diff --git a/pylint/test/unittest_reporters_json.py b/pylint/test/unittest_reporters_json.py
index 00ad766fa..d0862ed0b 100644
--- a/pylint/test/unittest_reporters_json.py
+++ b/pylint/test/unittest_reporters_json.py
@@ -11,7 +11,7 @@
import json
-import six
+from io import StringIO
from pylint.lint import PyLinter
from pylint import checkers
@@ -19,7 +19,7 @@ from pylint.reporters.json import JSONReporter
def test_simple_json_output():
- output = six.StringIO()
+ output = StringIO()
reporter = JSONReporter()
linter = PyLinter(reporter=reporter)
diff --git a/pylint/test/unittest_reporting.py b/pylint/test/unittest_reporting.py
index b5744acdf..7d89e17ea 100644
--- a/pylint/test/unittest_reporting.py
+++ b/pylint/test/unittest_reporting.py
@@ -11,7 +11,7 @@
import warnings
-import six
+from io import StringIO
from pylint.lint import PyLinter
from pylint import checkers
@@ -30,7 +30,7 @@ def disable(disable):
def test_template_option(linter):
- output = six.StringIO()
+ output = StringIO()
linter.reporter.set_output(output)
linter.set_option('msg-template', '{msg_id}:{line:03d}')
linter.open()
@@ -53,7 +53,7 @@ def test_parseable_output_deprecated():
def test_parseable_output_regression():
- output = six.StringIO()
+ output = StringIO()
with warnings.catch_warnings(record=True):
linter = PyLinter(reporter=ParseableTextReporter())
diff --git a/pylint/testutils.py b/pylint/testutils.py
index 925e21999..5456d1635 100644
--- a/pylint/testutils.py
+++ b/pylint/testutils.py
@@ -30,8 +30,7 @@ import sys
import tempfile
import tokenize
-import six
-from six.moves import StringIO
+from io import StringIO
import astroid
from pylint import checkers
@@ -185,7 +184,7 @@ class UnittestLinter(object):
return True
def add_stats(self, **kwargs):
- for name, value in six.iteritems(kwargs):
+ for name, value in kwargs.items():
self.stats[name] = value
return self.stats
@@ -198,7 +197,7 @@ def set_config(**kwargs):
def _wrapper(fun):
@functools.wraps(fun)
def _forward(self):
- for key, value in six.iteritems(kwargs):
+ for key, value in kwargs.items():
setattr(self.checker.config, key, value)
if isinstance(self, CheckerTestCase):
# reopen checker in case, it may be interested in configuration change
@@ -217,7 +216,7 @@ class CheckerTestCase(object):
def setup_method(self):
self.linter = UnittestLinter()
self.checker = self.CHECKER_CLASS(self.linter) # pylint: disable=not-callable
- for key, value in six.iteritems(self.CONFIG):
+ for key, value in self.CONFIG.items():
setattr(self.checker.config, key, value)
self.checker.open()
diff --git a/pylint/utils.py b/pylint/utils.py
index fb8103700..a4eb44b3d 100644
--- a/pylint/utils.py
+++ b/pylint/utils.py
@@ -46,9 +46,6 @@ import tokenize
import warnings
import textwrap
-import six
-from six.moves import zip # pylint: disable=redefined-builtin
-
from astroid import nodes, Module
from astroid import modutils
@@ -65,7 +62,7 @@ MSG_TYPES = {
'E' : 'error',
'F' : 'fatal'
}
-MSG_TYPES_LONG = {v: k for k, v in six.iteritems(MSG_TYPES)}
+MSG_TYPES_LONG = {v: k for k, v in MSG_TYPES.items()}
MSG_TYPES_STATUS = {
'I' : 0,
@@ -340,9 +337,9 @@ class MessagesHandlerMixIn(object):
msgs[msg.msgid] = enable
# sync configuration object
self.config.enable = [self._message_symbol(mid) for mid, val
- in sorted(six.iteritems(msgs)) if val]
+ in sorted(msgs.items()) if val]
self.config.disable = [self._message_symbol(mid) for mid, val
- in sorted(six.iteritems(msgs)) if not val]
+ in sorted(msgs.items()) if not val]
def _message_symbol(self, msgid):
"""Get the message symbol of the given message id
@@ -506,7 +503,7 @@ class MessagesHandlerMixIn(object):
print("Below is a list of all checkers and their features.", file=stream)
print("", file=stream)
- for checker, info in sorted(six.iteritems(by_checker)):
+ for checker, info in sorted(by_checker.items()):
self._print_checker_doc(checker, info, stream=stream)
@staticmethod
@@ -552,7 +549,7 @@ class MessagesHandlerMixIn(object):
title = 'Messages'
print(title, file=stream)
print('^' * len(title), file=stream)
- for msgid, msg in sorted(six.iteritems(msgs),
+ for msgid, msg in sorted(msgs.items(),
key=lambda kv: (_MSG_ORDER.index(kv[0][0]), kv[1])):
msg = build_message_def(checker_name, msgid, msg)
print(msg.format_help(checkerref=False), file=stream)
@@ -578,7 +575,7 @@ class FileState(object):
def collect_block_lines(self, msgs_store, module_node):
"""Walk the AST to collect block level options line numbers."""
- for msg, lines in six.iteritems(self._module_msgs_state):
+ for msg, lines in self._module_msgs_state.items():
self._raw_module_msgs_state[msg] = lines.copy()
orig_state = self._module_msgs_state.copy()
self._module_msgs_state = {}
@@ -613,7 +610,7 @@ class FileState(object):
firstchildlineno = node.body[0].fromlineno
else:
firstchildlineno = last
- for msgid, lines in six.iteritems(msg_state):
+ for msgid, lines in msg_state.items():
for lineno, state in list(lines.items()):
original_lineno = lineno
if first > lineno or last < lineno:
@@ -666,8 +663,8 @@ class FileState(object):
pass
def iter_spurious_suppression_messages(self, msgs_store):
- for warning, lines in six.iteritems(self._raw_module_msgs_state):
- for line, enable in six.iteritems(lines):
+ for warning, lines in self._raw_module_msgs_state.items():
+ for line, enable in lines.items():
if not enable and (warning, line) not in self._ignored_msgs:
yield 'useless-suppression', line, \
(msgs_store.get_msg_display_string(warning),)
@@ -700,7 +697,7 @@ class MessagesStore(object):
@property
def messages(self):
"""The list of all active messages."""
- return six.itervalues(self._messages)
+ return self._messages.values()
def add_renamed_message(self, old_id, old_symbol, new_symbol):
"""Register the old ID and symbol for a warning that was renamed.
@@ -720,7 +717,7 @@ class MessagesStore(object):
:return: A list of MessageDefinition.
"""
message_definitions = []
- for msgid, msg_tuple in sorted(six.iteritems(checker.msgs)):
+ for msgid, msg_tuple in sorted(checker.msgs.items()):
message = build_message_def(checker, msgid, msg_tuple)
message_definitions.append(message)
return message_definitions
@@ -903,7 +900,7 @@ class MessagesStore(object):
def list_messages(self):
"""Output full messages list documentation in ReST format. """
- messages = sorted(six.itervalues(self._messages), key=lambda m: m.msgid)
+ messages = sorted(self._messages.values(), key=lambda m: m.msgid)
for message in messages:
if not message.may_be_emitted():
continue
@@ -973,7 +970,7 @@ class ReportsHandlerMixIn(object):
"""add some stats entries to the statistic dictionary
raise an AssertionError if there is a key conflict
"""
- for key, value in six.iteritems(kwargs):
+ for key, value in kwargs.items():
if key[-1] == '_':
key = key[:-1]
assert key not in self.stats
@@ -1281,7 +1278,7 @@ def _format_option_value(optdict, value):
value = value.pattern
elif optdict.get('type') == 'yn':
value = 'yes' if value else 'no'
- elif isinstance(value, six.string_types) and value.isspace():
+ elif isinstance(value, str) and value.isspace():
value = "'%s'" % value
return value