From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA02AA04B9; Mon, 7 Sep 2020 11:03:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6E8991BF8A; Mon, 7 Sep 2020 11:03:50 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 07FB61BE0C for ; Mon, 7 Sep 2020 11:03:48 +0200 (CEST) IronPort-SDR: UkLHyXbH03tJNRwr9f1RROSMrLtx4wU5sQ+yqYn+yhyPQ+p55Wc19m4FWtFU7Vs4RAyVC/ulmT qC7PQ9wKcMzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9736"; a="157239129" X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="157239129" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 02:03:48 -0700 IronPort-SDR: Bg/EbHP4snJuYiQZflfwQhOOI4YHxr6DBUDXObBh986Rr7rmJTSr2dU7T0AiKjuy4iF4XY0TKn UzbygAVie/7A== X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="479575307" Received: from bricha3-mobl.ger.corp.intel.com ([10.251.80.24]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 07 Sep 2020 02:03:46 -0700 Date: Mon, 7 Sep 2020 10:03:43 +0100 From: Bruce Richardson To: Stephen Hemminger Cc: dev@dpdk.org Message-ID: <20200907090342.GD312@bricha3-MOBL.ger.corp.intel.com> References: <20200906013133.26360-1-stephen@networkplumber.org> <20200906013133.26360-10-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200906013133.26360-10-stephen@networkplumber.org> Subject: Re: [dpdk-dev] [PATCH 09/11] dpdk-pmdinfo: do not use len(x) to test for empty X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sat, Sep 05, 2020 at 06:31:31PM -0700, Stephen Hemminger wrote: > This fixes the following python lint warnings. > usertools/dpdk-pmdinfo.py:188:11: C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) > usertools/dpdk-pmdinfo.py:196:21: C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) > usertools/dpdk-pmdinfo.py:302:11: C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) > > Signed-off-by: Stephen Hemminger > --- > usertools/dpdk-pmdinfo.py | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py > index d746348f1415..632271e2f1d2 100755 > --- a/usertools/dpdk-pmdinfo.py > +++ b/usertools/dpdk-pmdinfo.py > @@ -185,7 +185,7 @@ def findDate(self, content): > return None > > def parse(self): > - if len(self.contents) < 1: > + if not len(self.contents): Does an empty sequence not directly resolve to false in python? If so, the len should be removable and just use "if not self.contents:" > print("data/%s-pci.ids not found" % self.date) > else: > vendorID = "" > @@ -193,7 +193,7 @@ def parse(self): > for l in self.contents: > if l[0] == "#": > continue > - elif len(l.strip()) == 0: > + elif not l.strip(): > continue > else: > if l.find("\t\t") == 0: > @@ -299,7 +299,7 @@ def parse_pmd_info_string(self, mystring): > except KeyError: > continue > > - if len(pmdinfo["pci_ids"]) != 0: > + if pmdinfo["pci_ids"]: > print("PMD HW SUPPORT:") > if pcidb is not None: > self.pretty_print_pmdinfo(pmdinfo) > -- > 2.27.0 >