Lint: Skip checking of functions stolen by python-nose.

python-nose modifies namespaces in a way that confuses pylint. To skip
these PyCheckers' visit_callfunc method must be extended.

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
David Kupka
2015-04-23 14:38:55 +02:00
committed by Tomas Babej
parent 528e9503ed
commit 4a5f5b14c3

View File

@@ -29,7 +29,8 @@ try:
from pylint import checkers
from pylint.lint import PyLinter
from pylint.checkers.typecheck import TypeChecker
from astroid import Class, Instance, Module, InferenceError
from pylint.checkers.utils import safe_infer
from astroid import Class, Instance, Module, InferenceError, Function
from pylint.reporters.text import TextReporter
except ImportError:
print >> sys.stderr, "To use {0}, please install pylint.".format(sys.argv[0])
@@ -58,7 +59,7 @@ class IPATypeChecker(TypeChecker):
'fragment', 'username', 'password', 'hostname', 'port'],
'urlparse.ParseResult': ['params'],
'pytest': ['fixture', 'raises', 'skip', 'yield_fixture', 'mark', 'fail'],
'nose.tools': ['assert_equal', 'assert_raises'],
'unittest.case': ['assertEqual', 'assertRaises'],
'datetime.tzinfo': ['houroffset', 'minoffset', 'utcoffset', 'dst'],
# IPA classes
@@ -130,6 +131,14 @@ class IPATypeChecker(TypeChecker):
super(IPATypeChecker, self).visit_getattr(node)
def visit_callfunc(self, node):
called = safe_infer(node.func)
if isinstance(called, Function):
if called.name in self.ignore.get(called.root().name, []):
return
super(IPATypeChecker, self).visit_callfunc(node)
class IPALinter(PyLinter):
ignore = (TypeChecker,)