summaryrefslogtreecommitdiff
path: root/checkers/base.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-08-29 15:48:24 -0400
committerBrett Cannon <brett@python.org>2014-08-29 15:48:24 -0400
commit8e23aa2b179274c9c1b128a8b3daf8d2e24cfd75 (patch)
treec234e08aa390be9bca941e66e508071e5e44a801 /checkers/base.py
parent001469c8272a235b4f62b9b5c3ee248635168ad4 (diff)
parentc2cc31874880d7f0d5bd444c6a3b17fa817e2509 (diff)
downloadpylint-python_6.tar.gz
Merge with defaultpython_6
Diffstat (limited to 'checkers/base.py')
-rw-r--r--checkers/base.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/checkers/base.py b/checkers/base.py
index 298ac5f..501d930 100644
--- a/checkers/base.py
+++ b/checkers/base.py
@@ -43,6 +43,8 @@ from pylint.checkers.utils import (
import re
+import six
+from six.moves import zip
# regex for class/function/variable/constant name
CLASS_NAME_RGX = re.compile('[A-Z_][a-zA-Z0-9]+$')
@@ -175,7 +177,7 @@ def decorated_with_abc(func):
if func.decorators:
for node in func.decorators.nodes:
try:
- infered = node.infer().next()
+ infered = next(node.infer())
except InferenceError:
continue
if infered and infered.qname() in ABC_METHODS:
@@ -380,7 +382,7 @@ class BasicErrorChecker(_BasicChecker):
abc.ABCMeta as metaclass.
"""
try:
- infered = node.func.infer().next()
+ infered = next(node.func.infer())
except astroid.InferenceError:
return
if not isinstance(infered, astroid.Class):
@@ -576,7 +578,7 @@ functions, methods
"""check for various kind of statements without effect"""
expr = node.value
if isinstance(expr, astroid.Const) and isinstance(expr.value,
- basestring):
+ six.string_types):
# treat string statement in a separated message
# Handle PEP-257 attribute docstrings.
# An attribute docstring is defined as being a string right after
@@ -653,7 +655,7 @@ functions, methods
# ordinary_args[i].name == call.args[i].name.
if len(ordinary_args) != len(call.args):
return
- for i in xrange(len(ordinary_args)):
+ for i in range(len(ordinary_args)):
if not isinstance(call.args[i], astroid.Name):
return
if node.args.args[i].name != call.args[i].name:
@@ -674,7 +676,7 @@ functions, methods
# check for dangerous default values as arguments
for default in node.args.defaults:
try:
- value = default.infer().next()
+ value = next(default.infer())
except astroid.InferenceError:
continue
@@ -840,7 +842,7 @@ functions, methods
# Try to see if we have iter().
if isinstance(node.args[0], astroid.CallFunc):
try:
- func = node.args[0].func.infer().next()
+ func = next(node.args[0].func.infer())
except InferenceError:
return
if (getattr(func, 'name', None) == 'iter' and
@@ -893,7 +895,7 @@ _NAME_TYPES = {
def _create_naming_options():
name_options = []
- for name_type, (rgx, human_readable_name) in _NAME_TYPES.iteritems():
+ for name_type, (rgx, human_readable_name) in six.iteritems(_NAME_TYPES):
name_type = name_type.replace('_', '-')
name_options.append((
'%s-rgx' % (name_type,),
@@ -968,12 +970,12 @@ class NameChecker(_BasicChecker):
self._bad_names = {}
def leave_module(self, node):
- for category, all_groups in self._bad_names.iteritems():
+ for category, all_groups in six.iteritems(self._bad_names):
if len(all_groups) < 2:
continue
groups = collections.defaultdict(list)
- min_warnings = sys.maxint
- for group in all_groups.itervalues():
+ min_warnings = sys.maxsize
+ for group in six.itervalues(all_groups):
groups[len(group)].append(group)
min_warnings = min(len(group), min_warnings)
if len(groups[min_warnings]) > 1:
@@ -988,7 +990,7 @@ class NameChecker(_BasicChecker):
@check_messages('blacklisted-name', 'invalid-name')
def visit_class(self, node):
self._check_name('class', node.name, node)
- for attr, anodes in node.instance_attrs.iteritems():
+ for attr, anodes in six.iteritems(node.instance_attrs):
if not list(node.instance_attr_ancestors(attr)):
self._check_name('attr', attr, anodes[0])