From 4a5f5b14c3159e3517b2bfefc3e89f16cebe9d4b Mon Sep 17 00:00:00 2001 From: David Kupka Date: Thu, 23 Apr 2015 14:38:55 +0200 Subject: 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 --- make-lint | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/make-lint b/make-lint index 33adf38ff..2dce0d147 100755 --- a/make-lint +++ b/make-lint @@ -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,) -- cgit