diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-11-29 18:08:51 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-11-29 18:08:51 +0200 |
commit | 0bc64a6fe54a2070726878b2ec8ba4cea7b80db8 (patch) | |
tree | 8de42a31967bebf2935f0917e8a5c4d153d00238 | |
parent | 6343e6acb20afa60bac1d2d6fbacac9c22667a6c (diff) | |
download | pylint-0bc64a6fe54a2070726878b2ec8ba4cea7b80db8.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.py | 19 |
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 |