From nobody Mon Apr 29 11:00:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631527142; cv=none; d=zohomail.com; s=zohoarc; b=RK/CHyzrFyGWAOe41+tRedzRLiiUI6B+97PyUc3ySk8h5gleZ+3F9HvSDPX+Ci+o7gcWzkXHaOvlJDMaaJ5sC5yNzVv7kV1a/EYC5PRbskFDrnijKnYjTx1dHkA9nDyWKzgmPDTTjWSEP19EjBUKqyywVcw1BC30OWW29kWExUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631527142; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ih3xKVtC8HRP3geypL4wwOximBaYMWR1t2LiU50XzGY=; b=DyCaFzbGgCpv2EnyEUP0ZrILbtHMpuu2uV5SDeWk7/EqEPp/95a0oPx8XD6tc0wY0i/SbGqcNrqjIaJaQ+7AcN9ztrlpAZKnPLTX/kUY5qSPyyXr0RkrcNfhUaViOdFd8576OR4JY6XVKsImTHo9LzeIKjJ5jN2fGmWepeT9kSU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631527142065473.0866676574823; Mon, 13 Sep 2021 02:59:02 -0700 (PDT) Received: from localhost ([::1]:57348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPijs-0005kc-Ih for importer@patchew.org; Mon, 13 Sep 2021 05:59:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPic0-00007S-Fg for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPibv-00073y-3w for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-CmEcvYJ4NN6LAzohguJkmQ-1; Mon, 13 Sep 2021 05:50:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1455A1923768; Mon, 13 Sep 2021 09:50:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D61146A257; Mon, 13 Sep 2021 09:50:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6BB97113861E; Mon, 13 Sep 2021 11:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631526646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ih3xKVtC8HRP3geypL4wwOximBaYMWR1t2LiU50XzGY=; b=N0elxKwUn9YJazMv2h46OQZ6oQ0HQNMoE8Vn6uraQTarkGmP7qcOxIQARmXwfHbdUZxCEn zflktNW0Do3jF3q7a8qx2hiqdDUK+nl57qhxC2GiDXKF+coYAimWxbS3lUgWDwz+DzwVcK cUgXt+l9gXPLbfUKWh4+OKVs2kpjiIY= X-MC-Unique: CmEcvYJ4NN6LAzohguJkmQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 1/5] qapi: Fix a botched type annotation Date: Mon, 13 Sep 2021 11:50:34 +0200 Message-Id: <20210913095038.3040776-2-armbru@redhat.com> In-Reply-To: <20210913095038.3040776-1-armbru@redhat.com> References: <20210913095038.3040776-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.393, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631527143660100001 Mypy is unhappy: $ mypy --config-file=3Dscripts/qapi/mypy.ini `git-ls-files scripts/qapi= /\*py` scripts/qapi/common.py:208: error: Function is missing a return type an= notation scripts/qapi/common.py:227: error: Returning Any from function declared= to return "str" Messed up in commit ccea6a8637 "qapi: Factor common recursion out of cgen_ifcond(), docgen_ifcond()". Tidy up. Signed-off-by: Markus Armbruster Message-Id: <20210908045428.2689093-2-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 5f8f76e5b2..c4d11b9637 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -205,7 +205,8 @@ def gen_ifcond(ifcond: Optional[Union[str, Dict[str, An= y]]], cond_fmt: str, not_fmt: str, all_operator: str, any_operator: str) -> str: =20 - def do_gen(ifcond: Union[str, Dict[str, Any]], need_parens: bool): + def do_gen(ifcond: Union[str, Dict[str, Any]], + need_parens: bool) -> str: if isinstance(ifcond, str): return cond_fmt % ifcond assert isinstance(ifcond, dict) and len(ifcond) =3D=3D 1 --=20 2.31.1 From nobody Mon Apr 29 11:00:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631526784; cv=none; d=zohomail.com; s=zohoarc; b=a7wQXqewljbxis9w64x0EIE/cytLcAn84DGD+KdGS13jT8C9IaPiRwM6+i11Rknj7wY8C24wiuJbxefABrP5Srr7kmiV8JKMS9ZdT9WC0cv9/qykZHWbGZKkdDzdXhGonMQowCkhK/+5CHFOUnC4odAxBFa2UHrSFRSXlpK6QAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631526784; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c/c/w4JMkB/UC3DnUfd6qzSk51gfpWLnv30yTdmTG3U=; b=eXxCrLz5KHd4O8l/wZhUWE2ccTUgsHf62hWn6SU4b78RdFjXWdy42eg3hifgdTHqqVEt1fR6rOFBFvEpoWx6JmSgjRGkCTtJLm3ak6W2hcXO6/nCDKqLmdzoodBSubWw/CQgRj3XuGlej7E5QOC5HfAPQy4roA0Glw3wrsgzx+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163152678478369.05769948371005; Mon, 13 Sep 2021 02:53:04 -0700 (PDT) Received: from localhost ([::1]:40956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPie7-00030m-Lz for importer@patchew.org; Mon, 13 Sep 2021 05:53:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPibz-00007Q-QM for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPibu-00073x-Vx for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-AQDaUHSmOOOyyOEEsJ0QGw-1; Mon, 13 Sep 2021 05:50:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AEBA1923767; Mon, 13 Sep 2021 09:50:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D626F10013C1; Mon, 13 Sep 2021 09:50:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6EE6911385C1; Mon, 13 Sep 2021 11:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631526646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c/c/w4JMkB/UC3DnUfd6qzSk51gfpWLnv30yTdmTG3U=; b=iRiu1ifTdhWWynSsr2RplpQvN9BvF0dZwGBl9+At1UDDBjJEMHvjudWsqc11CuNEI79JJL RwFyFp7dubvFKzRc1R8Ou7AnKqtKem0p6oF+tNZ2/RBS/hwiyxgS8NbdhcT7vDeh+77tNr dIBA2vhXVJKCc3YUFnuAhiORnXmsCTY= X-MC-Unique: AQDaUHSmOOOyyOEEsJ0QGw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 2/5] qapi: Drop Indentation.__bool__() Date: Mon, 13 Sep 2021 11:50:35 +0200 Message-Id: <20210913095038.3040776-3-armbru@redhat.com> In-Reply-To: <20210913095038.3040776-1-armbru@redhat.com> References: <20210913095038.3040776-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.393, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631526786566100005 Intentation.__bool__() is not worth its keep: it has just one user, which can just as well check .__str__() instead. Signed-off-by: Markus Armbruster Message-Id: <20210908045428.2689093-3-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index c4d11b9637..1d62c27fb7 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -142,10 +142,6 @@ def __str__(self) -> str: """Return the current indentation as a string of spaces.""" return ' ' * self._level =20 - def __bool__(self) -> bool: - """True when there is a non-zero indentation.""" - return bool(self._level) - def increase(self, amount: int =3D 4) -> None: """Increase the indentation level by ``amount``, default 4.""" self._level +=3D amount @@ -169,8 +165,9 @@ def cgen(code: str, **kwds: object) -> str: Obey `indent`, and strip `EATSPACE`. """ raw =3D code % kwds - if indent: - raw =3D re.sub(r'^(?!(#|$))', str(indent), raw, flags=3Dre.MULTILI= NE) + pfx =3D str(indent) + if pfx: + raw =3D re.sub(r'^(?!(#|$))', pfx, raw, flags=3Dre.MULTILINE) return re.sub(re.escape(EATSPACE) + r' *', '', raw) =20 =20 --=20 2.31.1 From nobody Mon Apr 29 11:00:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631526783; cv=none; d=zohomail.com; s=zohoarc; b=OIezvYBwIxdvSqUyaPqwL25A85zOkcHa2x/OElMQsWMuPbtwiI1T5F2TznS0Vzf2GRtog65NGCJ1BOqj2JmHc4WQNPe6Vf6fCDPMHgEr8GqO7TN7cB0jKtLZA0n3XIHnUR8/GDsRHIExd4HEcdpHdCfPBzHE7GkS3ZAR6ldYsPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631526783; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VY8nXdKF++rgEXHDxaP6rVmtKqQYPp8Al1wjhdpx6WE=; b=WnvxDGiQmFVDMu2e6CQdISqIorIv4ztJcX++mU+s1mM5tuc03i4A80jGBVs9g1Jgem2Xb9q4kPg9iTUYrRQn6bJLC1X9itFOJeguA0+ffiMRkp3Sqa5hszuLQ19GZ9J+cEkFxkPtlnqK2mrSEW/BwdjSNMJeHLn7mF7On5rc68M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631526783225987.4798684329007; Mon, 13 Sep 2021 02:53:03 -0700 (PDT) Received: from localhost ([::1]:40740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPie5-0002rs-6i for importer@patchew.org; Mon, 13 Sep 2021 05:53:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPic0-00007d-2X for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPibv-00073t-40 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-NZOCrbsYPsGZvamOStK9iw-1; Mon, 13 Sep 2021 05:50:44 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C27D7802947; Mon, 13 Sep 2021 09:50:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D63575C1D1; Mon, 13 Sep 2021 09:50:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7494B11385C3; Mon, 13 Sep 2021 11:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631526646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VY8nXdKF++rgEXHDxaP6rVmtKqQYPp8Al1wjhdpx6WE=; b=LX0IA6aI4UE21HKzWhN4fNBp4ww4P+TN1B5HpDOvz4SSXQ/kEhCtIPjN2EqxxHXevQ/J26 K+a+HzkU5h0YsK3kRpfk6Mu3sNn6aId9R9RI+hQxQjKP8LEmugTCTZfB7X2rgF2eP+ec+O dSm12Y1c1EIse8J3yR14UcsJOJnfoIQ= X-MC-Unique: NZOCrbsYPsGZvamOStK9iw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 3/5] qapi: Bury some unused code in class Indentation Date: Mon, 13 Sep 2021 11:50:36 +0200 Message-Id: <20210913095038.3040776-4-armbru@redhat.com> In-Reply-To: <20210913095038.3040776-1-armbru@redhat.com> References: <20210913095038.3040776-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.393, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631526785065100001 .__int__() has never been used. Drop it. .decrease() raises ArithmeticError when asked to decrease indentation level below zero. Nothing catches it. It's a programming error. Dumb down to assert. Signed-off-by: Markus Armbruster Message-Id: <20210908045428.2689093-4-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 1d62c27fb7..489273574a 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -132,9 +132,6 @@ class Indentation: def __init__(self, initial: int =3D 0) -> None: self._level =3D initial =20 - def __int__(self) -> int: - return self._level - def __repr__(self) -> str: return "{}({:d})".format(type(self).__name__, self._level) =20 @@ -148,9 +145,7 @@ def increase(self, amount: int =3D 4) -> None: =20 def decrease(self, amount: int =3D 4) -> None: """Decrease the indentation level by ``amount``, default 4.""" - if self._level < amount: - raise ArithmeticError( - f"Can't remove {amount:d} spaces from {self!r}") + assert amount <=3D self._level self._level -=3D amount =20 =20 --=20 2.31.1 From nobody Mon Apr 29 11:00:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631526785; cv=none; d=zohomail.com; s=zohoarc; b=GzzhcTWlPkCsxjwqYq+WSRqZVn7839o3wNR/as3qvaPpsy1HGDXbbfBDgLQQNleJjGYSn99mWJ0bM+o8GskxsV8V3zHVOE40E7gPJ8El4dxIK/+jrhFgJthKfKSVUT5JXzkG9NPNepqgGewD0MkXB9oTk8RjBwTLPu0yqV3VviA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631526785; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aWJ1+qMZuVE1HEQOHLA/fWb79Jty5MZ57lUwzgr/ADM=; b=ExfYSpDz8ItKV/OOHfgL4miAonsf63fxy9ejRtbXeM7LcOlLJ8Y8gKrcDHg5chAJBbkXCZjhpn1wVl2GtQUt7lwpsnGKfySvCcZ32reb8srvn4XpjJqpmQCsdIIKXqM+sdyhkRVtq4D4Nc4UasG2MmQW9W2jFWjcy/AIO0b1KDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631526785143845.6354309009471; Mon, 13 Sep 2021 02:53:05 -0700 (PDT) Received: from localhost ([::1]:40844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPie8-0002vp-0l for importer@patchew.org; Mon, 13 Sep 2021 05:53:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPic0-000080-Ol for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPibv-00074H-Kj for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-Y7uqJXr0Mlu0BvnqHVIe0g-1; Mon, 13 Sep 2021 05:50:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19424824FAB; Mon, 13 Sep 2021 09:50:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D61E45D9DD; Mon, 13 Sep 2021 09:50:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7590D1138526; Mon, 13 Sep 2021 11:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631526646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aWJ1+qMZuVE1HEQOHLA/fWb79Jty5MZ57lUwzgr/ADM=; b=QjGOpFepQTSkSCSBbo4GV+wYKGnWBEyFEF5LGIfAEPC1QwiHiiFrDb2pqrmgyQOrqtJq+l 5I/lRLPyVYVT8EBx3O3tA9B4HfEKK0zCNSrkxKG9zcdaU6MvGko75Bp+QRVaekTT6NjcS0 p0x1ErI6GVudpkApdk/NMSq00TDAonQ= X-MC-Unique: Y7uqJXr0Mlu0BvnqHVIe0g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 4/5] tests/qapi-schema: Cover 'not' condition with empty argument Date: Mon, 13 Sep 2021 11:50:37 +0200 Message-Id: <20210913095038.3040776-5-armbru@redhat.com> In-Reply-To: <20210913095038.3040776-1-armbru@redhat.com> References: <20210913095038.3040776-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.393, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631527688979100001 We flag this, but the error message is bogus: bad-if-not.json:2: 'if' condition [] of struct is useless The next commit will fix it. Signed-off-by: Markus Armbruster Message-Id: <20210908045428.2689093-5-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/qapi-schema/bad-if-not.err | 2 ++ tests/qapi-schema/bad-if-not.json | 3 +++ tests/qapi-schema/bad-if-not.out | 0 tests/qapi-schema/meson.build | 1 + 4 files changed, 6 insertions(+) create mode 100644 tests/qapi-schema/bad-if-not.err create mode 100644 tests/qapi-schema/bad-if-not.json create mode 100644 tests/qapi-schema/bad-if-not.out diff --git a/tests/qapi-schema/bad-if-not.err b/tests/qapi-schema/bad-if-no= t.err new file mode 100644 index 0000000000..b3acdd679a --- /dev/null +++ b/tests/qapi-schema/bad-if-not.err @@ -0,0 +1,2 @@ +bad-if-not.json: In struct 'TestIfStruct': +bad-if-not.json:2: 'if' condition [] of struct is useless diff --git a/tests/qapi-schema/bad-if-not.json b/tests/qapi-schema/bad-if-n= ot.json new file mode 100644 index 0000000000..9fdaacc47b --- /dev/null +++ b/tests/qapi-schema/bad-if-not.json @@ -0,0 +1,3 @@ +# check 'if not' with empy argument +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': { 'not': '' } } diff --git a/tests/qapi-schema/bad-if-not.out b/tests/qapi-schema/bad-if-no= t.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 4697c070bc..6b2a4ce41a 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -43,6 +43,7 @@ schemas =3D [ 'bad-if-key.json', 'bad-if-keys.json', 'bad-if-list.json', + 'bad-if-not.json', 'bad-type-bool.json', 'bad-type-dict.json', 'bad-type-int.json', --=20 2.31.1 From nobody Mon Apr 29 11:00:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631526999; cv=none; d=zohomail.com; s=zohoarc; b=W7ukj8F/6oE8HatrNOWR3hcXem26UelRYk+S+ZUCI8xskazrBpY2k1El+d7/5G05V+9h8/lm+C1rIFtzYFUQSrmqOfb7Rph2DQcXjaS+oWXY3Lh2EZm/+/hEiw1kfL8nrp0IKl4nIgAcxZvB45XmFu1Nlco/duRmuix7SngNzCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631526999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IszLxmNLRVkvuJ11uy2cGGtATxpF8YT7u4EJBLAz7lI=; b=d4+oJf2CqOSGRSHayf7ZP3VRsrWAGdg9SJ/Bohpqo9Z53yDTRg7TKc/LIi7b51qZyGGB1Z87iJeIRx7XPsgB6goQ5aNDoyE6ggpnh+m6MqoyC+dBcWJV+rC/Ou8dYMyTNASE6xVbNhNjHTlQWODQX0ZDA2DNEnF4j97fja9RbDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631526999681922.2299958881495; Mon, 13 Sep 2021 02:56:39 -0700 (PDT) Received: from localhost ([::1]:48838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPiha-0008Ky-Cg for importer@patchew.org; Mon, 13 Sep 2021 05:56:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPic0-00007h-5v for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30134) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPibv-000741-4x for qemu-devel@nongnu.org; Mon, 13 Sep 2021 05:50:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-syt8uaFNMK-DCOvGeeXlhQ-1; Mon, 13 Sep 2021 05:50:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D30DEC1A7; Mon, 13 Sep 2021 09:50:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53D1960853; Mon, 13 Sep 2021 09:50:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7B0E51138529; Mon, 13 Sep 2021 11:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631526646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IszLxmNLRVkvuJ11uy2cGGtATxpF8YT7u4EJBLAz7lI=; b=NVDTnGroZsmpJw1imGRyfA8CV30890gpZn3lttQtQdhDd9Nwv9yqUi95DuLduYnpli5LQv 1ml/oQcmqfv8XJ5TBsHO5FeEIFUbo9Zjw2PTZsHTffwuncGdNBiJ7D77x213xenXQ1Tdxr oy+C5FS5m7js6qSwf3XJlaUSlYl5Gm4= X-MC-Unique: syt8uaFNMK-DCOvGeeXlhQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 5/5] qapi: Fix bogus error for 'if': { 'not': '' } Date: Mon, 13 Sep 2021 11:50:38 +0200 Message-Id: <20210913095038.3040776-6-armbru@redhat.com> In-Reply-To: <20210913095038.3040776-1-armbru@redhat.com> References: <20210913095038.3040776-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.393, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631527002310100001 Signed-off-by: Markus Armbruster Message-Id: <20210908045428.2689093-6-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau [check_infix()'s type hint fixed] --- scripts/qapi/expr.py | 21 +++++++++++++-------- tests/qapi-schema/bad-if-not.err | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index b62f0a3640..90bde501b0 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -293,17 +293,22 @@ def _check_if(cond: Union[str, object]) -> None: info, "'if' condition of %s has conflicting keys" % source) =20 - oper, operands =3D next(iter(cond.items())) + if 'not' in cond: + _check_if(cond['not']) + elif 'all' in cond: + _check_infix('all', cond['all']) + else: + _check_infix('any', cond['any']) + + def _check_infix(operator: str, operands: object) -> None: + if not isinstance(operands, list): + raise QAPISemError( + info, + "'%s' condition of %s must be an array" + % (operator, source)) if not operands: raise QAPISemError( info, "'if' condition [] of %s is useless" % source) - - if oper =3D=3D "not": - _check_if(operands) - return - if oper in ("all", "any") and not isinstance(operands, list): - raise QAPISemError( - info, "'%s' condition of %s must be an array" % (oper, sou= rce)) for operand in operands: _check_if(operand) =20 diff --git a/tests/qapi-schema/bad-if-not.err b/tests/qapi-schema/bad-if-no= t.err index b3acdd679a..b33f5e16b8 100644 --- a/tests/qapi-schema/bad-if-not.err +++ b/tests/qapi-schema/bad-if-not.err @@ -1,2 +1,2 @@ bad-if-not.json: In struct 'TestIfStruct': -bad-if-not.json:2: 'if' condition [] of struct is useless +bad-if-not.json:2: 'if' condition '' of struct is not a valid identifier --=20 2.31.1