[libvirt] [PATCH] maint: Use flake8 to check python code

Ján Tomko jtomko at redhat.com
Tue Sep 17 17:46:03 UTC 2019


On Tue, Sep 17, 2019 at 05:37:24PM +0200, Ján Tomko wrote:
>On Fri, Sep 13, 2019 at 01:37:20AM +0800, Shi Lei wrote:
>>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.
>>
>
>Nice, less language parsers using regexes in libvirt!
>
>>Signed-off-by: Shi Lei <shi_lei at massclouds.com>
>>---
>>cfg.mk       | 8 +++-----
>>configure.ac | 4 ++++
>>2 files changed, 7 insertions(+), 5 deletions(-)
>>
>>diff --git a/cfg.mk b/cfg.mk
>>index 42e1abf0..8acc45ac 100644
>>--- a/cfg.mk
>>+++ b/cfg.mk
>>@@ -812,11 +812,9 @@ sc_require_enum_last_marker:
>>	    exit 1; } || :
>>
>># In Python files we don't want to end lines with a semicolon like in C
>>-sc_prohibit_semicolon_at_eol_in_python:
>>-	@prohibit='^[^#].*\;$$' \
>>-	in_vc_files='\.py$$' \
>>-	halt='python does not require to end lines with a semicolon' \
>>-	  $(_sc_search_regexp)
>>+sc_flake8:
>>+	@$(VC_LIST_EXCEPT) | $(GREP) '\.py$$' | xargs $(FLAKE8) --select E703 \
>
>>+		| $(GREP) . && { exit 1; } || :
>
>I don't think this line is necessary - we can just use the return value
>from flake8
>

also, the libvirt-dbus invocation is using --show-source to be more
helpful

Jano

>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190917/9caac478/attachment-0001.sig>


More information about the libvir-list mailing list