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
This commit is contained in:
Petr Viktorin
2013-08-19 12:18:54 +02:00
parent 85b974d1bc
commit a9225be0fa

View File

@@ -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)