summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--checkers/classes.py12
-rw-r--r--checkers/variables.py13
-rw-r--r--testutils.py3
3 files changed, 16 insertions, 12 deletions
diff --git a/checkers/classes.py b/checkers/classes.py
index fc2e2d6ec..6dd5df098 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2003-2014 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
@@ -16,7 +16,9 @@
"""classes checker for Python code
"""
from __future__ import generators
+
import sys
+
import astroid
from astroid import YES, Instance, are_exclusive, AssAttr
from astroid.bases import Generator
@@ -518,8 +520,8 @@ a metaclass class method.'}
for attr, nodes in accessed.iteritems():
# deactivate "except doesn't do anything", that's expected
# pylint: disable=W0704
- # is it a class attribute ?
try:
+ # is it a class attribute ?
node.local_attr(attr)
# yes, stop here
continue
@@ -547,8 +549,8 @@ a metaclass class method.'}
for _node in nodes:
if _node.frame() is frame and _node.fromlineno < lno \
and not are_exclusive(_node.statement(), defstmt, ('AttributeError', 'Exception', 'BaseException')):
- self.add_message('access-member-before-definition', node=_node,
- args=(attr, lno))
+ self.add_message('access-member-before-definition',
+ node=_node, args=(attr, lno))
def _check_first_arg_for_type(self, node, metaclass=0):
"""check the name of first argument, expect:
@@ -685,7 +687,7 @@ a metaclass class method.'}
"""check that the __init__ method call super or ancestors'__init__
method
"""
- if (not self.linter.is_message_enabled('super-init-not-called') and
+ if (not self.linter.is_message_enabled('super-init-not-called') and
not self.linter.is_message_enabled('non-parent-init-called')):
return
klass_node = node.parent.frame()
diff --git a/checkers/variables.py b/checkers/variables.py
index cdf6c22a9..73fdcc066 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -210,7 +210,8 @@ builtins. Remember that you should avoid to define new builtins when possible.'
except astroid.InferenceError:
continue
- if not isinstance(elt_name, astroid.Const) or not isinstance(elt_name.value, basestring):
+ if not isinstance(elt_name, astroid.Const) \
+ or not isinstance(elt_name.value, basestring):
self.add_message('E0604', args=elt.as_string(), node=elt)
continue
elt_name = elt_name.value
@@ -230,8 +231,8 @@ builtins. Remember that you should avoid to define new builtins when possible.'
try:
file_from_modpath(name.split("."))
except ImportError:
- self.add_message('undefined-all-variable',
- args=elt_name,
+ self.add_message('undefined-all-variable',
+ args=elt_name,
node=elt)
except SyntaxError, exc:
# don't yield an syntax-error warning,
@@ -547,10 +548,10 @@ builtins. Remember that you should avoid to define new builtins when possible.'
elif self._to_consume[-1][-1] != 'lambda':
# E0601 may *not* occurs in lambda scope
self.add_message('E0601', args=name, node=node)
- if not isinstance(node, astroid.AssName): # Aug AssName
- del to_consume[name]
- else:
+ if isinstance(node, astroid.AssName): # Aug AssName
del consumed[name]
+ else:
+ del to_consume[name]
# check it's not a loop variable used outside the loop
self._loopvar_name(node, name)
break
diff --git a/testutils.py b/testutils.py
index 8d8064dd7..d60ab4670 100644
--- a/testutils.py
+++ b/testutils.py
@@ -263,7 +263,8 @@ class LintTestUsingModule(testlib.TestCase):
self._test(tocheck)
def _check_result(self, got):
- self.assertMultiLineEqual(self._get_expected().strip(), got.strip())
+ self.assertMultiLineEqual(self._get_expected().strip()+'\n',
+ got.strip()+'\n')
def _test(self, tocheck):
if INFO_TEST_RGX.match(self.module):