From nobody Thu May 2 19:02:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568780438; cv=none; d=zoho.com; s=zohoarc; b=fnMJI1/FAiKVLRRZL3aEpxi8nJ3mrBLBSMyvO7N7b/N1AJGYHiaIGMyET5GDtaI3LioQ5KiVFON9aAVXwLTkATRWOEwGO+Q5bFvnlQJFxv9fHpk0aK7x0LIx8lePgOD2ELqbizcQb+XmutHB7fcFtSrwvA6in/xJ7TkkYIqN+6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568780438; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=F+EDIW6dEd9n6uZT6SMNmBGUrz3NIBhVdt006Vr8+AQ=; b=L5sacGwOsoDdob4C96KtaiYthDRKCi8TKJ0Ee72ofl4RTXHua0jbLtxk/oR8qqXOTPvFawOS2dI1aiCicnIiYTIlXecVpuquqIcguFldwj3gpr9TzXwViUc5rIuJro1TZ04G8BNykIUkvikuFGj8kj4Ndxo13Utc+eXYC0mAqLg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568780438372759.2886111496151; Tue, 17 Sep 2019 21:20:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BAE1308212D; Wed, 18 Sep 2019 04:20:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D3EA5C219; Wed, 18 Sep 2019 04:20:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D11351802216; Wed, 18 Sep 2019 04:20:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8I4KSCp027933 for ; Wed, 18 Sep 2019 00:20:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54B6D5D6C8; Wed, 18 Sep 2019 04:20:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx24.extmail.prod.ext.phx2.redhat.com [10.5.110.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E71F5D6B2 for ; Wed, 18 Sep 2019 04:20:26 +0000 (UTC) Received: from mail-m24147.qiye.163.com (mail-m24147.qiye.163.com [220.194.24.147]) by mx1.redhat.com (Postfix) with ESMTP id 0A78410CC1E0 for ; Wed, 18 Sep 2019 04:20:21 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp4 (Coremail) with SMTP id JedpCgDHjY2BsIFdk0gzAw--.1034S2; Wed, 18 Sep 2019 12:20:18 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 18 Sep 2019 12:19:43 +0800 Message-Id: <20190918041943.21832-1-shi_lei@massclouds.com> X-CM-TRANSID: JedpCgDHjY2BsIFdk0gzAw--.1034S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAF45Xw1xur4UXF15AF15XFb_yoW5GF15pF 4fJr1DJF1UJryxAF17Jw4q9r1UWryxWF4UJwn7Xr1UXr1UJ3WDWrsFqryfAry8WrsaqFWY yr1DAF15Ww4DCFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UHv3nUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiYAQ0T1i2k5YUDwAAsv X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Wed, 18 Sep 2019 04:20:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Wed, 18 Sep 2019 04:20:21 +0000 (UTC) for IP:'220.194.24.147' DOMAIN:'mail-m24147.qiye.163.com' HELO:'mail-m24147.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: 0.002 (RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE) 220.194.24.147 mail-m24147.qiye.163.com 220.194.24.147 mail-m24147.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.65 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2] maint: Use flake8 to check python code X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 18 Sep 2019 04:20:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Replace 'sc_prohibit_semicolon_at_eol_in_python' with generic 'sc_flake8' r= ule 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 Reviewed-by: J=C3=A1n Tomko --- v1: https://www.redhat.com/archives/libvir-list/2019-September/msg00501.html since v1: - Use the return-value from flake8 directly for 'sc_flake8'. - Add the option '--show-source' to be more helpful for developers. - Set checking for 'flake8' as a soft requirement. cfg.mk | 17 ++++++++++++----- configure.ac | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cfg.mk b/cfg.mk index 42e1abf0..a7c88383 100644 --- a/cfg.mk +++ b/cfg.mk @@ -812,11 +812,13 @@ sc_require_enum_last_marker: exit 1; } || : =20 # In Python files we don't want to end lines with a semicolon like in C -sc_prohibit_semicolon_at_eol_in_python: - @prohibit=3D'^[^#].*\;$$' \ - in_vc_files=3D'\.py$$' \ - halt=3D'python does not require to end lines with a semicolon' \ - $(_sc_search_regexp) +sc_flake8: + @if [ -n "$(FLAKE8)" ]; then \ + $(VC_LIST_EXCEPT) | $(GREP) '\.py$$' | xargs \ + $(FLAKE8) --select E703 --show-source; \ + else \ + echo '$(ME): skipping test $@: flake8 not installed' 1>&2; \ + fi =20 # mymain() in test files should use return, not exit, for nicer output sc_prohibit_exit_in_tests: @@ -1140,6 +1142,11 @@ syntax-check: spacing-check test-wrap-argv \ echo "*****************************************************" >&2; \ echo "* cppi not installed, some checks have been skipped *" >&2; \ echo "*****************************************************" >&2; \ + fi; \ + if [ -z "$(FLAKE8)" ]; then \ + echo "*****************************************************" >&2; \ + echo "* flake8 not installed, sc_flake8 has been skipped *" >&2; \ + echo "*****************************************************" >&2; \ fi endif =20 diff --git a/configure.ac b/configure.ac index 41d3da3e..286b9f7a 100644 --- a/configure.ac +++ b/configure.ac @@ -704,6 +704,10 @@ AC_PATH_PROGS([PYTHON], [python3 python2 python]) if test -z "$PYTHON"; then AC_MSG_ERROR(['python3', 'python2' or 'python' binary is required to b= uild libvirt]) 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]) if test -z "$PERL"; then AC_MSG_ERROR(['perl' binary is required to build libvirt]) --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list