On Fri, Mar 19, 2021 at 06:39:31PM +0100, Andrea Bolognani wrote:
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(a)redhat.com>
---
build-aux/syntax-check.mk | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index 2bd7e2aae4..51a498a897 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -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); \
Not that I'd be against ^this, but I think it might be worth (even for
consistency reasons) to mandate that all Python scripts to use the '.py'
extension explicitly instead and rename the ones that violate this. To support
my argument, there are 34 scripts that use a suffix and 2 (one of which is the
latest CI helper) that don't.
Erik