diff options
author | Brett Cannon <brett@python.org> | 2014-08-29 15:48:24 -0400 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2014-08-29 15:48:24 -0400 |
commit | 8e23aa2b179274c9c1b128a8b3daf8d2e24cfd75 (patch) | |
tree | c234e08aa390be9bca941e66e508071e5e44a801 /checkers/variables.py | |
parent | 001469c8272a235b4f62b9b5c3ee248635168ad4 (diff) | |
parent | c2cc31874880d7f0d5bd444c6a3b17fa817e2509 (diff) | |
download | pylint-python_6.tar.gz |
Merge with defaultpython_6
Diffstat (limited to 'checkers/variables.py')
-rw-r--r-- | checkers/variables.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/checkers/variables.py b/checkers/variables.py index 71b4be4..6a26f5a 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -33,6 +33,7 @@ from pylint.checkers.utils import ( is_defined_before, is_error, is_func_default, is_func_decorator, assign_parent, check_messages, is_inside_except, clobber_in_except, get_all_elements, has_known_bases) +import six SPECIAL_OBJ = re.compile("^_{2}[a-z]+_{2}$") @@ -45,7 +46,7 @@ def in_for_else_branch(parent, stmt): def overridden_method(klass, name): """get overridden method if any""" try: - parent = klass.local_attr_ancestors(name).next() + parent = next(klass.local_attr_ancestors(name)) except (StopIteration, KeyError): return None try: @@ -145,7 +146,7 @@ def _fix_dot_imports(not_consumed): """ # TODO: this should be improved in issue astroid #46 names = {} - for name, stmts in not_consumed.iteritems(): + for name, stmts in six.iteritems(not_consumed): if any(isinstance(stmt, astroid.AssName) and isinstance(stmt.ass_type(), astroid.AugAssign) for stmt in stmts): @@ -296,7 +297,7 @@ builtins. Remember that you should avoid to define new builtins when possible.' checks globals doesn't overrides builtins """ self._to_consume = [(copy(node.locals), {}, 'module')] - for name, stmts in node.locals.iteritems(): + for name, stmts in six.iteritems(node.locals): if is_builtin(name) and not is_inside_except(stmts[0]): # do not print Redefining builtin for additional builtins self.add_message('redefined-builtin', args=name, node=stmts[0]) @@ -311,16 +312,16 @@ builtins. Remember that you should avoid to define new builtins when possible.' not_consumed = self._to_consume.pop()[0] # attempt to check for __all__ if defined if '__all__' in node.locals: - assigned = node.igetattr('__all__').next() + assigned = next(node.igetattr('__all__')) if assigned is not astroid.YES: for elt in getattr(assigned, 'elts', ()): try: - elt_name = elt.infer().next() + elt_name = next(elt.infer()) except astroid.InferenceError: continue if not isinstance(elt_name, astroid.Const) \ - or not isinstance(elt_name.value, basestring): + or not isinstance(elt_name.value, six.string_types): self.add_message('invalid-all-object', args=elt.as_string(), node=elt) continue @@ -503,7 +504,7 @@ builtins. Remember that you should avoid to define new builtins when possible.' for nonlocal_stmt in node.nodes_of_class(astroid.Nonlocal): nonlocal_names.update(set(nonlocal_stmt.names)) - for name, stmts in not_consumed.iteritems(): + for name, stmts in six.iteritems(not_consumed): # ignore some special names specified by user configuration if authorized_rgx.match(name): continue @@ -829,7 +830,7 @@ builtins. Remember that you should avoid to define new builtins when possible.' for name, _ in node.names: parts = name.split('.') try: - module = node.infer_name_module(parts[0]).next() + module = next(node.infer_name_module(parts[0])) except astroid.ResolveError: continue self._check_module_attrs(node, module, parts[1:]) @@ -916,7 +917,7 @@ builtins. Remember that you should avoid to define new builtins when possible.' module = None break try: - module = module.getattr(name)[0].infer().next() + module = next(module.getattr(name)[0].infer()) if module is astroid.YES: return None except astroid.NotFoundError: |