mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
maint: Use flake8 to check python code
Replace 'sc_prohibit_semicolon_at_eol_in_python' with generic 'sc_flake8' rule to check python code style. Now 'sc_flake8' just check the error E703: 'statement ends with a semicolon'. In future, we could use '--select' to introduce more rules. Signed-off-by: Shi Lei <shi_lei@massclouds.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
caa1b711e8
commit
bc1e4389f5
17
cfg.mk
17
cfg.mk
@ -812,11 +812,13 @@ sc_require_enum_last_marker:
|
|||||||
exit 1; } || :
|
exit 1; } || :
|
||||||
|
|
||||||
# In Python files we don't want to end lines with a semicolon like in C
|
# In Python files we don't want to end lines with a semicolon like in C
|
||||||
sc_prohibit_semicolon_at_eol_in_python:
|
sc_flake8:
|
||||||
@prohibit='^[^#].*\;$$' \
|
@if [ -n "$(FLAKE8)" ]; then \
|
||||||
in_vc_files='\.py$$' \
|
$(VC_LIST_EXCEPT) | $(GREP) '\.py$$' | xargs \
|
||||||
halt='python does not require to end lines with a semicolon' \
|
$(FLAKE8) --select E703 --show-source; \
|
||||||
$(_sc_search_regexp)
|
else \
|
||||||
|
echo '$(ME): skipping test $@: flake8 not installed' 1>&2; \
|
||||||
|
fi
|
||||||
|
|
||||||
# mymain() in test files should use return, not exit, for nicer output
|
# mymain() in test files should use return, not exit, for nicer output
|
||||||
sc_prohibit_exit_in_tests:
|
sc_prohibit_exit_in_tests:
|
||||||
@ -1140,6 +1142,11 @@ syntax-check: spacing-check test-wrap-argv \
|
|||||||
echo "*****************************************************" >&2; \
|
echo "*****************************************************" >&2; \
|
||||||
echo "* cppi not installed, some checks have been skipped *" >&2; \
|
echo "* cppi not installed, some checks have been skipped *" >&2; \
|
||||||
echo "*****************************************************" >&2; \
|
echo "*****************************************************" >&2; \
|
||||||
|
fi; \
|
||||||
|
if [ -z "$(FLAKE8)" ]; then \
|
||||||
|
echo "*****************************************************" >&2; \
|
||||||
|
echo "* flake8 not installed, sc_flake8 has been skipped *" >&2; \
|
||||||
|
echo "*****************************************************" >&2; \
|
||||||
fi
|
fi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -704,6 +704,10 @@ AC_PATH_PROGS([PYTHON], [python3 python2 python])
|
|||||||
if test -z "$PYTHON"; then
|
if test -z "$PYTHON"; then
|
||||||
AC_MSG_ERROR(['python3', 'python2' or 'python' binary is required to build libvirt])
|
AC_MSG_ERROR(['python3', 'python2' or 'python' binary is required to build libvirt])
|
||||||
fi
|
fi
|
||||||
|
AC_PATH_PROG([FLAKE8], [flake8])
|
||||||
|
if test -z "$FLAKE8"; then
|
||||||
|
AC_MSG_WARN(['flake8' binary is required to check python code style])
|
||||||
|
fi
|
||||||
AC_PATH_PROG([PERL], [perl])
|
AC_PATH_PROG([PERL], [perl])
|
||||||
if test -z "$PERL"; then
|
if test -z "$PERL"; then
|
||||||
AC_MSG_ERROR(['perl' binary is required to build libvirt])
|
AC_MSG_ERROR(['perl' binary is required to build libvirt])
|
||||||
|
Loading…
Reference in New Issue
Block a user