From a9225be0fa7bb834cd78609603300d81dcc4d3c9 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 19 Aug 2013 12:18:54 +0200 Subject: [PATCH] Make make-lint compatible with Pylint 1.0 Pylint 1.0 was released[0] and it brings some incompatibilities, as well as a bug[1] that's triggered by FreeIPA code. This patch updates make-lint to be compatible with Pylint 1.0, while keeping support for version 0.26. [0] http://www.logilab.org/blogentry/163292 [1] https://bitbucket.org/logilab/pylint/issue/47 Ticket: https://fedorahosted.org/freeipa/ticket/3865 --- make-lint | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/make-lint b/make-lint index fd7bea213..d9c66a847 100755 --- a/make-lint +++ b/make-lint @@ -28,9 +28,17 @@ from fnmatch import fnmatch, fnmatchcase try: from pylint import checkers from pylint.lint import PyLinter - from pylint.reporters.text import ParseableTextReporter from pylint.checkers.typecheck import TypeChecker - from logilab.astng import Class, Instance, InferenceError + try: + # Pylint 1.0 + from astroid import Class, Instance, InferenceError + from pylint.reporters.text import TextReporter + have_pylint_1_0 = True + except ImportError: + # Older Pylint + from logilab.astng import Class, Instance, InferenceError + from pylint.reporters.text import ParseableTextReporter + have_pylint_1_0 = False except ImportError: print >> sys.stderr, "To use {0}, please install pylint.".format(sys.argv[0]) sys.exit(32) @@ -222,8 +230,13 @@ def main(): if options.errors_only: linter.disable_noerror_messages() linter.enable('F') - linter.set_reporter(ParseableTextReporter()) - linter.set_option('include-ids', True) + if have_pylint_1_0: + linter.set_reporter(TextReporter()) + linter.set_option('msg-template', + '{path}:{line}: [{msg_id}({symbol}), {obj}] {msg})') + else: + linter.set_reporter(ParseableTextReporter()) + linter.set_option('include-ids', True) linter.set_option('reports', False) linter.set_option('persistent', False)