From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612398845; cv=none; d=zohomail.com; s=zohoarc; b=WzeWj3cCJArU1wwdvCBpI22IJuyTbVJ9nXGIk4fTDlWvLQia5bn/fLeVsLxOpSTChCSsMfSlMxFtPUuH/C7r8oIp5IlrFwxcZQ4ki6N0XvzrWxVs1roCrqyeTasEUFFHnBJzmxSGbAh/aq4cJL88UaJko66Qj995KKdTTU/wV9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612398845; 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=XWr0AcRlsQez5Aq3NxYWxDa4M/wcTgndy6zggib5YUk=; b=Ds0FogFypaDheBSXRnWJlilzWsxXIek7PLJHIoWWGWE4NsDkCs96uLH7+aAnQBfHvjLRgLb/3vFBxD4t0mRm+Vjm4nK2UQ16jzdfks9+8odIO7YxzyZK79Xk2OAdZPs7fvWac5VT98rUULS2TasZMEh7pfTWFHxaUrEd/vecbTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612398845686295.39246215293144; Wed, 3 Feb 2021 16:34:05 -0800 (PST) Received: from localhost ([::1]:36670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Say-0002wW-9a for importer@patchew.org; Wed, 03 Feb 2021 19:34:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZN-0001Cp-04 for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZA-0000aS-Cz for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:23 -0500 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-304-Fj-bBDqWMKy2IsZC50l0lQ-1; Wed, 03 Feb 2021 19:32:09 -0500 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 EB890108C27B for ; Thu, 4 Feb 2021 00:32:08 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EB0F100AE4A; Thu, 4 Feb 2021 00:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398731; 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=XWr0AcRlsQez5Aq3NxYWxDa4M/wcTgndy6zggib5YUk=; b=MYBYAerQ77Ai2jbPvWD+UcVmpEOit63mSJD5JylFC2ytk9gzUMI2e9at8Add8nwG+OJfIT YZ7HMfUDmQeHQJbQTCJnwZsd4Q1WEDS6sXiX0TNL+pGaaRh6wcG4JyljO9EZ9Rg3Ux7ZrW YOvbpFnyK4Mjdh2Cg1u8yc0UtuDQJZg= X-MC-Unique: Fj-bBDqWMKy2IsZC50l0lQ-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 01/15] qapi/introspect.py: assert schema is not None Date: Wed, 3 Feb 2021 19:31:53 -0500 Message-Id: <20210204003207.2856909-2-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The introspect visitor is stateful, but expects that it will have a schema to refer to. Add assertions that state this. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index fafec94e022..43ab4be1f77 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -147,6 +147,8 @@ def _name(self, name): return self._name_map[name] =20 def _use_type(self, typ): + assert self._schema is not None + # Map the various integer types to plain int if typ.json_type() =3D=3D 'int': typ =3D self._schema.lookup_type('int') @@ -225,6 +227,8 @@ def visit_alternate_type(self, name, info, ifcond, feat= ures, variants): def visit_command(self, name, info, ifcond, features, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig, coroutine): + assert self._schema is not None + arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type obj =3D {'arg-type': self._use_type(arg_type), @@ -234,6 +238,7 @@ def visit_command(self, name, info, ifcond, features, self._gen_tree(name, 'command', obj, ifcond, features) =20 def visit_event(self, name, info, ifcond, features, arg_type, boxed): + assert self._schema is not None arg_type =3D arg_type or self._schema.the_empty_object_type self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type= )}, ifcond, features) --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612398851; cv=none; d=zohomail.com; s=zohoarc; b=lbCkSCKB6X8fVpHePfLV1S9Oz8OVHN7qVI3+umDMPePWxpXhsLSNPjUcVr9DUUiNjuKcsHsfwRiv+UwakNoII2rqb1AA2Pkmf6vaeaoPyDvPEyzMa1u71nWjvfpwEyYtJ0G2tXznJd3wWXC+PlluWZeRzMaMtFa5rTILi1ATXBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612398851; 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=N9yGGI4O27oKx7dXUhjSvY4iw/NC5t2MvhJDwQcUe9I=; b=fK9qtkIRQOap8yN9C+fXVdrpmniNRWYFu/vUEAPbdwOWJ+lRFtJrNZbl72MqdcDGA3Lz8A5aHvjyYMk66PMzvzeUu1TwtP8pUeA059ecgUZqPzHIakxdARQXXNeQFFl17/JHwbRMarj4XCYgylKzHJ2a4ykY9vPkCfXDoOT9j24= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612398851113579.1980767506604; Wed, 3 Feb 2021 16:34:11 -0800 (PST) Received: from localhost ([::1]:36844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sb3-00030j-QX for importer@patchew.org; Wed, 03 Feb 2021 19:34:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZN-0001Cv-7Y for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZB-0000ao-VI for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:24 -0500 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-265-FNaUV5YjMMGb4Id_1qcClg-1; Wed, 03 Feb 2021 19:32:10 -0500 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 AC3B9108C282 for ; Thu, 4 Feb 2021 00:32:09 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A3171007622; Thu, 4 Feb 2021 00:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398733; 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=N9yGGI4O27oKx7dXUhjSvY4iw/NC5t2MvhJDwQcUe9I=; b=CAu3R7Iou1UGLe4ScbFJI86POjnOt0gJcDd7s538j6uZpzF8rHQtCWlVsH92ZJPtPXmQRZ MQDchW5nnDFwX5jQ0d0fHKtvIM6P/s55Jq5d4faFcXXoUl1cUBjZJbZNkYHe4T3BD/r7FX tce3hVsJ7MoGqZ64a5qkbMzUNqj1fVc= X-MC-Unique: FNaUV5YjMMGb4Id_1qcClg-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 02/15] qapi/introspect.py: use _make_tree for features nodes Date: Wed, 3 Feb 2021 19:31:54 -0500 Message-Id: <20210204003207.2856909-3-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" At present, we open-code this in _make_tree itself; but if the structure of the tree changes, this is brittle. Use an explicit recursive call to _make_tree when appropriate to help keep the interior node typing consistent. A consequence of doing this is that the 'ifcond' key of the features dict will be omitted when ifcond is false-ish, just like it is omitted in top-level calls to _make_tree. This also increases consistency in our handling of this property. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 43ab4be1f77..3295a15c98e 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -30,7 +30,9 @@ def _make_tree(obj, ifcond, features, extra=3DNone): if ifcond: extra['if'] =3D ifcond if features: - obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in features] + obj['features'] =3D [ + _make_tree(f.name, f.ifcond, None) for f in features + ] if extra: return (obj, extra) return obj --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399058; cv=none; d=zohomail.com; s=zohoarc; b=C7psEZ/LUePs9ZvXaUiTIYlypI9rR8O+vMX9fALk2YL9xH/we0c8lObr+8FJHnJECrcLTb97XByyBPg+Lj/ILUgDJjibINpBFmuRwGFKAmQMHfgo+JRkPVgRUc2X/u5TwgBInDi0e42oJ4AfFvAgjjYnzugmHIA7TgGsWnqKTj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399058; 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=acrxd18H7FqKyFi0v69UbUmTdPkZgFPrjuidbeAGGhQ=; b=WfqJA7aEtQ12yR2boihQ78ymnnvOD+AHqCv0c10av5yrjf437Lo8dCW/DoGDRZmvMFcfqXKJQlgFxB3BH4LOEnhKLqxCoZgm1MheCEZNVPzw6YV2jdhWjRnxlUlxUKiCgfO89qUGEg6dOEJTSh4tNY4a6Ppob0e4CzQ7Ki/q86c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399058731423.3828075463887; Wed, 3 Feb 2021 16:37:38 -0800 (PST) Received: from localhost ([::1]:45194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7SeP-0006k3-Lf for importer@patchew.org; Wed, 03 Feb 2021 19:37:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZN-0001D2-CP for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZC-0000bB-6R for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:25 -0500 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-343-yXtQ71cUOvGAQzgBBiWRpg-1; Wed, 03 Feb 2021 19:32:11 -0500 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 73AA7AFA80 for ; Thu, 4 Feb 2021 00:32:10 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id D256D101E817; Thu, 4 Feb 2021 00:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398733; 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=acrxd18H7FqKyFi0v69UbUmTdPkZgFPrjuidbeAGGhQ=; b=SezRqJQHY9ZH+G710Fj7l7mAPrndCSr1nrYhZBIJSlOHpjkGKumYR+8dgFtyTNXTxSkSfa 8PfadTykdiGcc1S7fYSANtVokjg2SFGxoX7v/DvMsPasnp9HGTaTepLv3hywXn5c1xTSqa nYmop5++w3KSdEyKjT9N11IiCZ6ssRQ= X-MC-Unique: yXtQ71cUOvGAQzgBBiWRpg-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 03/15] qapi/introspect.py: add _gen_features helper Date: Wed, 3 Feb 2021 19:31:55 -0500 Message-Id: <20210204003207.2856909-4-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" _make_tree might receive a dict (a SchemaInfo object) or some other type (usually, a string) for its obj parameter. Adding features information should arguably be performed by the caller at such a time when we know the type of the object and don't have to re-interrogate it. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 3295a15c98e..4749f65ea3c 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -24,15 +24,11 @@ ) =20 =20 -def _make_tree(obj, ifcond, features, extra=3DNone): +def _make_tree(obj, ifcond, extra=3DNone): if extra is None: extra =3D {} if ifcond: extra['if'] =3D ifcond - if features: - obj['features'] =3D [ - _make_tree(f.name, f.ifcond, None) for f in features - ] if extra: return (obj, extra) return obj @@ -169,6 +165,10 @@ def _use_type(self, typ): return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 + @staticmethod + def _gen_features(features): + return [_make_tree(f.name, f.ifcond) for f in features] + def _gen_tree(self, name, mtype, obj, ifcond, features): extra =3D None if mtype not in ('command', 'event', 'builtin', 'array'): @@ -179,13 +179,17 @@ def _gen_tree(self, name, mtype, obj, ifcond, feature= s): name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype - self._trees.append(_make_tree(obj, ifcond, features, extra)) + if features: + obj['features'] =3D self._gen_features(features) + self._trees.append(_make_tree(obj, ifcond, extra)) =20 def _gen_member(self, member): obj =3D {'name': member.name, 'type': self._use_type(member.type)} if member.optional: obj['default'] =3D None - return _make_tree(obj, member.ifcond, member.features) + if member.features: + obj['features'] =3D self._gen_features(member.features) + return _make_tree(obj, member.ifcond) =20 def _gen_variants(self, tag_name, variants): return {'tag': tag_name, @@ -193,7 +197,7 @@ def _gen_variants(self, tag_name, variants): =20 def _gen_variant(self, variant): obj =3D {'case': variant.name, 'type': self._use_type(variant.type= )} - return _make_tree(obj, variant.ifcond, None) + return _make_tree(obj, variant.ifcond) =20 def visit_builtin_type(self, name, info, json_type): self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612398899; cv=none; d=zohomail.com; s=zohoarc; b=MGvWw9DvxvT1s1oIfeMQ7sRU8jrXwxWkOfSBuu08eub5rQ7ESSzN+pIVC7WumUoRH7UM/fxZJK4Ipggp5CAMhmGxJQU8ub7PFQXgZFQWf7sFUjnD3eZtyzMR+HBmcqJcinkr69YytIZlei0UpaZ7CdIgounzHZICvJFdGDJzkT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612398899; 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=QLWmo10aY/7+eJcykLq1vYXxnbs+2dOAa1qD1gwOsW4=; b=KVCRu3LSJ7yyVmTgak/oS/ZV5ohazr4rXF+DawLdp67l9Db8ZU0QocZcGwhBUN35Y3wEDHohvmYDEDM46wJUQ1wQupYy2dxyJG/7THRBoRaPrPz8X+DU8nidtLwWXoaW631rVC7mlAT/sBDa/R2hX6G8eUcatjbtmFMZYnnFQdY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612398899790776.4493213730343; Wed, 3 Feb 2021 16:34:59 -0800 (PST) Received: from localhost ([::1]:39770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sbq-0004Cb-Jb for importer@patchew.org; Wed, 03 Feb 2021 19:34:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZO-0001De-Qr for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZC-0000bq-TZ for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:26 -0500 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-504-fv0p9UdVPOC-MlzTw9DtLA-1; Wed, 03 Feb 2021 19:32:12 -0500 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 39B52108C27A for ; Thu, 4 Feb 2021 00:32:11 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 976BD102AE7E; Thu, 4 Feb 2021 00:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398734; 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=QLWmo10aY/7+eJcykLq1vYXxnbs+2dOAa1qD1gwOsW4=; b=I7wwUMTVa1Pt6ZF568/yUDr6TLApiut4VP2PvJHm7kR9X331aWe3G6rvVI2l8JTPFv4Ik6 B573rxNUVTlrx9ITcr3vwI41MarYshMFWSXZgdYJly2oPEgs4khjuh9jMZXAhhUIihUlY2 XLL0nPlgKHpnHIbuptnJciPl6OoKNVE= X-MC-Unique: fv0p9UdVPOC-MlzTw9DtLA-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 04/15] qapi/introspect.py: guard against ifcond/comment misuse Date: Wed, 3 Feb 2021 19:31:56 -0500 Message-Id: <20210204003207.2856909-5-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" _tree_to_qlit is called recursively on dict values (isolated from their keys); at such a point in generating output it is too late to apply an ifcond. Similarly, comments do not necessarily have a "tidy" place they can be printed in such a circumstance. Forbid this usage by renaming "suppress_first_indent" to "dict_value" to emphasize that indents are suppressed only for the benefit of dict values; then add an assertion assuring we do not pass ifcond/comments in this case. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 4749f65ea3c..a7ccda5ab92 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -34,7 +34,7 @@ def _make_tree(obj, ifcond, extra=3DNone): return obj =20 =20 -def _tree_to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): +def _tree_to_qlit(obj, level=3D0, dict_value=3DFalse): =20 def indent(level): return level * 4 * ' ' @@ -43,6 +43,12 @@ def indent(level): ifobj, extra =3D obj ifcond =3D extra.get('if') comment =3D extra.get('comment') + + # NB: _tree_to_qlit is called recursively on the values of a key:v= alue + # pair; those values can't be decorated with comments or condition= als. + msg =3D "dict values cannot have attached comments or if-condition= als." + assert not dict_value, msg + ret =3D '' if comment: ret +=3D indent(level) + '/* %s */\n' % comment @@ -54,7 +60,7 @@ def indent(level): return ret =20 ret =3D '' - if not suppress_first_indent: + if not dict_value: ret +=3D indent(level) if obj is None: ret +=3D 'QLIT_QNULL' --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399330; cv=none; d=zohomail.com; s=zohoarc; b=TTbcIRDJXkKjwCyv0ALc7n0LveRsLaAW/raCuSABj2YwXODGHSpSMsXhYk3O1vEOaBhvq8+O20KDMhgoHVXIUi/o76Cj2F4QIOIRtvf3lI9jd+O8Z2BByiD/CyYLoJPT8NEZmQE7cp517ijdNClFcK/KKG7uxtM1YHKNTbSYQhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399330; 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=hhSDtbsGfbobVTHftHTtFiV/76YmL0xiVKbNqWrc3lU=; b=IJVh73hgSLmBKGtK3LRQxJjd61M5EmObE3X1aVmE/+QvT+V8wuxn5S1+ZJmcu31nUqDEci51dEI2Q82uF3kTxkI29mXtwZQ/QbJQnx49EdF8BWhRj+7cIuNFk2U++CNk7f2keMTDi7wir5Ry8UIF/yit1adAouflefDKjytBySc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399330817521.2972372861551; Wed, 3 Feb 2021 16:42:10 -0800 (PST) Received: from localhost ([::1]:53884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sin-0001xs-Kf for importer@patchew.org; Wed, 03 Feb 2021 19:42:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZO-0001DR-Hg for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZD-0000bv-5F for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:26 -0500 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-448-1PAEaGzLNpaSanYAo8cERw-1; Wed, 03 Feb 2021 19:32:12 -0500 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 EF3BB8030B3 for ; Thu, 4 Feb 2021 00:32:11 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C9471007622; Thu, 4 Feb 2021 00:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398734; 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=hhSDtbsGfbobVTHftHTtFiV/76YmL0xiVKbNqWrc3lU=; b=IhXW9UVUiIJoEybYkPXwhmGepBFaqajmKXa1aCT3PHXHDxttoaeD7sE/lhajX2uXDpJhx8 pMaBeNZeBfBfgqWrxwrPyFFNUgbOgNT8Ri2FG78wiAR3cXXNeSQ1w3KbQ2qfXoqYICxj3x 9mZTW3qPLLTVVu490wwKdEuEHRFhzPo= X-MC-Unique: 1PAEaGzLNpaSanYAo8cERw-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 05/15] qapi/introspect.py: Unify return type of _make_tree() Date: Wed, 3 Feb 2021 19:31:57 -0500 Message-Id: <20210204003207.2856909-6-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Returning two different types conditionally can be complicated to type. Return one type for consistency. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index a7ccda5ab92..7730d8ed6b2 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -29,9 +29,7 @@ def _make_tree(obj, ifcond, extra=3DNone): extra =3D {} if ifcond: extra['if'] =3D ifcond - if extra: - return (obj, extra) - return obj + return (obj, extra) =20 =20 def _tree_to_qlit(obj, level=3D0, dict_value=3DFalse): --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399328; cv=none; d=zohomail.com; s=zohoarc; b=mPXOeo5iD3brUT65ZGpf33l+OEhg/u0bRN/3cMklwroO6DuxzQvM4TDy2hC9gKpj2aLDpjUQnXtEKbYBsvBBiLxcHG7VEN48tqC82U0rFwt5wtOJ4VZsOiI4Y0F4O4muqtoSaNL3EYP9fr+43PqFjmusE79j/BOOeJyK65Tuxrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399328; 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=vGs6OE2ncObnm5kTca0WqPCj9ZU90/mKzbEwVnH6IJw=; b=AV1uGdhV8YhdNk2qF/YFgtSwzH9CGc22128FyXMrbQTrS7wtkUVaW93bJR/snuA/YjXY0BGMJRJTKv6fqHtxGOryXGddLJQOKNJWO3rrvdcJTPCwE9OQZzBDqVk6Vq0m5zPS+MTsiWzePAEBRlsWe9ybvsrfzACeCM5pTUZg+9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161239932885284.30546198247737; Wed, 3 Feb 2021 16:42:08 -0800 (PST) Received: from localhost ([::1]:53662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sil-0001sU-DB for importer@patchew.org; Wed, 03 Feb 2021 19:42:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZP-0001Dr-09 for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZD-0000cQ-Vo for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:26 -0500 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-340-HoODNEt4OlyvyZ8wwi1CAA-1; Wed, 03 Feb 2021 19:32:13 -0500 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 EB8F7107ACC7 for ; Thu, 4 Feb 2021 00:32:12 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E924100AE4A; Thu, 4 Feb 2021 00:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398735; 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=vGs6OE2ncObnm5kTca0WqPCj9ZU90/mKzbEwVnH6IJw=; b=ABlrUlbohgy81NGsKPiGOcmW6B2asPS60Rs0MS5Q6y/v9lFCnesgPUYgYO7TK6wbd2QOoK M2nu729ENRuyz1WeqpFhcyrXB9zbYwXaWzc7DY+MjF7DDJMt9J4SWRL1zXcG5kFoQE+9o5 shucDRWJ2MwG1f1PykTuP2sYs8LFYAY= X-MC-Unique: HoODNEt4OlyvyZ8wwi1CAA-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 06/15] qapi/introspect.py: replace 'extra' dict with 'comment' argument Date: Wed, 3 Feb 2021 19:31:58 -0500 Message-Id: <20210204003207.2856909-7-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is only used to pass in a dictionary with a comment already set, so skip the runaround and just accept the (optional) comment. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 7730d8ed6b2..1655a21f85b 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,6 +10,8 @@ See the COPYING file in the top-level directory. """ =20 +from typing import Optional + from .common import ( c_name, gen_endif, @@ -24,11 +26,12 @@ ) =20 =20 -def _make_tree(obj, ifcond, extra=3DNone): - if extra is None: - extra =3D {} +def _make_tree(obj, ifcond, comment=3DNone): + extra =3D {} if ifcond: extra['if'] =3D ifcond + if comment: + extra['comment'] =3D comment return (obj, extra) =20 =20 @@ -174,18 +177,18 @@ def _gen_features(features): return [_make_tree(f.name, f.ifcond) for f in features] =20 def _gen_tree(self, name, mtype, obj, ifcond, features): - extra =3D None + comment: Optional[str] =3D None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: # Output a comment to make it easy to map masked names # back to the source when reading the generated output. - extra =3D {'comment': '"%s" =3D %s' % (self._name(name), n= ame)} + comment =3D f'"{self._name(name)}" =3D {name}' name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype if features: obj['features'] =3D self._gen_features(features) - self._trees.append(_make_tree(obj, ifcond, extra)) + self._trees.append(_make_tree(obj, ifcond, comment)) =20 def _gen_member(self, member): obj =3D {'name': member.name, 'type': self._use_type(member.type)} --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399550; cv=none; d=zohomail.com; s=zohoarc; b=XsnR4dWNNYSVno1rUwT3LfHQs4QNEsMN0jIm28WZAWBtyDBEp/h9x9uoG2abCWP7jLUqyGf/bxgqweITUHdlGcOiYIw5udTA80D+DyWyrHxMqXR1RD5V6iadmAiZklzbCd+RToNl6VbS2S0ShBRJzXur+0k/iFzcMUjFuM7wy0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399550; 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=JxItRlDjeE03aSUCdeoWAjl1xlJSCd+Z/KaGv7sl7LY=; b=GuT2fCusNDcmdiReFq5b3s0318iWvXYlCu19SdYt8b3lzDa1Y1YpR0U8+i2UJJdQ9HX0SrHTFEASUMNdkgwL3ef0brzx6oB2W4cS16QsqPEpHl1+J5IsrJGv+LGqQw/a9OLx78oYSHAjhCtkLI/CGixTKZSUnQ7IvHyvw/pmQJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399550835495.36255599468575; Wed, 3 Feb 2021 16:45:50 -0800 (PST) Received: from localhost ([::1]:33840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7SmL-0005Yo-Fq for importer@patchew.org; Wed, 03 Feb 2021 19:45:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZP-0001EE-8q for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54002) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZE-0000cb-Mj for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:26 -0500 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-160-0CBbiY3PN_2onTNaLTfyyQ-1; Wed, 03 Feb 2021 19:32:14 -0500 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 AC09F108C279 for ; Thu, 4 Feb 2021 00:32:13 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F40E100AE4E; Thu, 4 Feb 2021 00:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398736; 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=JxItRlDjeE03aSUCdeoWAjl1xlJSCd+Z/KaGv7sl7LY=; b=IQQUDS7SAZuP7PIjqluv8kuObNAliGBNAJ4G9dBdtFRZmq9AY9b3hVKBNLDg3djH8CHW7H yj/0gUHIt9m6C7WLF9HZJZ8Grp5/apD+AQkx3MXFFX0hyTkwoJJtwQHl7+7ZNbzMqri+zH SSQfLGWMHdqDDsafPRuvGwQW9KfsagI= X-MC-Unique: 0CBbiY3PN_2onTNaLTfyyQ-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 07/15] qapi/introspect.py: Always define all 'extra' dict keys Date: Wed, 3 Feb 2021 19:31:59 -0500 Message-Id: <20210204003207.2856909-8-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This mimics how a typed object works, where 'if' and 'comment' are always set, regardless of if they have a value set or not. It is safe to do this because of the way that _tree_to_qlit processes these values (using dict.get with a default of None), resulting in no change of output from _tree_to_qlit. There are no other users of this data. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 1655a21f85b..45231d2abc3 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -27,11 +27,10 @@ =20 =20 def _make_tree(obj, ifcond, comment=3DNone): - extra =3D {} - if ifcond: - extra['if'] =3D ifcond - if comment: - extra['comment'] =3D comment + extra =3D { + 'if': ifcond, + 'comment': comment + } return (obj, extra) =20 =20 --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399070; cv=none; d=zohomail.com; s=zohoarc; b=NVowhymJT0LIRPNsduf1Ldgh0f175W9bWvfgKA+b4WZHMaiR+T6ttFUb+nMkxGv6BIpfEousqBXVS6FyBCKIqisyAEd5h1SahYOgIqvOqQGAR1zVeBDWuunBOFo5dnJxDnsv+1Z7nO6dZYHrXzDCxWz0iZupfSZLR7aFWerGnBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399070; 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=1SsbOm4FHH0XCOp+wutYMrVH+yv5sFpo6JYVyifERMA=; b=W/KqnGIdnpFFuoq0Cn6JeYFNYNFb1by4rv9ecvUufOc4VN9FRyRdwIDLKUMvY4pYLNp7HFvCtPbmQXa5pfqtfOPTl7T07Pd7WhOHmkXG+cOdrKmrVd7JZ6FgY0uI1LwQXZ9ZhBEYFyJb6eyIkH9X1CyUGoNQCLEIzlw6O4GRPYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399070463849.5468546295924; Wed, 3 Feb 2021 16:37:50 -0800 (PST) Received: from localhost ([::1]:45780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Seb-0006zI-8N for importer@patchew.org; Wed, 03 Feb 2021 19:37:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZQ-0001GJ-5Q for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56093) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZF-0000d7-Gd for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:27 -0500 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-214-KFbLMwg9O0WT08nSIlobFg-1; Wed, 03 Feb 2021 19:32:15 -0500 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 6FF1D107ACF5 for ; Thu, 4 Feb 2021 00:32:14 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEBEB1007622; Thu, 4 Feb 2021 00:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398736; 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=1SsbOm4FHH0XCOp+wutYMrVH+yv5sFpo6JYVyifERMA=; b=BoDTVDqa7C4Z2E83Ns+f55F251pKvDYBei6kgBzU8Dg00mlxqrWZqNGvKO+sqWTczQJLvT sCPkNXrEKQXZwDwhyIBtQcZkLFA+4h+aWpnpsr9FkMN4ckAHt1zOf1jCDWfvzEK0OdBzii yg/LKVI7iRH6Ag86yLOpSBCvN+WOSXQ= X-MC-Unique: KFbLMwg9O0WT08nSIlobFg-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 08/15] qapi/introspect.py: Introduce preliminary tree typing Date: Wed, 3 Feb 2021 19:32:00 -0500 Message-Id: <20210204003207.2856909-9-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The types will be used in forthcoming patches to add typing. These types describe the layout and structure of the objects passed to _tree_to_qlit, but lack the power to describe annotations until the next commit. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 45231d2abc3..8e019b4a26a 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,7 +10,13 @@ See the COPYING file in the top-level directory. """ =20 -from typing import Optional +from typing import ( + Any, + Dict, + List, + Optional, + Union, +) =20 from .common import ( c_name, @@ -26,6 +32,28 @@ ) =20 =20 +# This module constructs a tree data structure that is used to +# generate the introspection information for QEMU. It behaves similarly +# to a JSON value. +# +# A complexity over JSON is that our values may or may not be annotated. +# +# Un-annotated values may be: +# Scalar: str, bool, None. +# Non-scalar: List, Dict +# _value =3D Union[str, bool, None, Dict[str, TreeValue], List[TreeValue]] +# +# With optional annotations, the type of all values is: +# TreeValue =3D Union[_value, Annotated[_value]] +# +# Sadly, mypy does not support recursive types, so we must approximate thi= s. +_stub =3D Any +_scalar =3D Union[str, bool, None] +_nonscalar =3D Union[Dict[str, _stub], List[_stub]] +_value =3D Union[_scalar, _nonscalar] +# TreeValue =3D TODO, in a forthcoming commit. + + def _make_tree(obj, ifcond, comment=3DNone): extra =3D { 'if': ifcond, --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399152; cv=none; d=zohomail.com; s=zohoarc; b=RwiwnaeA0jq8/mJdzHitlHKWYpaXrirmhkqfypSeWUuOnjBdZH1Db3721PQaOfVFoAP4PMiPfPhYsCqNoEt/2N5tQ2RdOA0C18zEeRLqzPws2FYyu/1vbkANv9ctpI/d3fgDDpL+AM4n78SHyfmN2oaN/QwnuyxMVAV/yf5BBaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399152; 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=wkntpfCCYf5FRo2qTCa/3nf3Rr89MHeedyElkjKNYSU=; b=hpz2vOhr+1OaqwO1QEmhOX+nboA4Dh/ko5xF4GwP2QTpLDAzk1F32eP5TgvwNLHL5zbZ6iavgD+297Dm+0I/OMg4e0MlIur7f+Cd4sGzXtj1zp4Ccm1hLVPDLXM3VbDg0CLMg+oUJ4Jicu3G6aiCDYTBwq6FguIIKcbzgnS2gTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399152325900.8256945291888; Wed, 3 Feb 2021 16:39:12 -0800 (PST) Received: from localhost ([::1]:48422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sfu-00083Q-TJ for importer@patchew.org; Wed, 03 Feb 2021 19:39:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZR-0001Kl-Vb for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZG-0000dd-Re for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:29 -0500 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-276-0YzPafoZOfCxs2dJQXUFsQ-1; Wed, 03 Feb 2021 19:32:16 -0500 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 307808030B6 for ; Thu, 4 Feb 2021 00:32:15 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FCDE100AE4A; Thu, 4 Feb 2021 00:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398738; 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=wkntpfCCYf5FRo2qTCa/3nf3Rr89MHeedyElkjKNYSU=; b=fSwHF05Y98qgzzmagZnzRIorP+9tPoSa1tIZkl3f31rx5xfKDh+RwGcEPx/vnOFOtf5aeR FDOIA6jqx8UFnkAMy9s4ofMRDzxSCx5KJoeU8SRd9AdCUJ8GhwEsymwDVFTTSoaZ8wEMOn FDUsJ6N67TnoZwwPh6LlJ8cnvY5fbgY= X-MC-Unique: 0YzPafoZOfCxs2dJQXUFsQ-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 09/15] qapi/introspect.py: create a typed 'Annotated' data strutcure Date: Wed, 3 Feb 2021 19:32:01 -0500 Message-Id: <20210204003207.2856909-10-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Presently, we use a tuple to attach a dict containing annotations (comments and compile-time conditionals) to a tree node. This is undesirable because dicts are difficult to strongly type; promoting it to a real class allows us to name the values and types of the annotations we are expecting. In terms of typing, the Annotated type serves as a generic container where the annotated node's type is preserved, allowing for greater specificity than we'd be able to provide without a generic. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 77 ++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 8e019b4a26a..b9427aba449 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -13,8 +13,12 @@ from typing import ( Any, Dict, + Generic, + Iterable, List, Optional, + Tuple, + TypeVar, Union, ) =20 @@ -51,15 +55,25 @@ _scalar =3D Union[str, bool, None] _nonscalar =3D Union[Dict[str, _stub], List[_stub]] _value =3D Union[_scalar, _nonscalar] -# TreeValue =3D TODO, in a forthcoming commit. +TreeValue =3D Union[_value, 'Annotated[_value]'] =20 =20 -def _make_tree(obj, ifcond, comment=3DNone): - extra =3D { - 'if': ifcond, - 'comment': comment - } - return (obj, extra) +_NodeT =3D TypeVar('_NodeT', bound=3D_value) + + +class Annotated(Generic[_NodeT]): + """ + Annotated generally contains a SchemaInfo-like type (as a dict), + But it also used to wrap comments/ifconds around scalar leaf values, + for the benefit of features and enums. + """ + # TODO: Remove after Python 3.7 adds @dataclass: + # pylint: disable=3Dtoo-few-public-methods + def __init__(self, value: _NodeT, ifcond: Iterable[str], + comment: Optional[str] =3D None): + self.value =3D value + self.comment: Optional[str] =3D comment + self.ifcond: Tuple[str, ...] =3D tuple(ifcond) =20 =20 def _tree_to_qlit(obj, level=3D0, dict_value=3DFalse): @@ -67,24 +81,20 @@ def _tree_to_qlit(obj, level=3D0, dict_value=3DFalse): def indent(level): return level * 4 * ' ' =20 - if isinstance(obj, tuple): - ifobj, extra =3D obj - ifcond =3D extra.get('if') - comment =3D extra.get('comment') - + if isinstance(obj, Annotated): # NB: _tree_to_qlit is called recursively on the values of a key:v= alue # pair; those values can't be decorated with comments or condition= als. msg =3D "dict values cannot have attached comments or if-condition= als." assert not dict_value, msg =20 ret =3D '' - if comment: - ret +=3D indent(level) + '/* %s */\n' % comment - if ifcond: - ret +=3D gen_if(ifcond) - ret +=3D _tree_to_qlit(ifobj, level) - if ifcond: - ret +=3D '\n' + gen_endif(ifcond) + if obj.comment: + ret +=3D indent(level) + '/* %s */\n' % obj.comment + if obj.ifcond: + ret +=3D gen_if(obj.ifcond) + ret +=3D _tree_to_qlit(obj.value, level) + if obj.ifcond: + ret +=3D '\n' + gen_endif(obj.ifcond) return ret =20 ret =3D '' @@ -201,7 +211,7 @@ def _use_type(self, typ): =20 @staticmethod def _gen_features(features): - return [_make_tree(f.name, f.ifcond) for f in features] + return [Annotated(f.name, f.ifcond) for f in features] =20 def _gen_tree(self, name, mtype, obj, ifcond, features): comment: Optional[str] =3D None @@ -215,7 +225,7 @@ def _gen_tree(self, name, mtype, obj, ifcond, features): obj['meta-type'] =3D mtype if features: obj['features'] =3D self._gen_features(features) - self._trees.append(_make_tree(obj, ifcond, comment)) + self._trees.append(Annotated(obj, ifcond, comment)) =20 def _gen_member(self, member): obj =3D {'name': member.name, 'type': self._use_type(member.type)} @@ -223,7 +233,7 @@ def _gen_member(self, member): obj['default'] =3D None if member.features: obj['features'] =3D self._gen_features(member.features) - return _make_tree(obj, member.ifcond) + return Annotated(obj, member.ifcond) =20 def _gen_variants(self, tag_name, variants): return {'tag': tag_name, @@ -231,16 +241,17 @@ def _gen_variants(self, tag_name, variants): =20 def _gen_variant(self, variant): obj =3D {'case': variant.name, 'type': self._use_type(variant.type= )} - return _make_tree(obj, variant.ifcond) + return Annotated(obj, variant.ifcond) =20 def visit_builtin_type(self, name, info, json_type): self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) =20 def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): - self._gen_tree(name, 'enum', - {'values': [_make_tree(m.name, m.ifcond, None) - for m in members]}, - ifcond, features) + self._gen_tree( + name, 'enum', + {'values': [Annotated(m.name, m.ifcond) for m in members]}, + ifcond, features + ) =20 def visit_array_type(self, name, info, ifcond, element_type): element =3D self._use_type(element_type) @@ -257,12 +268,12 @@ def visit_object_type_flat(self, name, info, ifcond, = features, self._gen_tree(name, 'object', obj, ifcond, features) =20 def visit_alternate_type(self, name, info, ifcond, features, variants): - self._gen_tree(name, 'alternate', - {'members': [ - _make_tree({'type': self._use_type(m.type)}, - m.ifcond, None) - for m in variants.variants]}, - ifcond, features) + self._gen_tree( + name, 'alternate', + {'members': [Annotated({'type': self._use_type(m.type)}, m.ifc= ond) + for m in variants.variants]}, + ifcond, features + ) =20 def visit_command(self, name, info, ifcond, features, arg_type, ret_type, gen, success_response, boxed, --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612398854; cv=none; d=zohomail.com; s=zohoarc; b=IoXTg5LQC4HIOVSmubV06ujNtT3Qv5Gf2BghuyMItKFGHH3D2qH8+G/rRN/7BMnJ2xF1G0ETzIQXAhNvAwJznKKzFwocQLPCVp0ZlGP817+1qaPm78lbeP6SxVRK/zF56e6vZ2ZGqusbIDZbtCmIFpa5KF4ecK20wsyG7QzECD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612398854; 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=ir8W7GI/RAEul9zjs7iM1O4jtduanRSkeI8lg+5O0Y8=; b=Ik+NeTPqWvKZpah1soxMNSL/2RCMT3RGsdJQvuqzC10Uov/oKAveStJSsdPzh0G//yP2pEJt0IkND4AdsHiKmuzrVegDpYTR64caGICIF+hLCZ9PxehTp1d8sZQXYY93sZokhYEHXRKCeYBuLR2NuUd4vN/MBmWFLHiG9MbAdpc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612398854042409.7218286603712; Wed, 3 Feb 2021 16:34:14 -0800 (PST) Received: from localhost ([::1]:37078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sb6-00036f-Qu for importer@patchew.org; Wed, 03 Feb 2021 19:34:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZQ-0001HK-Pm for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZH-0000do-HT for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:28 -0500 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-125-T4304iNhPdGXRK0WxIYszQ-1; Wed, 03 Feb 2021 19:32:16 -0500 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 E65A3AFA82 for ; Thu, 4 Feb 2021 00:32:15 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53863100AE4E; Thu, 4 Feb 2021 00:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398738; 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=ir8W7GI/RAEul9zjs7iM1O4jtduanRSkeI8lg+5O0Y8=; b=T0JJcNhEu5z065NsI8I5GGxnoOitWqQBQoxSsFaDWZxSSkm9KxuwjJFa0lgkZwQ4SraltC AtBlr7R9o9fp8+phe91KrqQkfD7QhtQOw9VL5fXtlEjv+zi1n/BixiDQ1GVzZL9UhMOEDj xCsa0pdsW3Aq4bKQaPmSZvT1xfKdioI= X-MC-Unique: T4304iNhPdGXRK0WxIYszQ-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 10/15] qapi/introspect.py: improve _tree_to_qlit error message Date: Wed, 3 Feb 2021 19:32:02 -0500 Message-Id: <20210204003207.2856909-11-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Trivial; make the error message just a pinch more explicit in case we trip this by accident in the future. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b9427aba449..0146e4c6a0c 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -124,7 +124,9 @@ def indent(level): elif isinstance(obj, bool): ret +=3D 'QLIT_QBOOL(%s)' % ('true' if obj else 'false') else: - assert False # not implemented + raise NotImplementedError( + f"type '{type(obj).__name__}' not implemented" + ) if level > 0: ret +=3D ',' return ret --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399351; cv=none; d=zohomail.com; s=zohoarc; b=FkRs6WQcOFTnAwrki4JVH+mGFfZAzCBrcD/Wc3DVo5i0PdR9zLaLRWz7tE0s2qftTbvd3sSOeRYENWqYFYsHZryq9H55AGdFUWvDStFyXE80COpYNr6Jgz0uvBeV3lO0LQQGN63njTB1lIr/CPtEOfAOyGbdXzyyMXc3U0g/d5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399351; 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=glJ6THkx7gbhIxYppi/omqSbh0u9hLVsk2WwC6p2wHw=; b=it+NMkgMQEAGc5/BSr3N/8P/s1JAVdmiSNJmBHQFHlsGytokVeXDBVgpXl58Hg9LvGzCQ9gE0iXoIzS5mitROFZN3UEKiwxGZAA1/qicnIScqu4ZiE1rpg/CVaJxEre0w/cvT/R7VJakhEaTeUI9xPCWvyGowobpvIydi+ULg0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399351785525.455300787012; Wed, 3 Feb 2021 16:42:31 -0800 (PST) Received: from localhost ([::1]:54446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sj8-0002DW-OA for importer@patchew.org; Wed, 03 Feb 2021 19:42:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZT-0001Oc-IC for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZH-0000ds-NU for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:31 -0500 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-121-Ho4G1eKjNY-sawIwgPOMRQ-1; Wed, 03 Feb 2021 19:32:17 -0500 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 B8E5B8030BA for ; Thu, 4 Feb 2021 00:32:16 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16C1B100AE4A; Thu, 4 Feb 2021 00:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398739; 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=glJ6THkx7gbhIxYppi/omqSbh0u9hLVsk2WwC6p2wHw=; b=J42wBebj1wCM13B1AxsSHVCTedyT6kw4az1MVfqAhBTqtiU+Cc3ayFzZpDQtV58SU5xiqj Rw6ouzNpgVU25/c2IJks8Sm7jQbXeybEZNK0XIyPK6W/7PEFeVZfAR6nN4uPcscJiIIlAp TMI4GASG1BFZgP41L2tle4oRTVmEbBU= X-MC-Unique: Ho4G1eKjNY-sawIwgPOMRQ-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 11/15] qapi/introspect.py: improve readability of _tree_to_qlit Date: Wed, 3 Feb 2021 19:32:03 -0500 Message-Id: <20210204003207.2856909-12-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Subjective, but I find getting rid of the comprehensions helps. Also, divide the sections into scalar and non-scalar sections, and remove old-style string formatting. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 0146e4c6a0c..cf0e4e05c5c 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -89,7 +89,7 @@ def indent(level): =20 ret =3D '' if obj.comment: - ret +=3D indent(level) + '/* %s */\n' % obj.comment + ret +=3D indent(level) + f"/* {obj.comment} */\n" if obj.ifcond: ret +=3D gen_if(obj.ifcond) ret +=3D _tree_to_qlit(obj.value, level) @@ -100,33 +100,36 @@ def indent(level): ret =3D '' if not dict_value: ret +=3D indent(level) + + # Scalars: if obj is None: ret +=3D 'QLIT_QNULL' elif isinstance(obj, str): - ret +=3D 'QLIT_QSTR(' + to_c_string(obj) + ')' + ret +=3D f"QLIT_QSTR({to_c_string(obj)})" + elif isinstance(obj, bool): + ret +=3D f"QLIT_QBOOL({str(obj).lower()})" + + # Non-scalars: elif isinstance(obj, list): - elts =3D [_tree_to_qlit(elt, level + 1).strip('\n') - for elt in obj] - elts.append(indent(level + 1) + "{}") ret +=3D 'QLIT_QLIST(((QLitObject[]) {\n' - ret +=3D '\n'.join(elts) + '\n' + for value in obj: + ret +=3D _tree_to_qlit(value, level + 1).strip('\n') + '\n' + ret +=3D indent(level + 1) + '{}\n' ret +=3D indent(level) + '}))' elif isinstance(obj, dict): - elts =3D [] - for key, value in sorted(obj.items()): - elts.append(indent(level + 1) + '{ %s, %s }' % - (to_c_string(key), - _tree_to_qlit(value, level + 1, True))) - elts.append(indent(level + 1) + '{}') ret +=3D 'QLIT_QDICT(((QLitDictEntry[]) {\n' - ret +=3D ',\n'.join(elts) + '\n' + for key, value in sorted(obj.items()): + ret +=3D indent(level + 1) + "{{ {:s}, {:s} }},\n".format( + to_c_string(key), + _tree_to_qlit(value, level + 1, dict_value=3DTrue) + ) + ret +=3D indent(level + 1) + '{}\n' ret +=3D indent(level) + '}))' - elif isinstance(obj, bool): - ret +=3D 'QLIT_QBOOL(%s)' % ('true' if obj else 'false') else: raise NotImplementedError( f"type '{type(obj).__name__}' not implemented" ) + if level > 0: ret +=3D ',' return ret --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399571; cv=none; d=zohomail.com; s=zohoarc; b=jMKqdY89Ktaahb7IX979i02wnNideCh+6KsgwVvMzA91OhI34/yLKWxk+/eDOZ7894Ln1IvCaP+UTF4MqwOFamfzbCTnASXRz/XXKdSDMBYMimp52zGG7N1IoT5pO8P1+vZQcMt3JjycnnC3n1yk1uhJHcfzqNQI+6nPhH1kF8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399571; 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=60sLjUaTVerOYCWbtg/mCm8TC0BCIfOTHEvUQAgVm1k=; b=On7f+E3yti0JMD+zWBUrv4klM14qi8Tb0z/67iAUs5Sx8IUZ0ePKvkHeXR6D2ZEL+wr2iL4OD8K7PA/ASO7qis0t5lnYxXxf+X1+DwSXPoJMO44JTK6O8bjY4VSESWNzXPMSZz3LTnQPCf86ctwZvAMY0zflgQVxJmncT5S7N80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399571983772.2329651322466; Wed, 3 Feb 2021 16:46:11 -0800 (PST) Received: from localhost ([::1]:34546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Smg-0005qQ-Sa for importer@patchew.org; Wed, 03 Feb 2021 19:46:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZT-0001Pb-Tf for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZJ-0000eY-6q for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:31 -0500 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-530-tum-B9UNN2mm49JtzXUgCg-1; Wed, 03 Feb 2021 19:32:18 -0500 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 808B1801966 for ; Thu, 4 Feb 2021 00:32:17 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE141100AE4E; Thu, 4 Feb 2021 00:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398740; 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=60sLjUaTVerOYCWbtg/mCm8TC0BCIfOTHEvUQAgVm1k=; b=YxMyfveckM18El3v/MprOIy414qEIQLUwHxXIYAgviFQia+/wgURHpfdUZVQSg1Z8vHRI5 2x0r15CAQWA8ym9MMy+Py2iZL/+O0FKNMX+2ll2JDUcdC//ebHoY4ysFh2d7xtxHyL8+Y1 PaQRR2dW9EU5w+uZcea1M4Hycsn3x8A= X-MC-Unique: tum-B9UNN2mm49JtzXUgCg-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 12/15] qapi/introspect.py: add type hint annotations Date: Wed, 3 Feb 2021 19:32:04 -0500 Message-Id: <20210204003207.2856909-13-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- See the next patch for an optional amendment that helps to clarify what _DObject is meant to be. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 117 ++++++++++++++++++++++++++----------- scripts/qapi/mypy.ini | 5 -- scripts/qapi/schema.py | 2 +- 3 files changed, 84 insertions(+), 40 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index cf0e4e05c5c..3afcdda7446 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -30,10 +30,19 @@ ) from .gen import QAPISchemaMonolithicCVisitor from .schema import ( + QAPISchema, QAPISchemaArrayType, QAPISchemaBuiltinType, + QAPISchemaEntity, + QAPISchemaEnumMember, + QAPISchemaFeature, + QAPISchemaObjectType, + QAPISchemaObjectTypeMember, QAPISchemaType, + QAPISchemaVariant, + QAPISchemaVariants, ) +from .source import QAPISourceInfo =20 =20 # This module constructs a tree data structure that is used to @@ -57,6 +66,10 @@ _value =3D Union[_scalar, _nonscalar] TreeValue =3D Union[_value, 'Annotated[_value]'] =20 +# This is an alias for an arbitrary JSON object, represented here as a Dic= t. +# It is stricter on the value type than the recursive definition above. +# It is used to represent SchemaInfo-related structures exclusively. +_DObject =3D Dict[str, object] =20 _NodeT =3D TypeVar('_NodeT', bound=3D_value) =20 @@ -76,9 +89,11 @@ def __init__(self, value: _NodeT, ifcond: Iterable[str], self.ifcond: Tuple[str, ...] =3D tuple(ifcond) =20 =20 -def _tree_to_qlit(obj, level=3D0, dict_value=3DFalse): +def _tree_to_qlit(obj: TreeValue, + level: int =3D 0, + dict_value: bool =3D False) -> str: =20 - def indent(level): + def indent(level: int) -> str: return level * 4 * ' ' =20 if isinstance(obj, Annotated): @@ -135,21 +150,21 @@ def indent(level): return ret =20 =20 -def to_c_string(string): +def to_c_string(string: str) -> str: return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' =20 =20 class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): =20 - def __init__(self, prefix, unmask): + def __init__(self, prefix: str, unmask: bool): super().__init__( prefix, 'qapi-introspect', ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask - self._schema =3D None - self._trees =3D [] - self._used_types =3D [] - self._name_map =3D {} + self._schema: Optional[QAPISchema] =3D None + self._trees: List[Annotated[_DObject]] =3D [] + self._used_types: List[QAPISchemaType] =3D [] + self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqapi-introspect.h" @@ -157,10 +172,10 @@ def __init__(self, prefix, unmask): ''', prefix=3Dprefix)) =20 - def visit_begin(self, schema): + def visit_begin(self, schema: QAPISchema) -> None: self._schema =3D schema =20 - def visit_end(self): + def visit_end(self) -> None: # visit the types that are actually used for typ in self._used_types: typ.visit(self) @@ -182,18 +197,18 @@ def visit_end(self): self._used_types =3D [] self._name_map =3D {} =20 - def visit_needed(self, entity): + def visit_needed(self, entity: QAPISchemaEntity) -> bool: # Ignore types on first pass; visit_end() will pick up used types return not isinstance(entity, QAPISchemaType) =20 - def _name(self, name): + def _name(self, name: str) -> str: if self._unmask: return name if name not in self._name_map: self._name_map[name] =3D '%d' % len(self._name_map) return self._name_map[name] =20 - def _use_type(self, typ): + def _use_type(self, typ: QAPISchemaType) -> str: assert self._schema is not None =20 # Map the various integer types to plain int @@ -215,10 +230,13 @@ def _use_type(self, typ): return self._name(typ.name) =20 @staticmethod - def _gen_features(features): + def _gen_features(features: List[QAPISchemaFeature] + ) -> List[Annotated[str]]: return [Annotated(f.name, f.ifcond) for f in features] =20 - def _gen_tree(self, name, mtype, obj, ifcond, features): + def _gen_tree(self, name: str, mtype: str, obj: _DObject, + ifcond: List[str], + features: Optional[List[QAPISchemaFeature]]) -> None: comment: Optional[str] =3D None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -232,47 +250,67 @@ def _gen_tree(self, name, mtype, obj, ifcond, feature= s): obj['features'] =3D self._gen_features(features) self._trees.append(Annotated(obj, ifcond, comment)) =20 - def _gen_member(self, member): - obj =3D {'name': member.name, 'type': self._use_type(member.type)} + def _gen_member(self, member: QAPISchemaObjectTypeMember + ) -> Annotated[_DObject]: + obj: _DObject =3D { + 'name': member.name, + 'type': self._use_type(member.type) + } if member.optional: obj['default'] =3D None if member.features: obj['features'] =3D self._gen_features(member.features) return Annotated(obj, member.ifcond) =20 - def _gen_variants(self, tag_name, variants): + def _gen_variants(self, tag_name: str, + variants: List[QAPISchemaVariant]) -> _DObject: return {'tag': tag_name, 'variants': [self._gen_variant(v) for v in variants]} =20 - def _gen_variant(self, variant): - obj =3D {'case': variant.name, 'type': self._use_type(variant.type= )} + def _gen_variant(self, variant: QAPISchemaVariant) -> Annotated[_DObje= ct]: + obj: _DObject =3D { + 'case': variant.name, + 'type': self._use_type(variant.type) + } return Annotated(obj, variant.ifcond) =20 - def visit_builtin_type(self, name, info, json_type): + def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], + json_type: str) -> None: self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) =20 - def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): + def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], features: List[QAPISchemaFeatur= e], + members: List[QAPISchemaEnumMember], + prefix: Optional[str]) -> None: self._gen_tree( name, 'enum', {'values': [Annotated(m.name, m.ifcond) for m in members]}, ifcond, features ) =20 - def visit_array_type(self, name, info, ifcond, element_type): + def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + element_type: QAPISchemaType) -> None: element =3D self._use_type(element_type) self._gen_tree('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond, None) =20 - def visit_object_type_flat(self, name, info, ifcond, features, - members, variants): - obj =3D {'members': [self._gen_member(m) for m in members]} + def visit_object_type_flat(self, name: str, info: Optional[QAPISourceI= nfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + members: List[QAPISchemaObjectTypeMember], + variants: Optional[QAPISchemaVariants]) -> = None: + obj: _DObject =3D {'members': [self._gen_member(m) for m in member= s]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) =20 self._gen_tree(name, 'object', obj, ifcond, features) =20 - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, name: str, info: Optional[QAPISourceInf= o], + ifcond: List[str], + features: List[QAPISchemaFeature], + variants: QAPISchemaVariants) -> None: self._gen_tree( name, 'alternate', {'members': [Annotated({'type': self._use_type(m.type)}, m.ifc= ond) @@ -280,27 +318,38 @@ def visit_alternate_type(self, name, info, ifcond, fe= atures, variants): ifcond, features ) =20 - def visit_command(self, name, info, ifcond, features, - arg_type, ret_type, gen, success_response, boxed, - allow_oob, allow_preconfig, coroutine): + def visit_command(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + ret_type: Optional[QAPISchemaType], gen: bool, + success_response: bool, boxed: bool, allow_oob: bool, + allow_preconfig: bool, coroutine: bool) -> None: assert self._schema is not None =20 arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type - obj =3D {'arg-type': self._use_type(arg_type), - 'ret-type': self._use_type(ret_type)} + obj: _DObject =3D { + 'arg-type': self._use_type(arg_type), + 'ret-type': self._use_type(ret_type) + } if allow_oob: obj['allow-oob'] =3D allow_oob self._gen_tree(name, 'command', obj, ifcond, features) =20 - def visit_event(self, name, info, ifcond, features, arg_type, boxed): + def visit_event(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + boxed: bool) -> None: assert self._schema is not None + arg_type =3D arg_type or self._schema.the_empty_object_type self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type= )}, ifcond, features) =20 =20 -def gen_introspect(schema, output_dir, prefix, opt_unmask): +def gen_introspect(schema: QAPISchema, output_dir: str, prefix: str, + opt_unmask: bool) -> None: vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 04bd5db5278..0a000d58b37 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -13,11 +13,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.introspect] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.parser] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 353e8020a27..ff16578f6de 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -28,7 +28,7 @@ class QAPISchemaEntity: meta: Optional[str] =3D None =20 - def __init__(self, name, info, doc, ifcond=3DNone, features=3DNone): + def __init__(self, name: str, info, doc, ifcond=3DNone, features=3DNon= e): assert name is None or isinstance(name, str) for f in features or []: assert isinstance(f, QAPISchemaFeature) --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399447; cv=none; d=zohomail.com; s=zohoarc; b=lQjPbcnB4cglex3zRG+g39SyZCe06rkJO8fSPL4KM3WdjKw7jsLTvUDPx5JTXZ/0iokL0mHPw46x6u+5Zt/jRPsQW1Meg4SoNHg35DlcoxXanSU9xDrLLzZmhSb1xpTdyDXVTZU+rQYElkOmZtbygl4qgCZPl+B33fva3VNwerE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399447; 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=XL7pAN2ei2uS8tPcluVqcUzLAMsJUai7U4gMv/imTms=; b=AmDC3MbxbCCFVYPJPAqbWrd/7RQlk7pfaP/A1y6NgOWjPZEmITyRmFzpfqBzdnzGDeAxmkZjWRHbmqPTwa6Wb235TUxjJd2J5lzi7jNDqV12taeibKgAv00SNM7eI+o4dVziINfEn+6elhM/H/q/96nVdsQnNYnFh1RkPz9RtFU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399447774209.680113440097; Wed, 3 Feb 2021 16:44:07 -0800 (PST) Received: from localhost ([::1]:57026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Skg-0003Qv-M7 for importer@patchew.org; Wed, 03 Feb 2021 19:44:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZU-0001R5-Es for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZK-0000fG-8h for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:32 -0500 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-235-ZFU5bkBMO7iWkXKAjyu7ZA-1; Wed, 03 Feb 2021 19:32:19 -0500 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 4539EAFA81 for ; Thu, 4 Feb 2021 00:32:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4E9D1007622; Thu, 4 Feb 2021 00:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398741; 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=XL7pAN2ei2uS8tPcluVqcUzLAMsJUai7U4gMv/imTms=; b=HWHUWG3ZtoHXy6VOrhqv3F6ywdONg0E5PlNYt8xqa/P1JvT9npV74wFUYoVom/Ks74SbTy 9ZgoJSZmPRKk0v1ZbgKMUO/midpjYWJ7dapbPF1aQRF3I0SSc1Ept/14T/s6QTWu70ubkc k0SbUJvH0P8iSY7EjuDsu0VAtLz5Uk4= X-MC-Unique: ZFU5bkBMO7iWkXKAjyu7ZA-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 13/15] qapi/introspect.py: add introspect.json dummy types Date: Wed, 3 Feb 2021 19:32:05 -0500 Message-Id: <20210204003207.2856909-14-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add some aliases that declare intent for some of the "dictly-typed" objects we pass around in introspect.py. Signed-off-by: John Snow --- This patch is optional, it can be dropped if desired. If it's taken, it's probably best to squash it with the prior patch. It is purely for the sake of demonstrating what the _DObject was meant to convey: a Python Dict that represents some JSON Object. It does not add any type safety in and of itself, but does have some (light) annotational benefit. In this case, it's usually a specific data structure from the QAPI Schema we are referencing, but do not have "compile-time" access to in Python. These are loosely typed and don't bother reproducing the exact structure of the real types. Python 3.6 does not have support for TypedDict structures, so this is as good as we can do without involving a third-party library (e.g. Pydantic), in which we might be able to say: class SchemaMetaType(str, enum.Enum): BUILTIN =3D "builtin" ENUM =3D "enum" ARRAY =3D "array" OBJECT =3D "object" ALTERNATE =3D "alternate" COMMAND =3D "command" EVENT =3D "event" class SchemaInfo(pydantic.BaseModel): name: str meta-type: SchemaMetaType features: Optional[List[str]] data: Union[SchemaInfoBuiltin, SchemaInfoEnum, SchemaInfoArray, SchemaInfoObject, SchemaInfoAlternate, SchemaInfoCommand, SchemaInfoEvent] However, the cost of reproducing and keeping these structure definitions in-sync between the user-defined portion of the schema and the code generator is likely not worth doing any such thing. However, it does illustrate an interesting dependency the generator has on the user-defined schema itself in terms of types. So, I settled on using some light types that suggest the form of the object instead of enforcing the form. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 51 +++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 3afcdda7446..2a39726f40a 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -66,10 +66,15 @@ _value =3D Union[_scalar, _nonscalar] TreeValue =3D Union[_value, 'Annotated[_value]'] =20 -# This is an alias for an arbitrary JSON object, represented here as a Dic= t. -# It is stricter on the value type than the recursive definition above. -# It is used to represent SchemaInfo-related structures exclusively. -_DObject =3D Dict[str, object] +# These types are based on structures defined in QEMU's schema, so we lack +# precise types for them here. Python 3.6 does not offer TypedDict constru= cts, +# so they are broadly typed here as simple Python Dicts. +SchemaInfo =3D Dict[str, object] +SchemaInfoObject =3D Dict[str, object] +SchemaInfoObjectVariant =3D Dict[str, object] +SchemaInfoObjectMember =3D Dict[str, object] +SchemaInfoCommand =3D Dict[str, object] + =20 _NodeT =3D TypeVar('_NodeT', bound=3D_value) =20 @@ -162,7 +167,7 @@ def __init__(self, prefix: str, unmask: bool): ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask self._schema: Optional[QAPISchema] =3D None - self._trees: List[Annotated[_DObject]] =3D [] + self._trees: List[Annotated[SchemaInfo]] =3D [] self._used_types: List[QAPISchemaType] =3D [] self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' @@ -234,9 +239,18 @@ def _gen_features(features: List[QAPISchemaFeature] ) -> List[Annotated[str]]: return [Annotated(f.name, f.ifcond) for f in features] =20 - def _gen_tree(self, name: str, mtype: str, obj: _DObject, + def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object], ifcond: List[str], features: Optional[List[QAPISchemaFeature]]) -> None: + """ + Build and append a SchemaInfo object to self._trees. + + :param name: The entity's name. + :param mtype: The entity's meta-type. + :param obj: Additional entity fields, as appropriate for the meta-= type. + :param ifcond: List of conditionals that apply to this entire enti= ty. + :param features: Optional features field for SchemaInfo. + """ comment: Optional[str] =3D None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -251,8 +265,8 @@ def _gen_tree(self, name: str, mtype: str, obj: _DObjec= t, self._trees.append(Annotated(obj, ifcond, comment)) =20 def _gen_member(self, member: QAPISchemaObjectTypeMember - ) -> Annotated[_DObject]: - obj: _DObject =3D { + ) -> Annotated[SchemaInfoObjectMember]: + obj: SchemaInfoObjectMember =3D { 'name': member.name, 'type': self._use_type(member.type) } @@ -262,13 +276,9 @@ def _gen_member(self, member: QAPISchemaObjectTypeMemb= er obj['features'] =3D self._gen_features(member.features) return Annotated(obj, member.ifcond) =20 - def _gen_variants(self, tag_name: str, - variants: List[QAPISchemaVariant]) -> _DObject: - return {'tag': tag_name, - 'variants': [self._gen_variant(v) for v in variants]} - - def _gen_variant(self, variant: QAPISchemaVariant) -> Annotated[_DObje= ct]: - obj: _DObject =3D { + def _gen_variant(self, variant: QAPISchemaVariant + ) -> Annotated[SchemaInfoObjectVariant]: + obj: SchemaInfoObjectVariant =3D { 'case': variant.name, 'type': self._use_type(variant.type) } @@ -300,11 +310,12 @@ def visit_object_type_flat(self, name: str, info: Opt= ional[QAPISourceInfo], features: List[QAPISchemaFeature], members: List[QAPISchemaObjectTypeMember], variants: Optional[QAPISchemaVariants]) -> = None: - obj: _DObject =3D {'members': [self._gen_member(m) for m in member= s]} + obj: SchemaInfoObject =3D { + 'members': [self._gen_member(m) for m in members] + } if variants: - obj.update(self._gen_variants(variants.tag_member.name, - variants.variants)) - + obj['tag'] =3D variants.tag_member.name + obj['variants'] =3D [self._gen_variant(v) for v in variants.va= riants] self._gen_tree(name, 'object', obj, ifcond, features) =20 def visit_alternate_type(self, name: str, info: Optional[QAPISourceInf= o], @@ -329,7 +340,7 @@ def visit_command(self, name: str, info: Optional[QAPIS= ourceInfo], =20 arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type - obj: _DObject =3D { + obj: SchemaInfoCommand =3D { 'arg-type': self._use_type(arg_type), 'ret-type': self._use_type(ret_type) } --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399694; cv=none; d=zohomail.com; s=zohoarc; b=ft/7AVZyvMzHOOlqHGe4EvCZYmx8G7Rr7TlBWUktxiMB7N/1fhWMU367sA4F+n3MqifroM5/Z9LfwlHblHXYA+r9pkaz+KGzVkprBiEfnM1URVYDODzqP6mfCPerdKxWqOTVN4HiUK3s/pyMnCNVBL8ApXMyWMIPKNVvtnRBNpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399694; 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=hn7XAQ7KOPuGPXVaIcggXWilkehuclPeKx/MkWKHcsU=; b=XXFk9oXaBiTFerR6U4vorD+V7rE7rGGANngHUuz6UFeaHmPtchkF0mhr3c0SwxFddG3YgKnXeor2GsV1YjbKdGUtqhB/AqXrEMldgosGgXBoDH9xR7sv/stAE76iUErw8hxct882gqtftBmPO6oBX40Cytv/p2X94yZowRq0Ht0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399694155249.28044013397619; Wed, 3 Feb 2021 16:48:14 -0800 (PST) Received: from localhost ([::1]:39020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sof-0007sE-0n for importer@patchew.org; Wed, 03 Feb 2021 19:48:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZV-0001U3-Li for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZK-0000fM-KT for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:33 -0500 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-139-pygJG_PgOZqtegNs57inwA-1; Wed, 03 Feb 2021 19:32:20 -0500 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 08C8F107ACF4 for ; Thu, 4 Feb 2021 00:32:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69BAF100AE4A; Thu, 4 Feb 2021 00:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398741; 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=hn7XAQ7KOPuGPXVaIcggXWilkehuclPeKx/MkWKHcsU=; b=O4Zei9epUaDtyeEmkXGqfvwQkWnb/m6QRFljBJRLwlr/vTZvvCxxlkBCpsGxpKGxd0xgmG a3eOKxzG6omclk6yd4JHna41GVtRy1SH2i97dmDqYRDjaBWv/8B5SkZwTJ7QVccB9mzuTX qXGFaZ/LlvyWUPhUvlfjfQizNihWpVM= X-MC-Unique: pygJG_PgOZqtegNs57inwA-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 14/15] qapi/introspect.py: Add docstring to _tree_to_qlit Date: Wed, 3 Feb 2021 19:32:06 -0500 Message-Id: <20210204003207.2856909-15-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- scripts/qapi/introspect.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 2a39726f40a..2b338abe2cf 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -97,6 +97,14 @@ def __init__(self, value: _NodeT, ifcond: Iterable[str], def _tree_to_qlit(obj: TreeValue, level: int =3D 0, dict_value: bool =3D False) -> str: + """ + Convert the type tree into a QLIT C string, recursively. + + :param obj: The value to convert. + :param level: The indentation level for this particular value. + :param dict_value: True when the value being processed belongs to a + dict key; which suppresses the output indent. + """ =20 def indent(level: int) -> str: return level * 4 * ' ' --=20 2.29.2 From nobody Sat May 18 21:16:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612399836; cv=none; d=zohomail.com; s=zohoarc; b=grOHKrXQmPgTOXxw/jsQJiz6X3t/i0f0J0f2VHTRRSziZUuIPZlyEnR5nsuT5MUcP+KxZFE+gBlA3RosguiKkxViP+CfKqxrn1mzvK4Mi4pWyLqafecaSSQwJlZ5AS47bzabDLYZn6uuQCbE/VO5tJ1B5xN1HMGf30UU+37GH74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612399836; 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=GMT7eZx1fLSXQkHuaaVct0GDfiqMgm+QsNGFrYVYbZ4=; b=AKmWdzdCINwRUAUBXKvp/JmhKM9A4msaQr1n8HPvtwFZowQyWW0Vph0i6pcueZKzG0N26FGDBmTJ00AjdFXVSAydYwvEoGi14QV9TqlNB7MmLCTHVLXyp5yOdFsZNYWBG9aV9K8+CBfntaPVBbhXix3vl5stPmo+GzMEJZW9mO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612399836331116.7107497328036; Wed, 3 Feb 2021 16:50:36 -0800 (PST) Received: from localhost ([::1]:41364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Sqx-0000Wg-5Q for importer@patchew.org; Wed, 03 Feb 2021 19:50:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZX-0001Yf-Fy for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7SZL-0000fU-1X for qemu-devel@nongnu.org; Wed, 03 Feb 2021 19:32:35 -0500 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-361-mVegGDQFN0G4oKdJxVRXVg-1; Wed, 03 Feb 2021 19:32:20 -0500 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 C0241108C30A for ; Thu, 4 Feb 2021 00:32:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CF95100AE4A; Thu, 4 Feb 2021 00:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398742; 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=GMT7eZx1fLSXQkHuaaVct0GDfiqMgm+QsNGFrYVYbZ4=; b=Iur7M9BhNZ2PToU41U9pn0Kcpr5R5n50wQFYf59qujTm36TXRNvBxPlgymbcOV10wO9rsT QgBOGMDiya9050dTb9hEyZAFrq+hLHlanbCXAzbjQWtLrEzKNXAC6r5XGl9qfca3uY1Kf9 c2PON/n9bG5UJQBvk8qJxdhUDHuQE60= X-MC-Unique: mVegGDQFN0G4oKdJxVRXVg-1 From: John Snow To: Markus Armbruster , qemu-devel@nongnu.org Subject: [PATCH v5 15/15] qapi/introspect.py: Update copyright and authors list Date: Wed, 3 Feb 2021 19:32:07 -0500 Message-Id: <20210204003207.2856909-16-jsnow@redhat.com> In-Reply-To: <20210204003207.2856909-1-jsnow@redhat.com> References: <20210204003207.2856909-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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: John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- scripts/qapi/introspect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 2b338abe2cf..fd0ca0aba21 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -1,10 +1,11 @@ """ QAPI introspection generator =20 -Copyright (C) 2015-2018 Red Hat, Inc. +Copyright (C) 2015-2021 Red Hat, Inc. =20 Authors: Markus Armbruster + John Snow =20 This work is licensed under the terms of the GNU GPL, version 2. See the COPYING file in the top-level directory. --=20 2.29.2