]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
syntax-check: Run flake8 on all Python scripts
authorAndrea Bolognani <abologna@redhat.com>
Fri, 19 Mar 2021 13:24:19 +0000 (14:24 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 22 Mar 2021 11:05:18 +0000 (12:05 +0100)
Currenty we only check files that end in .py, but we have at
least a couple of scripts that don't have that suffix and we
nonetheless want to keep compliant with the code style.

Extend the sc_flake8 syntax-check rule so that any file that
contains a Python 3 shebang is fed to flake8 too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
build-aux/syntax-check.mk

index 2bd7e2aae4d9f1730093be9546567eba105f7934..51a498a8976851b9e2668c37fd3c0993e7ab4b2d 100644 (file)
@@ -877,8 +877,10 @@ FLAKE8_IGNORE = E501,W504
 
 sc_flake8:
        @if [ -n "$(FLAKE8)" ]; then \
-               $(VC_LIST_EXCEPT) | $(GREP) '\.py$$' | xargs \
-                       $(FLAKE8) --ignore $(FLAKE8_IGNORE) --show-source; \
+               DOT_PY=$$($(VC_LIST_EXCEPT) | $(GREP) '\.py$$'); \
+               BANG_PY=$$($(VC_LIST_EXCEPT) | xargs grep -l '^#!/usr/bin/env python3$$'); \
+               ALL_PY=$$(printf "%s\n%s" "$$DOT_PY" "$$BANG_PY" | sort -u); \
+               echo "$$ALL_PY" | xargs $(FLAKE8) --ignore $(FLAKE8_IGNORE) --show-source; \
        else \
                echo '$(ME): skipping test $@: flake8 not installed' 1>&2; \
        fi