From nobody Tue Nov 18 05:48:44 2025 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=1607990094; cv=none; d=zohomail.com; s=zohoarc; b=Va3hBTXNXWyomCdapXB8G1uueqykjwxorz0q4ESeCVtF8Lh5ZU5NJ8b8kT2VcHP9WiEQmCWb0s4+hcHVT0q1ZJ462jHrHmlLMv4E5fvb3Ml07FMte+9SIZaUglmTqV1H9MxVbtuCFzz0QaJhvwE6SlUlyu96terdxM/fWNwcRsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990094; 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=N44H5z57ZOXvSx+mP+v50AsYGRCeBOq0OYHfLEQ2EjE=; b=fZ0sTLSFEZx5ifpt7o1DQPJya6n3EiIEZrGGSDqMgRSbkdxpeXIrXfAUAEaXYhe312VyjrUrLg3GJDtxGrA7RBOODeHxbSCSr8IbjJaAc4HJ9Y9+dmzrMbLULJ59KukIGROcLvL5uP2GhxPWV8f4q5BRNLC07ID1yeHdQQv6EAA= 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 1607990094664148.25245827240383; Mon, 14 Dec 2020 15:54:54 -0800 (PST) Received: from localhost ([::1]:59198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxg5-0004di-FM for importer@patchew.org; Mon, 14 Dec 2020 18:54:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxex-00033O-Ag for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49757) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxeu-0000st-M8 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:43 -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-34-WLkxIVxsPj6VbhTlLyfGhA-1; Mon, 14 Dec 2020 18:53:37 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9DB9800467 for ; Mon, 14 Dec 2020 23:53:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id E890870484; Mon, 14 Dec 2020 23:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990020; 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=N44H5z57ZOXvSx+mP+v50AsYGRCeBOq0OYHfLEQ2EjE=; b=RXStWacWMVVwod2yKsKPHJyzXYw1KvHD94/xSUMf5SkquqkAUjTEAiGIyz9dbJGWMuu+qz IzD7bGixE6MDEJ87Yxhb15C1VK7aCQ5v0pa2LzBeOOOcBmkaZbMJQkvX5tnvK7b8NeWzN9 yP7LKhjU2x11BaGU+9DYUjhiHV5c5W0= X-MC-Unique: WLkxIVxsPj6VbhTlLyfGhA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 01/12] qapi/commands: assert arg_type is not None Date: Mon, 14 Dec 2020 18:53:16 -0500 Message-Id: <20201214235327.1007124-2-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" when boxed is true, expr.py asserts that we must have arguments. Ultimately, this should mean that if boxed is True, that arg_type should be defined. Mypy cannot infer this, and does not support 'stateful' type inference, e.g.: ``` if x: assert y is not None ... if x: y.etc() ``` does not work, because mypy does not statefully remember the conditional assertion in the second block. Help mypy out by creating a new local that it can track more easily. Signed-off-by: John Snow --- scripts/qapi/commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 50978090b440..71744f48a353 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -126,6 +126,9 @@ def gen_marshal(name: str, boxed: bool, ret_type: Optional[QAPISchemaType]) -> str: have_args =3D boxed or (arg_type and not arg_type.is_empty()) + if have_args: + assert arg_type is not None + arg_type_c_name =3D arg_type.c_name() =20 ret =3D mcgen(''' =20 @@ -147,7 +150,7 @@ def gen_marshal(name: str, ret +=3D mcgen(''' %(c_name)s arg =3D {0}; ''', - c_name=3Darg_type.c_name()) + c_name=3Darg_type_c_name) =20 ret +=3D mcgen(''' =20 @@ -163,7 +166,7 @@ def gen_marshal(name: str, ok =3D visit_check_struct(v, errp); } ''', - c_arg_type=3Darg_type.c_name()) + c_arg_type=3Darg_type_c_name) else: ret +=3D mcgen(''' ok =3D visit_check_struct(v, errp); @@ -193,7 +196,7 @@ def gen_marshal(name: str, ret +=3D mcgen(''' visit_type_%(c_arg_type)s_members(v, &arg, NULL); ''', - c_arg_type=3Darg_type.c_name()) + c_arg_type=3Darg_type_c_name) =20 ret +=3D mcgen(''' visit_end_struct(v, NULL); --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990115; cv=none; d=zohomail.com; s=zohoarc; b=BrYVdC11afWgMkdMe+V89LDvDClbgl9d5Jz9zcKrHgH+6KFId9g2Gpo5UclErOvAe6Mb98+SJKX5BJktmhxl4nIGc2Hyu29A/DC/7jqubyRF1dc8/28nqy2kBkZPqnUqCtNCdhc/Bu3mDrQ8UWBtcW/uF4V5hGX2NT0M2+VuXec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990115; 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=iuhWeksv3jkJDkAmjl12mWMS4DFMKWnmIdfOWNDchdI=; b=dPSdM5PfXqSr29OH0Zz+68FtGc6dQqXMxtloYUgfl7MnHMsFTU6ZagwQ6mJYkiL2mhKh41Xn7kFW2ZFf4EvIi9FhQzUg3aLJMlTtYGbdhWbcp+k2f92MYH5tSFpYwU/iFaTEStheVAr1nItDTBuLCzeb5KXnCS08+Nbo4sba0x0= 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 1607990115485709.9809594840791; Mon, 14 Dec 2020 15:55:15 -0800 (PST) Received: from localhost ([::1]:59584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxgO-0004oL-Pf for importer@patchew.org; Mon, 14 Dec 2020 18:55:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxez-00037c-V6 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxey-0000tE-AH for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:45 -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-210-3RRS7dUwPnynP0ByeuzDjw-1; Mon, 14 Dec 2020 18:53:42 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47BAB10054FF for ; Mon, 14 Dec 2020 23:53:41 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id D04F913470; Mon, 14 Dec 2020 23:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990023; 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=iuhWeksv3jkJDkAmjl12mWMS4DFMKWnmIdfOWNDchdI=; b=cr5YiW/rYCaFXNKJQDk8VbbbU/Mqb4FXb23wtUdhJ1dYtglEI3cqmZCoEDXd8wPNUokkr/ OBwBjMLck2iM1MR1lfAASABNL3b2z5uBx9demOYZVubHGhIO7WJSJ0Avfs5J2ffUmWGsIG AvwyHWlMkb/x89A1Lj3Zh6Kl84HEVuU= X-MC-Unique: 3RRS7dUwPnynP0ByeuzDjw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 02/12] qapi/events: fix visit_event typing Date: Mon, 14 Dec 2020 18:53:17 -0500 Message-Id: <20201214235327.1007124-3-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" Actually, the arg_type can indeed be Optional. Signed-off-by: John Snow --- scripts/qapi/events.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 599f3d1f564b..9851653b9d11 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -12,7 +12,7 @@ See the COPYING file in the top-level directory. """ =20 -from typing import List +from typing import List, Optional =20 from .common import c_enum_const, c_name, mcgen from .gen import QAPISchemaModularCVisitor, build_params, ifcontext @@ -27,7 +27,7 @@ =20 =20 def build_event_send_proto(name: str, - arg_type: QAPISchemaObjectType, + arg_type: Optional[QAPISchemaObjectType], boxed: bool) -> str: return 'void qapi_event_send_%(c_name)s(%(param)s)' % { 'c_name': c_name(name.lower()), @@ -35,7 +35,7 @@ def build_event_send_proto(name: str, =20 =20 def gen_event_send_decl(name: str, - arg_type: QAPISchemaObjectType, + arg_type: Optional[QAPISchemaObjectType], boxed: bool) -> str: return mcgen(''' =20 @@ -78,7 +78,7 @@ def gen_param_var(typ: QAPISchemaObjectType) -> str: =20 =20 def gen_event_send(name: str, - arg_type: QAPISchemaObjectType, + arg_type: Optional[QAPISchemaObjectType], boxed: bool, event_enum_name: str, event_emit: str) -> str: @@ -99,6 +99,7 @@ def gen_event_send(name: str, proto=3Dbuild_event_send_proto(name, arg_type, boxed)) =20 if have_args: + assert arg_type is not None ret +=3D mcgen(''' QObject *obj; Visitor *v; @@ -114,6 +115,7 @@ def gen_event_send(name: str, name=3Dname) =20 if have_args: + assert arg_type is not None ret +=3D mcgen(''' v =3D qobject_output_visitor_new(&obj); ''') @@ -214,7 +216,7 @@ def visit_event(self, info: QAPISourceInfo, ifcond: List[str], features: List[QAPISchemaFeature], - arg_type: QAPISchemaObjectType, + arg_type: Optional[QAPISchemaObjectType], boxed: bool) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990102; cv=none; d=zohomail.com; s=zohoarc; b=ChfNCOodJrcBOP+/KD0VEvBt/PjZ2MVg6LUpw6s9+Q3HqqAk3z9mc+OTioFF9JkNTMr0DOEvqfVj88fOZNEFhe/6mx8PKB/od39euc+WYOu9m6wB9aVk3PO3lCcsYmh0Q/cS8+SFbQXNYur3EVPT1NVARhVNfDN4UG7HPxW+JwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990102; 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=jVZwYme5l6iEWkwayovcx/tWuBg7uP8L2Dd8B4g03us=; b=iojt7zTS9MDI6pMQIQIs31VTzhuZCTUL2PTyh16JVqiAoUbw3IQpXZSZcbx/f4RP6YH2to6y+YW9NDjJKuiWqwJe3xkGYxZjFg9fJjRG0EOVR+/HyzUhKCtAdMeOOYRKofc53/C7NQbvhws3YEq2+6DJLYi5id+CoXNvTpA+TGc= 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 1607990102497159.90284654992877; Mon, 14 Dec 2020 15:55:02 -0800 (PST) Received: from localhost ([::1]:59640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxgD-0004pf-FX for importer@patchew.org; Mon, 14 Dec 2020 18:55:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxf1-0003A4-6S for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxez-0000tK-OK for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:46 -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-434-C-HmTC8gMUiJCvR10hghcA-1; Mon, 14 Dec 2020 18:53:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35CAD1015C80 for ; Mon, 14 Dec 2020 23:53:42 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7073370484; Mon, 14 Dec 2020 23:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990025; 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=jVZwYme5l6iEWkwayovcx/tWuBg7uP8L2Dd8B4g03us=; b=NPfW9+U0tQpS//n8R6X05O8DneyytY+zsxagItEeqgArlzURzeKNzPC8roDUX1pUzBfw+t iQQknTMrcpBlzNxG7UFg7EXN34OVZm2K0PVZdUc6alU11Z5j2bgax41UKifde2xW4S9EmA MgQoCjSDUXHIMgGu7sNpZmw6G5A6jRE= X-MC-Unique: C-HmTC8gMUiJCvR10hghcA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 03/12] qapi/main: handle theoretical None-return from re.match() Date: Mon, 14 Dec 2020 18:53:18 -0500 Message-Id: <20201214235327.1007124-4-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" Mypy cannot understand that this match can never be None, so help it along. Signed-off-by: John Snow --- scripts/qapi/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index 42517210b805..271d9e84da94 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -23,7 +23,8 @@ =20 def invalid_prefix_char(prefix: str) -> Optional[str]: match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix) - if match.end() !=3D len(prefix): + # match cannot be None, but mypy cannot infer that. + if match and match.end() !=3D len(prefix): return prefix[match.end()] return None =20 --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990226; cv=none; d=zohomail.com; s=zohoarc; b=kWd2gIfztobK07o4SXtYTvVW8RwxY6vsRovbywdlEX+aPEd9aHeD3Rob7Rs0iSOC640pySQ6mAwebrRj1/JhG4PP53fiC6Ek8oydUKqM0+6+5l5HU8zcYV+0h52tWx8Ua/Ly1Dsp1Do8ryoudakgrf836lHT28yvrm/OamzyLsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990226; 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=BzwysPB6rJBtPSdp674bMPM34g2T/AXsb1hxa0ijq5w=; b=MC7T3q8htfZ25FrljgLKzfjVD/uL7YfQfpOSnomMWVPPxIdCwRPC20LkBzxhPMTtN7As7ROWe2lwZMgh8pc3Wh7H98ahuXW83Gey07fw6xYvxQjyMfMDttB2RoL/YT6LAj6LgjADVROEvk+CUlrQrVkLaJWhfPABVuR4A4QytMY= 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 1607990226621996.7469408857506; Mon, 14 Dec 2020 15:57:06 -0800 (PST) Received: from localhost ([::1]:38856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxiD-0007vc-EU for importer@patchew.org; Mon, 14 Dec 2020 18:57:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxf1-0003B4-Ju for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf0-0000tO-2G for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:47 -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-584-IyEPKtL9OfGdReyOH18n6w-1; Mon, 14 Dec 2020 18:53:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C82359 for ; Mon, 14 Dec 2020 23:53:43 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D56813470; Mon, 14 Dec 2020 23:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990025; 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=BzwysPB6rJBtPSdp674bMPM34g2T/AXsb1hxa0ijq5w=; b=bLzMdcB5TOdzX1x6nZKxkTu7bErT/PgZssOMLdWWUjAzdC4CDg9ThRmmPgZlFKpklr1xKQ R8t1Bjx2JPz9F4Rn5hssKr3SFO05bJILE9UFyO1E2/viLeInr+IuDc3CZYvF0X1mS17pzL oRV8M11+6pBQjaIBN/yIDFMPREl5/xo= X-MC-Unique: IyEPKtL9OfGdReyOH18n6w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 04/12] qapi/gen: assert that _start_if is not None in _wrap_ifcond Date: Mon, 14 Dec 2020 18:53:19 -0500 Message-Id: <20201214235327.1007124-5-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" We already assert this in end_if, but that's opaque to mypy. Do it in _wrap_ifcond instead. Same effect at runtime, but mypy can now infer the type in _wrap_ifcond's body. Signed-off-by: John Snow --- scripts/qapi/gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index b40f18eee3cd..a6dc991b1d03 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -130,11 +130,11 @@ def start_if(self, ifcond: List[str]) -> None: self._start_if =3D (ifcond, self._body, self._preamble) =20 def end_if(self) -> None: - assert self._start_if self._wrap_ifcond() self._start_if =3D None =20 def _wrap_ifcond(self) -> None: + assert self._start_if self._body =3D _wrap_ifcond(self._start_if[0], self._start_if[1], self._body) self._preamble =3D _wrap_ifcond(self._start_if[0], --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990231; cv=none; d=zohomail.com; s=zohoarc; b=i1amsr5n53eDV2rA4n4RTM5oRzYdvUcQOtcXsodr+mXaXwSxVYwVRH2P6/a6TaZPTZH1TJmL3SfsMimRyHo1ypPwLEjkVPqowFvlXgVLwhgPgzNihUxUxhpXnJ2LT7YJ7VtS2pVeliQX8KoX4xu7wi1mVQex7CxPVNHIRhz84MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990231; 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=hKFNRCIXPnZk+5v+fBW9tO/zhEtLRaI3ZElq3h4Cm8U=; b=Gkj32+wQbISC4sDHK9CpQ22y22IQEqemH7A1NMDmibv4LMbhRd22FIRQMYtjaSmkbX3E7fN6Iosoix+KD+lmwviV/m5zw5JgXXwPYqBEbJcQuL32hGKzOz5vn4ASNHFjCctO8BTBynodpzHLM4sOu6zhaRFQ43L4yhspB5a/3wI= 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 1607990231332353.74597886865774; Mon, 14 Dec 2020 15:57:11 -0800 (PST) Received: from localhost ([::1]:39244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxiI-000851-66 for importer@patchew.org; Mon, 14 Dec 2020 18:57:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxf3-0003GD-H0 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf1-0000ta-Q5 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:49 -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-53-WZeX_-YdMd6P2o05YjVmhA-1; Mon, 14 Dec 2020 18:53:45 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19CA3800D55 for ; Mon, 14 Dec 2020 23:53:44 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 459D113470; Mon, 14 Dec 2020 23:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990026; 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=hKFNRCIXPnZk+5v+fBW9tO/zhEtLRaI3ZElq3h4Cm8U=; b=JmxBJIvK2c41m/bT6tGwMDiYh+6KifHzQlvgWI31/PknM0D/j7t4KH3R6D88z9fNdeMNpo 61KataqJ4ajhDUamljv151o519kqWlGf/+/Qf5NGbJaJWJV4JL+VAGM2D7S3EjTFIZgrE3 k/fkvkCs7mUM4JQhrPjGhmwiF2zO1PE= X-MC-Unique: WZeX_-YdMd6P2o05YjVmhA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 05/12] qapi/gen: use './builtin' for the built-in module name Date: Mon, 14 Dec 2020 18:53:20 -0500 Message-Id: <20201214235327.1007124-6-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" Use this in preference to 'None', which helps remove some edge cases in the typing. Signed-off-by: John Snow --- scripts/qapi/gen.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index a6dc991b1d03..0c5d1fee6088 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -245,23 +245,23 @@ def __init__(self, self._pydoc =3D pydoc self._genc: Optional[QAPIGenC] =3D None self._genh: Optional[QAPIGenH] =3D None - self._module: Dict[Optional[str], Tuple[QAPIGenC, QAPIGenH]] =3D {} + self._module: Dict[str, Tuple[QAPIGenC, QAPIGenH]] =3D {} self._main_module: Optional[str] =3D None =20 @staticmethod - def _is_user_module(name: Optional[str]) -> bool: - return bool(name and not name.startswith('./')) + def _is_user_module(name: str) -> bool: + return not name.startswith('./') =20 @staticmethod - def _is_builtin_module(name: Optional[str]) -> bool: - return not name + def _is_builtin_module(name: str) -> bool: + return name =3D=3D './builtin' =20 - def _module_dirname(self, name: Optional[str]) -> str: + def _module_dirname(self, name: str) -> str: if self._is_user_module(name): return os.path.dirname(name) return '' =20 - def _module_basename(self, what: str, name: Optional[str]) -> str: + def _module_basename(self, what: str, name: str) -> str: ret =3D '' if self._is_builtin_module(name) else self._prefix if self._is_user_module(name): basename =3D os.path.basename(name) @@ -269,15 +269,14 @@ def _module_basename(self, what: str, name: Optional[= str]) -> str: if name !=3D self._main_module: ret +=3D '-' + os.path.splitext(basename)[0] else: - name =3D name[2:] if name else 'builtin' - ret +=3D re.sub(r'-', '-' + name + '-', what) + ret +=3D re.sub(r'-', '-' + name[2:] + '-', what) return ret =20 - def _module_filename(self, what: str, name: Optional[str]) -> str: + def _module_filename(self, what: str, name: str) -> str: return os.path.join(self._module_dirname(name), self._module_basename(what, name)) =20 - def _add_module(self, name: Optional[str], blurb: str) -> None: + def _add_module(self, name: str, blurb: str) -> None: basename =3D self._module_filename(self._what, name) genc =3D QAPIGenC(basename + '.c', blurb, self._pydoc) genh =3D QAPIGenH(basename + '.h', blurb, self._pydoc) @@ -290,8 +289,8 @@ def _add_user_module(self, name: str, blurb: str) -> No= ne: self._main_module =3D name self._add_module(name, blurb) =20 - def _add_system_module(self, name: Optional[str], blurb: str) -> None: - self._add_module(name and './' + name, blurb) + def _add_system_module(self, name: str, blurb: str) -> None: + self._add_module(f"./{name}", blurb) =20 def write(self, output_dir: str, opt_builtins: bool =3D False) -> None: for name in self._module: @@ -310,7 +309,7 @@ def _begin_user_module(self, name: str) -> None: def visit_module(self, name: Optional[str]) -> None: if name is None: if self._builtin_blurb: - self._add_system_module(None, self._builtin_blurb) + self._add_system_module('builtin', self._builtin_blurb) self._begin_system_module(name) else: # The built-in module has not been created. No code may --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990239; cv=none; d=zohomail.com; s=zohoarc; b=kO26gcrtwx5I5Awe4OOp+3TSd98e7FjCsMUWPesSr1gGHzDcubaYSUzznO+uJ2ncHCLcFyxikOYL7F3zIvy0d7d+moXin2px/SzMKzCCy37bKSZD06f/EdbWRzWVGqxDKTaHRGgbR/zBEflSqcDpQT+85pJkoPBn+Kj2dspqvtE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990239; 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=yVunUmIG6winirkBVZemtaF3IjSeIhFGCw8J53mrOFg=; b=OdCGDF8LdwVqGhCanS1Jya0oEpJ8JbiPaRlO4lQBn1lIXc9p1uiBDbGDxMMh8P3COQ6iQC8K/eNaBH339hzHY+nOiv6NdAkz698UsSDXObiMeGk61F7X7okeKBbIfRviNQqDFio8bfpTF6xkACD+jpGglg83kGUJNanynwunLTY= 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 1607990239654533.8181028427265; Mon, 14 Dec 2020 15:57:19 -0800 (PST) Received: from localhost ([::1]:39408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxiQ-000893-Kj for importer@patchew.org; Mon, 14 Dec 2020 18:57:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxf4-0003Hj-0s for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf2-0000tm-97 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:49 -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-550-9c5lhPtQOGqSjwBzM9J5MQ-1; Mon, 14 Dec 2020 18:53:45 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0201F59 for ; Mon, 14 Dec 2020 23:53:45 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43F3F13470; Mon, 14 Dec 2020 23:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990027; 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=yVunUmIG6winirkBVZemtaF3IjSeIhFGCw8J53mrOFg=; b=AAmBz/K8z79r8mm9NZB4UXSws4NCqs8CFaI9zAuuDCaFMZQ+kvJk/MgIY7LkGt/Ns7wcuJ +jNU9ir7yJCaIPoa/6QJaBGfrrzxq1RIrGFMLuZsMDN4uSjeqcPNv/OWYUuJuNXwk313c4 131xFI77sXeoEWecuVgeDPW8XO7mQm4= X-MC-Unique: 9c5lhPtQOGqSjwBzM9J5MQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/12] qapi/source: Add builtin null-object sentinel Date: Mon, 14 Dec 2020 18:53:21 -0500 Message-Id: <20201214235327.1007124-7-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" We use None to represent an object that has no source information because it's a builtin. This complicates interface typing, since many interfaces expect that there is an info object available to print errors with. Introduce a special QAPISourceInfo that represents these built-ins so that if an error should so happen to occur relating to one of these builtins that we will be able to print its information, and interface typing becomes simpler: you will always have a source info object. This object will evaluate as False, so "if info" is a valid idiomatic construct. NB: It was intentional to not allow empty constructors or similar to create "empty" source info objects; callers must explicitly invoke 'builtin()' to pro-actively opt into using the sentinel. This should prevent use-by-accident. Signed-off-by: John Snow --- scripts/qapi/source.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py index d7a79a9b8aee..64af7318cb67 100644 --- a/scripts/qapi/source.py +++ b/scripts/qapi/source.py @@ -11,7 +11,12 @@ =20 import copy import sys -from typing import List, Optional, TypeVar +from typing import ( + List, + Optional, + Type, + TypeVar, +) =20 =20 class QAPISchemaPragma: @@ -41,6 +46,17 @@ def __init__(self, fname: str, line: int, self.defn_meta: Optional[str] =3D None self.defn_name: Optional[str] =3D None =20 + @classmethod + def builtin(cls: Type[T]) -> T: + """ + Create a SourceInfo object corresponding to a builtin definition. + """ + return cls('', -1, None) + + def __bool__(self) -> bool: + # "if info: ..." is false if info is the builtin sentinel. + return bool(self.fname) + def set_defn(self, meta: str, name: str) -> None: self.defn_meta =3D meta self.defn_name =3D name @@ -73,4 +89,6 @@ def include_path(self) -> str: return ret =20 def __str__(self) -> str: + if not bool(self): + return '[builtin]' return self.include_path() + self.in_defn() + self.loc() --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990371; cv=none; d=zohomail.com; s=zohoarc; b=hc1wR+iuGYsqZUjeo6hxRAk5wQHnw32XwUK6lavmq4Ev86l0FSqdnSlae59lIkVG6VdzgN+Q6PfAGRNefV9jXh1/WjZl3uHYOpO5QEtaoafpvXdVYrinIAuN0+sisd2rq3KMF75HQ6riQcE0Dq6bl11PEe3dztcXSd6hu9IFGNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990371; 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=fU1x3aYfkQgbpuX5Pv2W3fUdPM/d6b7VrrWfI36y0ls=; b=Yg3ZhVNhU0WyPTEMMcY+wbNNaWHCrpTpu87XNtPJ3DsdQHjmUa2iU3WbjyvJh1uqSEbnA9TD2n51OaGWFY9R0TEBQmn3cZbDqG9GMJXXHWRMcbjeYUEWF0z8RwvLYZzMB/iBosBS0lKKMvLec4AnXiEJnJ2LqNo6DuzVBJfMILE= 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 1607990371272565.0829213780502; Mon, 14 Dec 2020 15:59:31 -0800 (PST) Received: from localhost ([::1]:45158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxkV-00023O-7U for importer@patchew.org; Mon, 14 Dec 2020 18:59:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxf4-0003K9-VU for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf3-0000ts-22 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:50 -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-419-dh1MuHObOLGRRqy1TFX20g-1; Mon, 14 Dec 2020 18:53:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DBF381922964 for ; Mon, 14 Dec 2020 23:53:45 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B4A770484; Mon, 14 Dec 2020 23:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990028; 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=fU1x3aYfkQgbpuX5Pv2W3fUdPM/d6b7VrrWfI36y0ls=; b=iYZuVs0XXD5lve7wrF1TlKCTHxGFhfuQP6W7v3mUd98bGjzUCYf3PnVqN3GYRk4zgCuPMP uy/ocHTJO0FDG6USMJ1mOHoLUlzAUGWesHUN3SRmQ8ibW0t1ekkkKINKCHmwjVZt8gDIVE Z6IGPIboNSDg2jwzTFLcljsgSOdJltI= X-MC-Unique: dh1MuHObOLGRRqy1TFX20g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 07/12] qapi/gen: write _genc/_genh access shims Date: Mon, 14 Dec 2020 18:53:22 -0500 Message-Id: <20201214235327.1007124-8-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" Many places assume they can access these fields without checking them first to ensure they are defined. Eliminating the _genc and _genh fields and replacing them with functional properties that check for correct state can ease the typing overhead by eliminating the Optional[T] return type. Signed-off-by: John Snow --- scripts/qapi/gen.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 0c5d1fee6088..17ae9f4af703 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -243,11 +243,20 @@ def __init__(self, self._user_blurb =3D user_blurb self._builtin_blurb =3D builtin_blurb self._pydoc =3D pydoc - self._genc: Optional[QAPIGenC] =3D None - self._genh: Optional[QAPIGenH] =3D None + self._current_module: Optional[str] =3D None self._module: Dict[str, Tuple[QAPIGenC, QAPIGenH]] =3D {} self._main_module: Optional[str] =3D None =20 + @property + def _genc(self) -> QAPIGenC: + assert self._current_module is not None + return self._module[self._current_module][0] + + @property + def _genh(self) -> QAPIGenH: + assert self._current_module is not None + return self._module[self._current_module][1] + @staticmethod def _is_user_module(name: str) -> bool: return not name.startswith('./') @@ -281,7 +290,7 @@ def _add_module(self, name: str, blurb: str) -> None: genc =3D QAPIGenC(basename + '.c', blurb, self._pydoc) genh =3D QAPIGenH(basename + '.h', blurb, self._pydoc) self._module[name] =3D (genc, genh) - self._genc, self._genh =3D self._module[name] + self._current_module =3D name =20 def _add_user_module(self, name: str, blurb: str) -> None: assert self._is_user_module(name) @@ -314,8 +323,7 @@ def visit_module(self, name: Optional[str]) -> None: else: # The built-in module has not been created. No code may # be generated. - self._genc =3D None - self._genh =3D None + self._current_module =3D None else: self._add_user_module(name, self._user_blurb) self._begin_user_module(name) --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607991767; cv=none; d=zohomail.com; s=zohoarc; b=aBd19yFlgDa4se2Z4TN8/X6Jik5TXKmM4agESR4G8hX0gsP48Afj32Fo+sm8OtnI2EoOj+auzlByFEFZkRILLsZO4G+jdo+czkEOSmdXCgKELfWkLLzX5M5ZJNWmpVSN/jxpynOhFdIxLgL4r/MULrfUbm/tbxs+9M+tyWRGhNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607991767; 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=aJzM+YFsGGiICyChAdCIr9PaT9MkF50o/yeU+bFKzDk=; b=R8xg9bduzBdE7+rqgEcRae//OCVTYSVNeO4CqnIPUXPCZJHpEpD5ImVsJ/Hrb5a2T/cVuB/gwcCod+6S+dRFwXeRUGl+femRdqajY+VO5OIut0UcUba9WUSF2BCHT3u74v3jSBYlRcSvgCMDU2DX9qXctQo2IJvEQNJiMG178AQ= 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 1607991767046700.4315025306191; Mon, 14 Dec 2020 16:22:47 -0800 (PST) Received: from localhost ([::1]:53574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxnE-0005ZN-8N for importer@patchew.org; Mon, 14 Dec 2020 19:02:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxfH-0003bM-DY for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:54:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxfE-0000vA-1D for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:54:03 -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-562-yjNlUBl7PyaChM9dDOzYqA-1; Mon, 14 Dec 2020 18:53:47 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D44BC59 for ; Mon, 14 Dec 2020 23:53:46 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FBA270484; Mon, 14 Dec 2020 23:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990039; 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=aJzM+YFsGGiICyChAdCIr9PaT9MkF50o/yeU+bFKzDk=; b=flNaMewpq+qyCGLkQ0uxpBgiAhIkxDlm7tRbGpzpA7bkivncoF3Ay7053rdbh2ayJpR2I3 VH6arpQEzDXXgL4FMuKrYppLgKoC1PY7RH8OAlZufROMxmyNCi7h32FLauXRJiLLrKNGF9 sKxc5n08rtxp9rs8mXcFt4xlEYM2WrM= X-MC-Unique: yjNlUBl7PyaChM9dDOzYqA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 08/12] qapi/schema: make QAPISourceInfo mandatory Date: Mon, 14 Dec 2020 18:53:23 -0500 Message-Id: <20201214235327.1007124-9-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" -- events.py had an info to route, was it by choice that it wasn't before? Signed-off-by: John Snow --- scripts/qapi/events.py | 2 +- scripts/qapi/schema.py | 23 +++++++++++++---------- scripts/qapi/types.py | 9 +++++---- scripts/qapi/visit.py | 6 +++--- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 9851653b9d11..9ba4f109028d 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -225,7 +225,7 @@ def visit_event(self, self._event_emit_name)) # Note: we generate the enum member regardless of @ifcond, to # keep the enumeration usable in target-independent code. - self._event_enum_members.append(QAPISchemaEnumMember(name, None)) + self._event_enum_members.append(QAPISchemaEnumMember(name, info)) =20 =20 def gen_events(schema: QAPISchema, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 720449feee4d..d5f19732b516 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -23,6 +23,7 @@ from .error import QAPIError, QAPISemError from .expr import check_exprs from .parser import QAPISchemaParser +from .source import QAPISourceInfo =20 =20 class QAPISchemaEntity: @@ -36,10 +37,10 @@ def __init__(self, name, info, doc, ifcond=3DNone, feat= ures=3DNone): self.name =3D name self._module =3D None # For explicitly defined entities, info points to the (explicit) - # definition. For builtins (and their arrays), info is None. - # For implicitly defined entities, info points to a place that - # triggered the implicit definition (there may be more than one - # such place). + # definition. For builtins (and their arrays), info is a null-obj= ect + # sentinel that evaluates to False. For implicitly defined entitie= s, + # info points to a place that triggered the implicit definition + # (there may be more than one such place). self.info =3D info self.doc =3D doc self._ifcond =3D ifcond or [] @@ -209,7 +210,7 @@ class QAPISchemaBuiltinType(QAPISchemaType): meta =3D 'built-in' =20 def __init__(self, name, json_type, c_type): - super().__init__(name, None, None) + super().__init__(name, QAPISourceInfo.builtin(), None) assert not c_type or isinstance(c_type, str) assert json_type in ('string', 'number', 'int', 'boolean', 'null', 'value') @@ -871,7 +872,7 @@ def resolve_type(self, name, info, what): return typ =20 def _module_name(self, fname): - if fname is None: + if not fname: return None return os.path.relpath(fname, self._schema_dir) =20 @@ -897,9 +898,11 @@ def _def_builtin_type(self, name, json_type, c_type): # be nice, but we can't as long as their generated code # (qapi-builtin-types.[ch]) may be shared by some other # schema. - self._make_array_type(name, None) + self._make_array_type(name, QAPISourceInfo.builtin()) =20 def _def_predefineds(self): + info =3D QAPISourceInfo.builtin() + for t in [('str', 'string', 'char' + POINTER_SUFFIX), ('number', 'number', 'double'), ('int', 'int', 'int64_t'), @@ -917,15 +920,15 @@ def _def_predefineds(self): ('null', 'null', 'QNull' + POINTER_SUFFIX)]: self._def_builtin_type(*t) self.the_empty_object_type =3D QAPISchemaObjectType( - 'q_empty', None, None, None, None, None, [], None) + 'q_empty', info, None, None, None, None, [], None) self._def_entity(self.the_empty_object_type) =20 qtypes =3D ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] qtype_values =3D self._make_enum_members( - [{'name': n} for n in qtypes], None) + [{'name': n} for n in qtypes], info) =20 - self._def_entity(QAPISchemaEnumType('QType', None, None, None, Non= e, + self._def_entity(QAPISchemaEnumType('QType', info, None, None, Non= e, qtype_values, 'QTYPE')) =20 def _make_features(self, features, info): diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 2b4916cdaa1b..a3a16284006b 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -71,7 +71,8 @@ def gen_enum(name: str, members: List[QAPISchemaEnumMember], prefix: Optional[str] =3D None) -> str: # append automatically generated _MAX value - enum_members =3D members + [QAPISchemaEnumMember('_MAX', None)] + enum_members =3D members + [ + QAPISchemaEnumMember('_MAX', QAPISourceInfo.builtin())] =20 ret =3D mcgen(''' =20 @@ -306,7 +307,7 @@ def _gen_type_cleanup(self, name: str) -> None: =20 def visit_enum_type(self, name: str, - info: Optional[QAPISourceInfo], + info: QAPISourceInfo, ifcond: List[str], features: List[QAPISchemaFeature], members: List[QAPISchemaEnumMember], @@ -317,7 +318,7 @@ def visit_enum_type(self, =20 def visit_array_type(self, name: str, - info: Optional[QAPISourceInfo], + info: QAPISourceInfo, ifcond: List[str], element_type: QAPISchemaType) -> None: with ifcontext(ifcond, self._genh, self._genc): @@ -327,7 +328,7 @@ def visit_array_type(self, =20 def visit_object_type(self, name: str, - info: Optional[QAPISourceInfo], + info: QAPISourceInfo, ifcond: List[str], features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 339f1521524c..3f49c307c566 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -336,7 +336,7 @@ def _begin_user_module(self, name: str) -> None: =20 def visit_enum_type(self, name: str, - info: QAPISourceInfo, + info: Optional[QAPISourceInfo], ifcond: List[str], features: List[QAPISchemaFeature], members: List[QAPISchemaEnumMember], @@ -347,7 +347,7 @@ def visit_enum_type(self, =20 def visit_array_type(self, name: str, - info: Optional[QAPISourceInfo], + info: QAPISourceInfo, ifcond: List[str], element_type: QAPISchemaType) -> None: with ifcontext(ifcond, self._genh, self._genc): @@ -356,7 +356,7 @@ def visit_array_type(self, =20 def visit_object_type(self, name: str, - info: Optional[QAPISourceInfo], + info: QAPISourceInfo, ifcond: List[str], features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990407; cv=none; d=zohomail.com; s=zohoarc; b=Hl2M+r+674JhzSjNxcIBql7h6qtuZXJZcuenKxLLseyiD0aEPOAuBUFGWrs+/6S5wj1jtNIw3wmjPtWU1j5ifBLTYo7hrDPxJz9GMg7EaENUWY1+Y5nh7sgQAQBUUpwfXpLRO8QlkUn969/Gn07ufyFNiT6MTIwRnIXBeoZPTZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990407; 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=Z/i3u4Jqw+ltJl/CYpUVaD3HcCU59abT8EbOdb4TprE=; b=LPyboQOgDecrg5pDwdbttALsFYgqonM41JvZD00gi3WR4dQ6+VzYfoMZEdO9Nnseiuw9YW05iKLfVQ0ujCc6dekcAHAiwWFURvWw+hrmN94dxDGo1Ti3IQb14WifPWWIdOm5rXsyLorOZguE84WK0+cCqbnbQvnXjl9QsuTV2zA= 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 160799040762071.00189459559715; Mon, 14 Dec 2020 16:00:07 -0800 (PST) Received: from localhost ([::1]:47862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxl7-000393-Oo for importer@patchew.org; Mon, 14 Dec 2020 19:00:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxf7-0003T3-Mr for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf5-0000uB-KW for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:53 -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-327-KO6a4wWePi2ztc_RSF24rA-1; Mon, 14 Dec 2020 18:53:49 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E53F9CDA0 for ; Mon, 14 Dec 2020 23:53:48 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09E0E70484; Mon, 14 Dec 2020 23:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990030; 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=Z/i3u4Jqw+ltJl/CYpUVaD3HcCU59abT8EbOdb4TprE=; b=JVTeWI3N3Tul9/dXqJYlDnt5yehleegQI0Uky+ja9M1JzDyawe35gavpQ0ZvJRAoKwvPrA 4diPQUDfh3CTJLsrBNq6Udm7aZzoLvFaQF+z2b/a1mNZEQQ+MU/mP9nInE/jxP6f4FzOGt Pn1PmLR+3YYHN1wBj6OwYiXNfzUHfx8= X-MC-Unique: KO6a4wWePi2ztc_RSF24rA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 09/12] qapi/gen: move write method to QAPIGenC, make fname a str Date: Mon, 14 Dec 2020 18:53:24 -0500 Message-Id: <20201214235327.1007124-10-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" QAPIGenC and QAPIGenH in particular depend on fname being defined, but we have a usage of QAPIGenCCode that isn't intended to be associated with a particular file. No problem, move the write method down to the class that actually needs it, and keep QAPIGenCCode more abstract. Signed-off-by: John Snow --- scripts/qapi/commands.py | 2 +- scripts/qapi/gen.py | 54 ++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 71744f48a353..b346676d15a0 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -258,7 +258,7 @@ def __init__(self, prefix: str): super().__init__( prefix, 'qapi-commands', ' * Schema-defined QAPI/QMP commands', None, __doc__) - self._regy =3D QAPIGenCCode(None) + self._regy =3D QAPIGenCCode() self._visited_ret_types: Dict[QAPIGenC, Set[QAPISchemaType]] =3D {} =20 def _begin_user_module(self, name: str) -> None: diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 17ae9f4af703..b2c89213d838 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -36,8 +36,7 @@ =20 =20 class QAPIGen: - def __init__(self, fname: Optional[str]): - self.fname =3D fname + def __init__(self) -> None: self._preamble =3D '' self._body =3D '' =20 @@ -58,28 +57,6 @@ def _bottom(self) -> str: # pylint: disable=3Dno-self-use return '' =20 - def write(self, output_dir: str) -> None: - # Include paths starting with ../ are used to reuse modules of the= main - # schema in specialised schemas. Don't overwrite the files that are - # already generated for the main schema. - if self.fname.startswith('../'): - return - pathname =3D os.path.join(output_dir, self.fname) - odir =3D os.path.dirname(pathname) - - if odir: - os.makedirs(odir, exist_ok=3DTrue) - - # use os.open for O_CREAT to create and read a non-existant file - fd =3D os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666) - with os.fdopen(fd, 'r+', encoding=3D'utf-8') as fp: - text =3D self.get_content() - oldtext =3D fp.read(len(text) + 1) - if text !=3D oldtext: - fp.seek(0) - fp.truncate(0) - fp.write(text) - =20 def _wrap_ifcond(ifcond: List[str], before: str, after: str) -> str: if before =3D=3D after: @@ -121,8 +98,8 @@ def build_params(arg_type: Optional[QAPISchemaObjectType= ], =20 =20 class QAPIGenCCode(QAPIGen): - def __init__(self, fname: Optional[str]): - super().__init__(fname) + def __init__(self) -> None: + super().__init__() self._start_if: Optional[Tuple[List[str], str, str]] =3D None =20 def start_if(self, ifcond: List[str]) -> None: @@ -147,11 +124,34 @@ def get_content(self) -> str: =20 class QAPIGenC(QAPIGenCCode): def __init__(self, fname: str, blurb: str, pydoc: str): - super().__init__(fname) + super().__init__() + self.fname =3D fname self._blurb =3D blurb self._copyright =3D '\n * '.join(re.findall(r'^Copyright .*', pydo= c, re.MULTILINE)) =20 + def write(self, output_dir: str) -> None: + # Include paths starting with ../ are used to reuse modules of the= main + # schema in specialised schemas. Don't overwrite the files that are + # already generated for the main schema. + if self.fname.startswith('../'): + return + pathname =3D os.path.join(output_dir, self.fname) + odir =3D os.path.dirname(pathname) + + if odir: + os.makedirs(odir, exist_ok=3DTrue) + + # use os.open for O_CREAT to create and read a non-existant file + fd =3D os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666) + with os.fdopen(fd, 'r+', encoding=3D'utf-8') as fp: + text =3D self.get_content() + oldtext =3D fp.read(len(text) + 1) + if text !=3D oldtext: + fp.seek(0) + fp.truncate(0) + fp.write(text) + def _top(self) -> str: return mcgen(''' /* AUTOMATICALLY GENERATED, DO NOT MODIFY */ --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607991768; cv=none; d=zohomail.com; s=zohoarc; b=SijjW2nhxKPXMeLwP3DfzgI5mItWSvmeXlHmPGFdAHtt8SO2HFi/cNyr+K6J0AQxLikqcm/N8/SNauBuRza3F2Ft2Mlm1vi7odP8kPvHqK11CkVih+HyTsjEgAL/5lo4dGjDjCuA22vVsqhq7Q1f0rU4IEdT0cvSLTL5QmX3MdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607991768; 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=6X64M+4r0oVZayPbOvP7v5gmUWR5OqyAXXoHWTe8pM4=; b=cBrB0dZU4WL6K+5Xr/jkM4ZenCQq/0jkxCcTeh3OvBH3kWe4zyhzGYPILqiAwIZokX5VBJPm0cnyMfkCyoPmVmcGa4eOheAVG4xJ0MHuT+7VoQTJGSh7pOwmx6tfGLbmkMeaPWTrMrTQGl7lKk3Y9pv9dd35ed1cV7DTzbTcsR0= 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 16079917687831.710040590630797; Mon, 14 Dec 2020 16:22:48 -0800 (PST) Received: from localhost ([::1]:51654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxmj-0004mg-F6 for importer@patchew.org; Mon, 14 Dec 2020 19:01:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxfC-0003WZ-CU for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf7-0000uF-GC for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:55 -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-192-I3L7KlciPu-8S-FRHrTSiw-1; Mon, 14 Dec 2020 18:53:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0AA81005504 for ; Mon, 14 Dec 2020 23:53:49 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7346813470; Mon, 14 Dec 2020 23:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990032; 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=6X64M+4r0oVZayPbOvP7v5gmUWR5OqyAXXoHWTe8pM4=; b=SeopMlVSklCia4wm/lrfKHeIEsnTrw14c2ZXvIxrTKC3/+uvHGwSZ2AS6FycAZX7Ph84PU Nkn4G43OWh2dtCywXUmFu3lOlEIbOmDjfNJMHdDjsbvrO4rpYgkrE6DLSOz6DkfJJgmzKF qG7nEU19gY8t0P70yFSxbZFrt3NPVpo= X-MC-Unique: I3L7KlciPu-8S-FRHrTSiw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 10/12] tests/qapi-schema: Add quotes to module name in test output Date: Mon, 14 Dec 2020 18:53:25 -0500 Message-Id: <20201214235327.1007124-11-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" A forthcoming patch is going to allow the empty string as a name for the builtin module, and quotes will help us see that in test output. Without this, git will be upset about trailing empty spaces in test output, so the quotes are necessary. Signed-off-by: John Snow --- tests/qapi-schema/comments.out | 4 ++-- tests/qapi-schema/doc-good.out | 4 ++-- tests/qapi-schema/empty.out | 4 ++-- tests/qapi-schema/event-case.out | 4 ++-- tests/qapi-schema/include-repetition.out | 8 ++++---- tests/qapi-schema/include-simple.out | 6 +++--- tests/qapi-schema/indented-expr.out | 4 ++-- tests/qapi-schema/qapi-schema-test.out | 8 ++++---- tests/qapi-schema/test-qapi.py | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index 273f0f54e16c..08aba8354e2a 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,7 +9,7 @@ enum QType member qdict member qlist member qbool -module comments.json +module "comments.json" enum Status member good member bad diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 419284dae29b..83a3d9bd69b5 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,7 +9,7 @@ enum QType member qdict member qlist member qbool -module doc-good.json +module "doc-good.json" enum Enum member one if ['defined(IFONE)'] diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 69666c39ad2d..0dac23c80c15 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,4 +9,4 @@ enum QType member qdict member qlist member qbool -module empty.json +module "empty.json" diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-cas= e.out index 42ae519656dc..ace511ba5a96 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,6 +9,6 @@ enum QType member qdict member qlist member qbool -module event-case.json +module "event-case.json" event oops None boxed=3DFalse diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 0b654ddebb6a..f7ab4987943c 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,15 +9,15 @@ enum QType member qdict member qlist member qbool -module include-repetition.json +module "include-repetition.json" include comments.json include include-repetition-sub.json include comments.json -module comments.json +module "comments.json" enum Status member good member bad member ugly -module include-repetition-sub.json +module "include-repetition-sub.json" include comments.json include comments.json diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 061f81e50904..81bdeb887b66 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,9 +9,9 @@ enum QType member qdict member qlist member qbool -module include-simple.json +module "include-simple.json" include include-simple-sub.json -module include-simple-sub.json +module "include-simple-sub.json" enum Status member good member bad diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 04356775cd16..361a58185e67 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,7 +9,7 @@ enum QType member qdict member qlist member qbool -module indented-expr.json +module "indented-expr.json" command eins None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command zwei None -> None diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 8868ca0dca9e..4f5ab9fd596c 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,4 +1,4 @@ -module None +module "None" object q_empty enum QType prefix QTYPE @@ -9,7 +9,7 @@ enum QType member qdict member qlist member qbool -module qapi-schema-test.json +module "qapi-schema-test.json" object TestStruct member integer: int optional=3DFalse member boolean: bool optional=3DFalse @@ -443,11 +443,11 @@ command test-command-cond-features3 None -> None event TEST-EVENT-FEATURES1 None boxed=3DFalse feature deprecated -module include/sub-module.json +module "include/sub-module.json" include sub-sub-module.json object SecondArrayRef member s: StatusList optional=3DFalse -module sub-sub-module.json +module "sub-sub-module.json" array StatusList Status enum Status member good diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index e8db9d09d914..4adf0b3c1857 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -25,7 +25,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): =20 def visit_module(self, name): - print('module %s' % name) + print('module "%s"' % name) =20 def visit_include(self, name, info): print('include %s' % name) --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607991684; cv=none; d=zohomail.com; s=zohoarc; b=NsjUXM6jAETk0JZjGGdPBClBrR4+xEVFIqnboFD9dXqkHqqvKintTTczX+bAo+xFiRBa5kO/QJOjsI8qNh8W1y7QS4aLFh6YVAs11cG2VwzJht4lsQIf1K36NUcjr9NxV65Brf2VGqkgfeboB/dhgmjkJLxfFJ5tCsowHmZMrOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607991684; 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=g22mw6VCBBku3TozxhC+MNGMi192VGwuNN8d7ZsT+tQ=; b=PoTaYhjrYy1u5GYyHfv3Y9BR6h+NTvrzGNrT8Tv6S9hLo3KvP/nXn1yaQFbxfK7lvQvns6J4wN9pnR3g8RwICLTMezX10HgRhQLm0X0NGVRSQYPLX/YbR8lnEKFaEWWLEMwFekNWqiPyfJEbvqkWx/oQwQKZRjFQH1gVqLWnS0s= 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 1607991684693408.9472246388174; Mon, 14 Dec 2020 16:21:24 -0800 (PST) Received: from localhost ([::1]:56144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxnz-0006cM-8r for importer@patchew.org; Mon, 14 Dec 2020 19:03:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxfD-0003Xk-Ji for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:54:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxf8-0000uV-By for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:53:59 -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-485-JsO2DfalPlunt_lLvCXG0g-1; Mon, 14 Dec 2020 18:53:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E074C107ACE3 for ; Mon, 14 Dec 2020 23:53:50 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00CF518F0A; Mon, 14 Dec 2020 23:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990033; 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=g22mw6VCBBku3TozxhC+MNGMi192VGwuNN8d7ZsT+tQ=; b=bYOy7w9y5OgT8btRe91RCHVFQOLHVWAuXtzXs+fAkR9FIBX1tmcyocj6y/B5vQih6fNbkp V3TRhFzlUP1xggihHrVxIwuEabBZKMa8ceYP8wy3VH6PxrREkmoEJkO7bmWUluXlWrCcLZ G1/fNz3qqUEhttesBrkC3dXytv3q1GY= X-MC-Unique: JsO2DfalPlunt_lLvCXG0g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 11/12] qapi/schema: Name the builtin module "" instead of None Date: Mon, 14 Dec 2020 18:53:26 -0500 Message-Id: <20201214235327.1007124-12-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" Instead of using None as the built-in module filename, use an empty string instead. This allows us to clarify the type of various interfaces dealing with module names as always taking a string, which saves us from having to use Optional[str] everywhere. Signed-off-by: John Snow --- scripts/qapi/gen.py | 6 +++--- scripts/qapi/schema.py | 12 ++++++------ scripts/qapi/types.py | 2 +- scripts/qapi/visit.py | 2 +- tests/qapi-schema/comments.out | 2 +- tests/qapi-schema/doc-good.out | 2 +- tests/qapi-schema/empty.out | 2 +- tests/qapi-schema/event-case.out | 2 +- tests/qapi-schema/include-repetition.out | 2 +- tests/qapi-schema/include-simple.out | 2 +- tests/qapi-schema/indented-expr.out | 2 +- tests/qapi-schema/qapi-schema-test.out | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index b2c89213d838..a577a4a7f002 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -309,14 +309,14 @@ def write(self, output_dir: str, opt_builtins: bool = =3D False) -> None: genc.write(output_dir) genh.write(output_dir) =20 - def _begin_system_module(self, name: None) -> None: + def _begin_system_module(self, name: str) -> None: pass =20 def _begin_user_module(self, name: str) -> None: pass =20 - def visit_module(self, name: Optional[str]) -> None: - if name is None: + def visit_module(self, name: str) -> None: + if not name: if self._builtin_blurb: self._add_system_module('builtin', self._builtin_blurb) self._begin_system_module(name) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index d5f19732b516..8d8b8758f65e 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -69,7 +69,7 @@ def check_doc(self): =20 def _set_module(self, schema, info): assert self._checked - self._module =3D schema.module_by_fname(info and info.fname) + self._module =3D schema.module_by_fname(info.fname) self._module.add_entity(self) =20 def set_module(self, schema): @@ -826,7 +826,7 @@ def __init__(self, fname): self._entity_dict =3D {} self._module_dict =3D OrderedDict() self._schema_dir =3D os.path.dirname(fname) - self._make_module(None) # built-ins + self._make_module(QAPISourceInfo.builtin().fname) # built-ins self._make_module(fname) self._predefining =3D True self._def_predefineds() @@ -871,10 +871,10 @@ def resolve_type(self, name, info, what): info, "%s uses unknown type '%s'" % (what, name)) return typ =20 - def _module_name(self, fname): - if not fname: - return None - return os.path.relpath(fname, self._schema_dir) + def _module_name(self, fname: str) -> str: + if fname: + return os.path.relpath(fname, self._schema_dir) + return fname =20 def _make_module(self, fname): name =3D self._module_name(fname) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index a3a16284006b..12eeea3aaffe 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -272,7 +272,7 @@ def __init__(self, prefix: str): prefix, 'qapi-types', ' * Schema-defined QAPI types', ' * Built-in QAPI types', __doc__) =20 - def _begin_system_module(self, name: None) -> None: + def _begin_system_module(self, name: str) -> None: self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 3f49c307c566..76e34ee7f02e 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -305,7 +305,7 @@ def __init__(self, prefix: str): prefix, 'qapi-visit', ' * Schema-defined QAPI visitors', ' * Built-in QAPI visitors', __doc__) =20 - def _begin_system_module(self, name: None) -> None: + def _begin_system_module(self, name: str) -> None: self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/error.h" diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index 08aba8354e2a..02000c06e5e0 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 83a3d9bd69b5..494533d74793 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 0dac23c80c15..059caa4e1d2a 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-cas= e.out index ace511ba5a96..4d9d2b519f4b 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index f7ab4987943c..31d64631b665 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 81bdeb887b66..1b35b3295713 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 361a58185e67..aed689e7bd67 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 4f5ab9fd596c..4a899ba63ecb 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,4 +1,4 @@ -module "None" +module "" object q_empty enum QType prefix QTYPE --=20 2.26.2 From nobody Tue Nov 18 05:48:44 2025 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=1607990375; cv=none; d=zohomail.com; s=zohoarc; b=T2gDJ1+dVa0Oi31wnYtXmtqmg5JkADZPLQDNiH5ayD153kqgVUle8+DgqIMc1e/pBvABBtRW6WuQGtjjJld0Fuh/WKVK3xgncJzRl0PWzXr8izZNeQplFInfTtC4gfard18qCpVGF8OzXci4jtUpkzMtCalCw7dSjrHlWoJZ1T4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607990375; 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=srrr8BplPYO0fdEbz8tXky8bnnFfwdoVvuEoFcFNi8E=; b=Uy2S8ueNCAIzpQhuzGIzhBVdNwokxAcJBLeLMIlO9eOwdxgzxHKRv1RHFIskWtWjB0bdIr4RqOXBfs1J7FGTTVZDufjhL7XLUQQ6Vlm65KzeqV/kZY+J+PNKF2LShMgxMV3p83aK1FCdRIFk6Ka4C3PGsv9UgiYrYvZKeQt0cms= 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 1607990375895131.91493946224568; Mon, 14 Dec 2020 15:59:35 -0800 (PST) Received: from localhost ([::1]:45652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koxkc-0002FP-SC for importer@patchew.org; Mon, 14 Dec 2020 18:59:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koxfH-0003bL-BY for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:54:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1koxfD-0000uv-FX for qemu-devel@nongnu.org; Mon, 14 Dec 2020 18:54:01 -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-557-OCzNKgBcPiKYJTPt-mTX0Q-1; Mon, 14 Dec 2020 18:53:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1365D107ACE3 for ; Mon, 14 Dec 2020 23:53:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-117.rdu2.redhat.com [10.10.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C85713470; Mon, 14 Dec 2020 23:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607990037; 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=srrr8BplPYO0fdEbz8tXky8bnnFfwdoVvuEoFcFNi8E=; b=LrfFWj2lW2b5j6skBRwkhTlGC88kS04HR1tESGqvDcZt0JD5zzRKfdC1jLtjflwBPMg6Q3 8amXQAywTEaGP+mwGOvThNP6cu+oKCKIoJ6qFsCiQMfDHGuxWpUuYCmLJ3UQTszzkqXiud +lhdLPmz2+MOgiC3gDv+pRSj7AXjT4c= X-MC-Unique: OCzNKgBcPiKYJTPt-mTX0Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 12/12] qapi: enable strict-optional checks Date: Mon, 14 Dec 2020 18:53:27 -0500 Message-Id: <20201214235327.1007124-13-jsnow@redhat.com> In-Reply-To: <20201214235327.1007124-1-jsnow@redhat.com> References: <20201214235327.1007124-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , John Snow , Eduardo Habkost , Markus Armbruster 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" In the modules that we are checking so far, we can be stricter about the difference between Optional[T] and T types. Enable that check. Enabling it now will assist review on further typing and cleanup work. Signed-off-by: John Snow --- scripts/qapi/mypy.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 74fc6c82153e..04bd5db5278d 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -1,6 +1,5 @@ [mypy] strict =3D True -strict_optional =3D False disallow_untyped_calls =3D False python_version =3D 3.6 =20 --=20 2.26.2