summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-11-29 18:08:51 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-11-29 18:08:51 +0200
commitb751e27cab545061149f1714e96449dfc1d60a9d (patch)
treee40775865d91543ed451bb8a46d1686cd82dab88
parenta5165d34575a4d12a8235e5c090087bfd7814b40 (diff)
downloadpylint-b751e27cab545061149f1714e96449dfc1d60a9d.tar.gz
Don't use .iteritems, it doesn't exist on Python 3. Change some variable names and the name of the builtins module.
-rw-r--r--pylint/checkers/base.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 224c8d6..cd995b6 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -68,11 +68,8 @@ TYPECHECK_COMPARISON_OPERATORS = frozenset(('is', 'is not', '==',
'!=', 'in', 'not in'))
LITERAL_NODE_TYPES = (astroid.Const, astroid.Dict, astroid.List, astroid.Set)
UNITTEST_CASE = 'unittest.case'
-if sys.version_info >= (3, 0):
- TYPE_QNAME = 'builtins.type'
-else:
- TYPE_QNAME = '__builtin__.type'
-
+BUILTINS = six.moves.builtins.__name__
+TYPE_QNAME = "%s.type" % BUILTINS
PY33 = sys.version_info >= (3, 3)
PY3K = sys.version_info >= (3, 0)
PY35 = sys.version_info >= (3, 5)
@@ -92,7 +89,7 @@ EXEMPT_NAME_CATEGORIES = set(('exempt', 'ignore'))
# A mapping from builtin-qname -> symbol, to be used when generating messages
# about dangerous default values as arguments
DEFAULT_ARGUMENT_SYMBOLS = dict(
- zip(['.'.join([astroid.bases.BUILTINS, x]) for x in ('set', 'dict', 'list')],
+ zip(['.'.join([BUILTINS, x]) for x in ('set', 'dict', 'list')],
['set()', '{}', '[]'])
)
REVERSED_COMPS = {'<': '>', '<=': '>=', '>': '<', '>=': '<='}
@@ -1919,16 +1916,16 @@ class MultipleTypesChecker(BaseChecker):
def _check_and_add_messages(self):
assigns = self._assigns.pop()
- for name, args in assigns.iteritems():
+ for name, args in assigns.items():
if len(args) <= 1:
continue
orig_node, orig_type = args[0]
- # check if there is a type in the following nodes that would be
- # different from orig_type
+ # Check if there is a type in the following nodes that would be
+ # different from orig_type.
for redef_node, redef_type in args[1:]:
if redef_type != orig_type:
- orig_type = orig_type.replace('__builtin__.', '')
- redef_type = redef_type.replace('__builtin__.', '')
+ orig_type = orig_type.replace(BUILTINS + ".", '')
+ redef_type = redef_type.replace(BUILTINS + ".", '')
self.add_message('redefined-variable-type', node=redef_node,
args=(name, orig_type, redef_type))
break