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
39
make-lint
39
make-lint
@ -26,6 +26,7 @@ import os
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
from fnmatch import fnmatch, fnmatchcase
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
from pylint import checkers
|
||||
@ -220,6 +221,10 @@ def main():
|
||||
dest='fail', default=True, action='store_false')
|
||||
optparser.add_option('--enable-noerror', help='enable warnings and other non-error messages',
|
||||
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()
|
||||
cwd = os.getcwd()
|
||||
@ -306,33 +311,41 @@ def main():
|
||||
linter.set_option('persistent', False)
|
||||
linter.set_option('disable', 'python3')
|
||||
|
||||
linter.check(files)
|
||||
if options.do_lint:
|
||||
linter.check(files)
|
||||
|
||||
if linter.msg_status != 0:
|
||||
print("""
|
||||
if linter.msg_status != 0:
|
||||
print("""
|
||||
===============================================================================
|
||||
Errors were found during the static code check.
|
||||
""", file=sys.stderr)
|
||||
|
||||
if len(linter.missing) > 0:
|
||||
print("There are some missing imports:", file=sys.stderr)
|
||||
for mod in sorted(linter.missing):
|
||||
print(" " + mod, file=sys.stderr)
|
||||
print("""
|
||||
if len(linter.missing) > 0:
|
||||
print("There are some missing imports:", file=sys.stderr)
|
||||
for mod in sorted(linter.missing):
|
||||
print(" " + mod, file=sys.stderr)
|
||||
print("""
|
||||
Please make sure all of the required and optional (python-gssapi, python-rhsm)
|
||||
python packages are installed.
|
||||
""", file=sys.stderr)
|
||||
|
||||
print("""\
|
||||
print("""\
|
||||
If you are certain that any of the reported errors are false positives, please
|
||||
mark them in the source code according to the pylint documentation.
|
||||
===============================================================================
|
||||
""", file=sys.stderr)
|
||||
|
||||
if options.fail:
|
||||
return linter.msg_status
|
||||
else:
|
||||
return 0
|
||||
if options.fail and linter.msg_status != 0:
|
||||
return linter.msg_status
|
||||
|
||||
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
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
Loading…
Reference in New Issue
Block a user