mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
make-lint: Allow running pylint --py3k to detect Python3 issues
Pylint can be run with the --py3k switch to detect porting issues. This is not compatible with regular checking (i.e. to do all checks, pylint must be run twice, with and without --py3k). So, do an additional run of pylint in a subprocess for the py3k checks. Add a --no-py3k switch to skip the additional py3k run. Also add a --no-lint switch to allow only running the py3 checks. https://fedorahosted.org/freeipa/ticket/5623 Reviewed-By: Jan Cholasta <jcholast@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
parent
5bff350d0d
commit
5d82214787
17
make-lint
17
make-lint
@ -26,6 +26,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from fnmatch import fnmatch, fnmatchcase
|
from fnmatch import fnmatch, fnmatchcase
|
||||||
|
import subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pylint import checkers
|
from pylint import checkers
|
||||||
@ -220,6 +221,10 @@ def main():
|
|||||||
dest='fail', default=True, action='store_false')
|
dest='fail', default=True, action='store_false')
|
||||||
optparser.add_option('--enable-noerror', help='enable warnings and other non-error messages',
|
optparser.add_option('--enable-noerror', help='enable warnings and other non-error messages',
|
||||||
dest='errors_only', default=True, action='store_false')
|
dest='errors_only', default=True, action='store_false')
|
||||||
|
optparser.add_option('--no-py3k', help='Do not check for Python 3 porting issues',
|
||||||
|
dest='py3k', default=True, action='store_false')
|
||||||
|
optparser.add_option('--no-lint', help='Skip the main lint check',
|
||||||
|
dest='do_lint', default=True, action='store_false')
|
||||||
|
|
||||||
options, args = optparser.parse_args()
|
options, args = optparser.parse_args()
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
@ -306,6 +311,7 @@ def main():
|
|||||||
linter.set_option('persistent', False)
|
linter.set_option('persistent', False)
|
||||||
linter.set_option('disable', 'python3')
|
linter.set_option('disable', 'python3')
|
||||||
|
|
||||||
|
if options.do_lint:
|
||||||
linter.check(files)
|
linter.check(files)
|
||||||
|
|
||||||
if linter.msg_status != 0:
|
if linter.msg_status != 0:
|
||||||
@ -329,9 +335,16 @@ mark them in the source code according to the pylint documentation.
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
""", file=sys.stderr)
|
""", file=sys.stderr)
|
||||||
|
|
||||||
if options.fail:
|
if options.fail and linter.msg_status != 0:
|
||||||
return linter.msg_status
|
return linter.msg_status
|
||||||
else:
|
|
||||||
|
if options.py3k:
|
||||||
|
args = ['pylint', '--py3k', '-d', 'no-absolute-import', '--reports=n']
|
||||||
|
args.extend(files)
|
||||||
|
returncode = subprocess.call(args)
|
||||||
|
if options.fail and returncode != 0:
|
||||||
|
return returncode
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user