From nobody Wed May 8 20:28:04 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=1568309874; cv=none; d=zoho.com; s=zohoarc; b=ey6G2BTu4scuyOhCBBly+C1QEl4jrIsn6asMmd3Hf7hB3cs0jFyoPk3gVv/bkvg/dx0dUaL+NFsg31m9yea5RKDB9YbLYjvqj5BGUQhFDn6UCXQ1sIfkJ+Ar+DTJtUAHZha7qTaJGE224IGjs9eWpmPK+yueC/9RaAv9cyuiPPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568309874; 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=qtHz5ei5pkCFczGbcHcjxUlQF/QJWDJXqtWu4lKA8iI=; b=ENxF8omv3JSGi7e4OsMCdnkAVb1uzthDoWvw8rjR9th/PsgqSuPOqP7zIDBIaJZBWF+p76dbd8Hg8AQ0osJZd6cvgUUOBBBrLh+0wUeDXpswsbbhzoQPvhwX6vYRSZVkBqgV+mmshiHxWHPLCXu4+U324FD+jyq+9Ce8ee0PrR4= 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 1568309873641305.1341050357522; Thu, 12 Sep 2019 10:37:53 -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 63CFA30917AA; Thu, 12 Sep 2019 17:37:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 883145C1B2; Thu, 12 Sep 2019 17:37:47 +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 5D10A2551C; Thu, 12 Sep 2019 17:37:44 +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 x8CHbebf028172 for ; Thu, 12 Sep 2019 13:37:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id D68175D712; Thu, 12 Sep 2019 17:37:40 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D251C5D713 for ; Thu, 12 Sep 2019 17:37:36 +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 F296F30860C9 for ; Thu, 12 Sep 2019 17:37:31 +0000 (UTC) Received: from LAPTOP-24A084V2.localdomain (unknown [27.211.35.99]) by smtp4 (Coremail) with SMTP id JedpCgCHbY5UgnpdwOYJAw--.5457S2; Fri, 13 Sep 2019 01:37:25 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Fri, 13 Sep 2019 01:37:20 +0800 Message-Id: <20190912173720.8886-1-shi_lei@massclouds.com> X-CM-TRANSID: JedpCgCHbY5UgnpdwOYJAw--.5457S2 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUr739UUUUU X-Originating-IP: [27.211.35.99] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiYxkuT1i2k8A3nQAAsM X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 12 Sep 2019 17:37:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 12 Sep 2019 17:37:33 +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.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] 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.41]); Thu, 12 Sep 2019 17:37:51 +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 --- 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; } || : =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: + @$(VC_LIST_EXCEPT) | $(GREP) '\.py$$' | xargs $(FLAKE8) --select E703 \ + | $(GREP) . && { exit 1; } || : =20 # mymain() in test files should use return, not exit, for nicer output sc_prohibit_exit_in_tests: diff --git a/configure.ac b/configure.ac index a8f8b051..93212ca7 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_ERROR(['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