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
|
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,33 +311,41 @@ def main():
|
|||||||
linter.set_option('persistent', False)
|
linter.set_option('persistent', False)
|
||||||
linter.set_option('disable', 'python3')
|
linter.set_option('disable', 'python3')
|
||||||
|
|
||||||
linter.check(files)
|
if options.do_lint:
|
||||||
|
linter.check(files)
|
||||||
|
|
||||||
if linter.msg_status != 0:
|
if linter.msg_status != 0:
|
||||||
print("""
|
print("""
|
||||||
===============================================================================
|
===============================================================================
|
||||||
Errors were found during the static code check.
|
Errors were found during the static code check.
|
||||||
""", file=sys.stderr)
|
""", file=sys.stderr)
|
||||||
|
|
||||||
if len(linter.missing) > 0:
|
if len(linter.missing) > 0:
|
||||||
print("There are some missing imports:", file=sys.stderr)
|
print("There are some missing imports:", file=sys.stderr)
|
||||||
for mod in sorted(linter.missing):
|
for mod in sorted(linter.missing):
|
||||||
print(" " + mod, file=sys.stderr)
|
print(" " + mod, file=sys.stderr)
|
||||||
print("""
|
print("""
|
||||||
Please make sure all of the required and optional (python-gssapi, python-rhsm)
|
Please make sure all of the required and optional (python-gssapi, python-rhsm)
|
||||||
python packages are installed.
|
python packages are installed.
|
||||||
""", file=sys.stderr)
|
""", file=sys.stderr)
|
||||||
|
|
||||||
print("""\
|
print("""\
|
||||||
If you are certain that any of the reported errors are false positives, please
|
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.
|
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:
|
|
||||||
return 0
|
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__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Loading…
Reference in New Issue
Block a user