From nobody Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608170857; cv=none; d=zohomail.com; s=zohoarc; b=Yd9frUC6taHJ+QFGUhXTxlDgTC/80T29QJKZWXip8LlKtS/nSXSo/YiE0Iswt2LbF2iI2ktt4/GsUfhu1ZAiRnMSlppkPN0Qtjez6rmf31rgFcAK4yZtn+DZi9+SHEDuZstWv12uKn7bmemTtHn2mzHUeO4n2EJSKO3CWIYTWuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608170857; 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=FaXZkgMJipKZxS7oDXugHZOYAQgqxW8CYJ0DO8crVBI=; b=mpXeIPuoD7WSSb42hHudYD3szWXdzEyRSnVQtSdpBXqVa9VGs+yMzJPETmdrpewFEBxV1g0VDSODwgsaASfVlu+KZ0e4soLxrUzGcU5eA9oMIZqiOLsUI9hA7wPJ8B5SBADIbHiW3MNYt8Kaon+auRIhivXPz/xyBjfawShCxNY= 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 1608170857907675.8236718248645; Wed, 16 Dec 2020 18:07:37 -0800 (PST) Received: from localhost ([::1]:60486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpihc-0001mG-UG for importer@patchew.org; Wed, 16 Dec 2020 21:07:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiZv-0002Bf-Ae for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpiZt-0007AG-3n for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:39 -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-6ZaUGKMvNUybOd4sgdTYJA-1; Wed, 16 Dec 2020 20:59:34 -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 3E26F10054FF; Thu, 17 Dec 2020 01:59:33 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 732D41E5; Thu, 17 Dec 2020 01:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170375; 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=FaXZkgMJipKZxS7oDXugHZOYAQgqxW8CYJ0DO8crVBI=; b=LbkpUv+ofDRH9lhgjGGuCWtr6Cpa2UZ67VurXu/CDHBa9ZbUSIp8tUJw82o3L089HlgFOR lB/W2pwQqwoHe9bXNJ8nxL/2yCGwpVN9o8CPM/emBic6gK0oTTK+HvZz55qwzE7WwGuQXH c51VtNq0CdA9jiTX1FVliRwFDnEodPs= X-MC-Unique: 6ZaUGKMvNUybOd4sgdTYJA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 01/12] qapi/commands: assert arg_type is not None Date: Wed, 16 Dec 2020 20:59:16 -0500 Message-Id: <20201217015927.197287-2-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 50978090b44..71744f48a35 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608170860; cv=none; d=zohomail.com; s=zohoarc; b=MwIiCDkxrPFlbi/3IUTTwJuKC9JMFf4FjXYslHLUhh+myDHYyDrPPbfdiEjHdWvt+L3wI2qxioZpgjL76S9+H/WisMgFf2/z+wraGewbrQHmsfoIQ9eYNmOVELQTZL0+T4zqfX0OBVY+CGL5k2ylk2ZRDR/nC0mVsgJYBdgoxW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608170860; 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=GG76/Nd6SkwPrzWo+WM1kldD4e/+xCkc9xSouGuiJ+w=; b=k4Yk2Z4MauEzWL/4KShMdwyVESn9yUaZZ1zhYMIjs72rU6HOU3Vv5v5TlxCGqJhFYl1wF0OrJ+OpbG4p5iwxki7VwkThTnpxKpb4COkfgY5jI+bdVfont0tlQzrR6lbPzX3f65idf9WGcshLJEHe8Cuuy0lhK+ws7SrLKdEAXt0= 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 160817086039098.31386953798324; Wed, 16 Dec 2020 18:07:40 -0800 (PST) Received: from localhost ([::1]:60630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpihf-0001pq-Cs for importer@patchew.org; Wed, 16 Dec 2020 21:07:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiZy-0002CU-8I for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56421) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpiZt-0007AM-Kn for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:42 -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-591-Oh96MSFuOLexEYxirUD93A-1; Wed, 16 Dec 2020 20:59:35 -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 241A1802B40; Thu, 17 Dec 2020 01:59:34 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6507A2BFC7; Thu, 17 Dec 2020 01:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170376; 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=GG76/Nd6SkwPrzWo+WM1kldD4e/+xCkc9xSouGuiJ+w=; b=G7pW7UW1kZY7h/wNtRfLcg62xqJycDR0tPqmeRokN1n74JPG0KFqapd/+KJTucsLCgjhfx 2MSMklLXohOyZNyq56tM7Qm4PGLrvo+9pOEc0CTaxqxv6kuZNDw99p6AlSN3Inq/9H0S+J Zg8pxT3cVDSt7NcWhxZ2Re/T6j8mg+I= X-MC-Unique: Oh96MSFuOLexEYxirUD93A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 02/12] qapi/events: fix visit_event typing Date: Wed, 16 Dec 2020 20:59:17 -0500 Message-Id: <20201217015927.197287-3-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 599f3d1f564..9851653b9d1 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171015; cv=none; d=zohomail.com; s=zohoarc; b=Gekb/kLlL3ws39WBOGpFrZ5NMpvJLIj260VYvMPJ4tfzykTr27+0fpW4JvXlXwmFF0y2XwReS3jFA4EZQabcpdVTopFdfAMno70yjhuG+QhN3G41RdTp4PgHqv3MTty0suckEG1BGiSFMVkr4uowfL6hsbhE+CoWV60XsVufGsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171015; 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=UWlRvp04PP8y4awj0DstdIy0uVKYQOYQ4hnvF2zD2T8=; b=PmZxi4tEaT3j4gEigunQtuQIbljL5TUddQXumCckvUfiCBo3X8vANd0VE2Z7OwTWRR5/JWuYtQ9/Odbbu8DqafC6NR+ZACJfTDvuHzO1jMv2TAoqTHV4Hoty2BW642Okd4n4cI3GOZlH2JEH2GDeLM4OP018n0sbBkVzb5x16Jo= 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 16081710157891021.0874581931603; Wed, 16 Dec 2020 18:10:15 -0800 (PST) Received: from localhost ([::1]:39044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpikA-0004Yo-Ld for importer@patchew.org; Wed, 16 Dec 2020 21:10:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpia0-0002DC-Ql for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpiZu-0007AV-Vm for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:42 -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-456-uqbZdNQWNQK16IHk05rv_g-1; Wed, 16 Dec 2020 20:59:36 -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 2E6AA10054FF; Thu, 17 Dec 2020 01:59:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4708B1E5; Thu, 17 Dec 2020 01:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170377; 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=UWlRvp04PP8y4awj0DstdIy0uVKYQOYQ4hnvF2zD2T8=; b=OvxDAoDgG+4mvHFK1dqkgbXjdLkVRSSwga76UmqI7oXbjWQ1rZvZ0VAHed/tN70lT1VrIG 52W/wEPQDr7wJhAxNH26w0Y/gf5o++y+uQR+8s0K/2ZpQaLMtAXOFzEbpC8uBCKdZ1XFc1 Q5LJSPUkD68hYEYiag1CTuI+2tu0FTs= X-MC-Unique: uqbZdNQWNQK16IHk05rv_g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 03/12] qapi/main: handle theoretical None-return from re.match() Date: Wed, 16 Dec 2020 20:59:18 -0500 Message-Id: <20201217015927.197287-4-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index 42517210b80..703e7ed1ed5 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -23,6 +23,8 @@ =20 def invalid_prefix_char(prefix: str) -> Optional[str]: match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix) + # match cannot be None, but mypy cannot infer that. + assert match is not None if match.end() !=3D len(prefix): return prefix[match.end()] return None --=20 2.26.2 From nobody Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608170955; cv=none; d=zohomail.com; s=zohoarc; b=Rm8ZAe/w+ee53mLm8CEClqYxgJI0vjpSh8BDLaKq6G6vGAyC0vUr4QE4yCcU/L4iw/1j8bJbMlS5PPr+3GgvdahOwr5jFn5QWjzqg7Q5iZ9/6EC/pLtyse920dCIpIxPwWyfFOwCTqgyUiL7dxBEH/bPCbJl5P8E6Xs9IyW9o9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608170955; 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=sm6q2MBGr7KgFIW1CPrq3LBncDHdcO3QbH/R75aARKU=; b=M7WqiBNuy/toQEB3urKwS99Ar+Sdq7V2qDrFvsG1EEdr0tfZK4PMXoFWFrqJL4vnzTp2kHtvnP3KlzOrZ2I+rn/90eZ9F4mbaViogwcf5XbnCw/9abrPdvP+UioGoozOgXktO/ZdIbcZoycy3uHADiQ3OQyat+YMQvElLEsiMQ8= 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 1608170955276698.3602719522622; Wed, 16 Dec 2020 18:09:15 -0800 (PST) Received: from localhost ([::1]:36800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpijC-0003eB-0o for importer@patchew.org; Wed, 16 Dec 2020 21:09:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpia0-0002DD-TX for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpiZv-0007Ac-HG for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:44 -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-209-1f9GnetKNjeD2v-seQSPVQ-1; Wed, 16 Dec 2020 20:59: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 471BA107ACE6; Thu, 17 Dec 2020 01:59:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5272F1E5; Thu, 17 Dec 2020 01:59:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170378; 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=sm6q2MBGr7KgFIW1CPrq3LBncDHdcO3QbH/R75aARKU=; b=NWl8Th/VtAYl+G/Rv1n7fk8BiL+SH+IkIxuiiDa/dlsYCbe4J1cQSjLZwpHhFWbv/Kq3fa o9t8vomy5jW9LAUruA0g5WnuL8/Wk+LlVjYizCJnsA9X+soZYwyHpXUf1p/tUb7fx2+bSm 0g23oPzq+m7UcplutknMUve9MxgZ4HM= X-MC-Unique: 1f9GnetKNjeD2v-seQSPVQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 04/12] qapi/gen: assert that _start_if is not None in _wrap_ifcond Date: Wed, 16 Dec 2020 20:59:19 -0500 Message-Id: <20201217015927.197287-5-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 b40f18eee3c..a6dc991b1d0 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171210; cv=none; d=zohomail.com; s=zohoarc; b=PpnpIHchiAskqTkMHDjW6qzWcljNjdTNwnXkDWLbgyviJZS1mrCCdf2A7NOl8YhBVH06LFYM4NkiXtB0JPtCGwXLmhZwsn+n8QGUgyjX0CJxj8e1LR+4xpDlx2vcs5t6OuchE7aRxWX/+7l09i+P/PNUOx3ddAStBl4VTjWl2oA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171210; 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=WpMQKsyexewSO4yo0ep0Z8BN6zN0/7QMY2SVcGZVxKA=; b=gg626Ddy5+3VY80hQucrLYY+KrfSNQidDUI16XboMhZ/FTnRIIpHLPzoFRgJZ8Jk5Pxpu88miGwpmS+W5zi/YjzMx07+jMIJ358ZxOQlustisWcQgNM8nLE46lvFaxfCXEbAttt6MiD+tP1ibLFJvtGJT6/fm/7Q9S0AvSIZWys= 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 1608171210063939.0908491231856; Wed, 16 Dec 2020 18:13:30 -0800 (PST) Received: from localhost ([::1]:45916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpinJ-0007QF-2s for importer@patchew.org; Wed, 16 Dec 2020 21:13:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpia3-0002Dw-LU for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpiZy-0007Ax-Np for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59: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-213-nT7iNqHNMPW7eCSJaamyTA-1; Wed, 16 Dec 2020 20:59:38 -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 061BBE758; Thu, 17 Dec 2020 01:59:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4587F70481; Thu, 17 Dec 2020 01:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170381; 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=WpMQKsyexewSO4yo0ep0Z8BN6zN0/7QMY2SVcGZVxKA=; b=AYpnGfiaL5y1UTIZep4153ks2jQVo2wz2uXtJHzW9dLWlvNjOl6N7Pa0lGHwlmvQo5bvhz q/tayh+hYE8pBhAW+xgDL8e8yJxwRdnWICwjyqLNwfVPmMg8dWyT78QkkGhjvO6Dx2IkmA F2f9kBPutFaLqqfAynNKWAJEeNspPCM= X-MC-Unique: nT7iNqHNMPW7eCSJaamyTA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 05/12] qapi/gen: use './builtin' for the built-in module name Date: Wed, 16 Dec 2020 20:59:20 -0500 Message-Id: <20201217015927.197287-6-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index a6dc991b1d0..476d0adac4e 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,15 @@ 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) + assert name.startswith('./') + 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 +290,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('./' + name, blurb) =20 def write(self, output_dir: str, opt_builtins: bool =3D False) -> None: for name in self._module: @@ -310,7 +310,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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171504; cv=none; d=zohomail.com; s=zohoarc; b=OwNvRTpR16gUaeTbWgIqicSGLrgjq+95NyxoQnnnWkBIlVJiiDcZ14ivOijOowgTT/TQYbNMEVlMdGj5i8W6qPj89NIu8HM+9BLayRhu2dbH28aUHhUHVYuoytgPVKqshytecma+Sauj+fz3Zuf12ZZD36D4HWVUR6Jtk9ieN0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171504; 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=RPyhPA0LQsrutFNs3gyJCJgOExNTaIdt0Mdj53/n+WU=; b=Bn6gq5GnWoZHRCnNocZK2Vk6rfzJ7ahk3nsGcnRP9kusNmRclZBXmLNLO1cbrS5Op6RXIU8lRkvpnwR9RfRX4+BIdRvXKQ5PH6mJjSUwTalPKbYmx8Iykz9z0EJOF19vAFQg4HSM3dKXxyVXav3m2HLPoPlQ34FvMbIbYgDIiWE= 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 1608171503997679.728089716841; Wed, 16 Dec 2020 18:18:23 -0800 (PST) Received: from localhost ([::1]:55498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpis2-0002yr-Om for importer@patchew.org; Wed, 16 Dec 2020 21:18:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpia7-0002EV-9c for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpiZx-0007Ar-V1 for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:51 -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-256-Jx4Vl1LSOT2kHtTVjWQq6w-1; Wed, 16 Dec 2020 20:59:38 -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 E8FFC59; Thu, 17 Dec 2020 01:59:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F7751E5; Thu, 17 Dec 2020 01:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170380; 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=RPyhPA0LQsrutFNs3gyJCJgOExNTaIdt0Mdj53/n+WU=; b=K0w0VsFMn2HQ8xfbLKoXbgpV/3qBcKwNHIvfPWfDKuNml9dlj6Vnb6gCu77mabzFaclLG7 E8eu2A4Y8HrKlzfbmT/jYJ9vuTyOPEMHDIjLB/NpoJRIEVujOQUhehnzyh1aE6q/hBjpdN Wd90kV/tlDmoM8gQXq9Ef/IxqjuQdyc= X-MC-Unique: Jx4Vl1LSOT2kHtTVjWQq6w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 06/12] qapi/source: Add builtin null-object sentinel Date: Wed, 16 Dec 2020 20:59:21 -0500 Message-Id: <20201217015927.197287-7-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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" remains 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 d7a79a9b8ae..a049b73b57b 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 an instance corresponding to a built-in definition. + """ + return cls('', -1, None) + + def __bool__(self) -> bool: + # "if info" is false if @info corresponds to a built-in definition. + 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171205; cv=none; d=zohomail.com; s=zohoarc; b=AnnfWIiTeeWDd+TLQjwVN5OJAPiyQjPcJgnCssrO5xpgNGwqLpB+oLj3Tssz5FjQpgPBNHiz2yAEjGLMDxq3S48cHmd8Yuo+Yf7Qw+xASiyKkfRy9sHFMfeyFowaZDvHNubqXvVpp1o7bRGAa3XAhTaUSZ5DEDf6FcnFvuMdNE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171205; 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=MZg6kl92R9fCmKWRuiJH0usUFG83EOYNQGMwSnpfJSo=; b=R2XieCv2mU0yr/FXGJ8o1EuHXCEHUuxz+19QueU8alzhC1VtUjZe72TuQeZLn6SdQrkcswtBu60vKyu27oOHb0xiLRJOXSqRHKAvzZRqJeZPjqJU+SXnVdCFUpneM+3zYAZkMahRh/Zk+Rx1PdzEDu5frdorhy1kdhj36m9FUMk= 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 16081712050261016.2580254799868; Wed, 16 Dec 2020 18:13:25 -0800 (PST) Received: from localhost ([::1]:45810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpinD-0007Ni-SD for importer@patchew.org; Wed, 16 Dec 2020 21:13:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiaC-0002GB-B2 for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpia2-0007BG-Aa for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:56 -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-51-wJIOl9EcNpeaeNoQGFAp0w-1; Wed, 16 Dec 2020 20:59:40 -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 72D83E758; Thu, 17 Dec 2020 01:59:39 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A9AB1E5; Thu, 17 Dec 2020 01:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170384; 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=MZg6kl92R9fCmKWRuiJH0usUFG83EOYNQGMwSnpfJSo=; b=Tr+59vgCq3SKNWFPoGNqRvXSeL1u7G1ibPjvyeFCkvuOWmg7DY0Q6lFYpgiTlAX2G5XlCV IZEAlZndMRdvLBkuBCcQvFkkw1ocGWOl5XvIoliAHX6u2YmK5x1eWcFIjZ137XDJq+Vild 54VxYz/IYmvH9jlANjeSW+vi3vcQbzg= X-MC-Unique: wJIOl9EcNpeaeNoQGFAp0w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 07/12] qapi/schema: make QAPISourceInfo mandatory Date: Wed, 16 Dec 2020 20:59:22 -0500 Message-Id: <20201217015927.197287-8-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- The event_enum_members change might become irrelevant after a forthcoming (?) patch by Markus, but didn't have it in-hand at time of publishing. Signed-off-by: John Snow --- scripts/qapi/events.py | 2 +- scripts/qapi/schema.py | 25 ++++++++++++++----------- scripts/qapi/types.py | 9 +++++---- scripts/qapi/visit.py | 6 +++--- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 9851653b9d1..9ba4f109028 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 720449feee4..0449771dfe5 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 built-in types (and their arrays), info is a + # special object that evaluates to False. For implicitly defined + # entities, 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 [] @@ -68,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 if info else No= ne) self._module.add_entity(self) =20 def set_module(self, schema): @@ -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') @@ -897,7 +898,7 @@ 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): for t in [('str', 'string', 'char' + POINTER_SUFFIX), @@ -917,16 +918,18 @@ 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', QAPISourceInfo.builtin(), + 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], QAPISourceInfo.builtin()) =20 - self._def_entity(QAPISchemaEnumType('QType', None, None, None, Non= e, - qtype_values, 'QTYPE')) + self._def_entity(QAPISchemaEnumType( + 'QType', QAPISourceInfo.builtin(), None, + None, None, qtype_values, 'QTYPE')) =20 def _make_features(self, features, info): if features is None: diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 2b4916cdaa1..a3a16284006 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 339f1521524..3f49c307c56 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171162; cv=none; d=zohomail.com; s=zohoarc; b=DoLKoUPywAeBGEZZNDR6JcjyO002izRwFjWVyllLF4QN+ieK3gyHjG4EOgSlnt0x/CqD8WxO3RePXpOqAP9QpmLqJrN6ea6vvyLGpNAvbUJvO0mVXvvqB9mpUj0Gh7Z/zRTONwGtXVphWd0m3jpQpxY5HA1vwaAIMaCU8R5bbcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171162; 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=Y4LO+NOoequEnTMn7BmCl3y7hnHeMLTh/G6wUPIRTf8=; b=lfCs4Lw5AfZIndsgLHp9bwH5HeavscZFNttuHJ/0VAFPr1RPgKT6EHNbxy9G7QOpmmvzO/ggCzgeVGvQBbL6+zHMEIIRaxAfcEp9CNQknuYSOp2aB8mi5yaXQNlf29frSgNxD1N0CcaQPiXP8tnNDiWc1WS0EHmiUg5lUTMQDj8= 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 1608171162092242.31076250601882; Wed, 16 Dec 2020 18:12:42 -0800 (PST) Received: from localhost ([::1]:43866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpimW-0006ab-Qq for importer@patchew.org; Wed, 16 Dec 2020 21:12:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiaC-0002GA-9y for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpia2-0007BU-Am for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59: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-55-DifYcYTdMBW6OC0JN7MROw-1; Wed, 16 Dec 2020 20:59:41 -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 68505180A093; Thu, 17 Dec 2020 01:59:40 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 922801E5; Thu, 17 Dec 2020 01:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170385; 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=Y4LO+NOoequEnTMn7BmCl3y7hnHeMLTh/G6wUPIRTf8=; b=W/KgsrF7KjoFHZOkjwnXZ2niGIGb38cUyS9hDCbXhfW1h7N/gUCNf0t/aAe/EKhZ+y4BS7 PXPmkYxE7S5qVlal8dPid50aLdDbai7A1CkjkpsUgMf1WXrKykG0+Za5ZoonPF2nYXridG doxnxKsTG8ZXt7UGNctxombGHpwJ4dM= X-MC-Unique: DifYcYTdMBW6OC0JN7MROw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 08/12] qapi/gen: write _genc/_genh access shims Date: Wed, 16 Dec 2020 20:59:23 -0500 Message-Id: <20201217015927.197287-9-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 476d0adac4e..12ea98fb61e 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('./') @@ -282,7 +291,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) @@ -315,8 +324,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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171571; cv=none; d=zohomail.com; s=zohoarc; b=iw5xWXQ9knFqG/0KXxDJ0/podYR2zviNmYENN9mVNLnc5fmU8NIj7ltfzsK/SLihdIjBfFInoEOKx1lzyJnK1ClEfPZKaYMp0Nrr4+ioFqu3Ay0s9xfXKcjCeHToHNd4D55hGxSq56DbGuJ9qd+YRKfZkHc3BZMdiPo560h4HyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171571; 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=f8nKPihbKZ56Dc478W9rWwckr42c8RsR38TC3NpzLws=; b=A5EgYBFXYulSgUNIZT4MG9TggjPS1+rSjUUJ70QZUKNdItodiFzEWh65voWKwHFZp10jueVKVWRxF+l0VLVQoLdDhoV7uX9RFPSHnbmuB1yJ99ac+hYDKcut3hujy6pt9wv9/NYKnyMJLM/CzALc81UJdnEQagbAOFM+ak64al0= 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 1608171571771817.8606237418692; Wed, 16 Dec 2020 18:19:31 -0800 (PST) Received: from localhost ([::1]:57668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpit8-0003sn-N1 for importer@patchew.org; Wed, 16 Dec 2020 21:19:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiaC-0002GS-RX for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52975) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpia3-0007Ba-D1 for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:56 -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-79-fLsiGXTKPBGMqUBU1i-MGA-1; Wed, 16 Dec 2020 20:59: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 57421801AC1; Thu, 17 Dec 2020 01:59:41 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C4CC1E5; Thu, 17 Dec 2020 01:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170386; 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=f8nKPihbKZ56Dc478W9rWwckr42c8RsR38TC3NpzLws=; b=Yyukgqxet2eTx9x4UQZ+fKob/FuCqt0Gyy4T9kJz2ZjEKVbOzhNyEEh7qrFB6yV2mUpk7P Wa6Ua9uDBe6yQcL0izx9KRg/S7sDgOn5CFJoLvx9IclUpeAOScYRimowV4ySSUUivm2QQ2 1AMKsldW1O/p3VpMS/YFiE0N7K/5WYM= X-MC-Unique: fLsiGXTKPBGMqUBU1i-MGA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 09/12] qapi/gen: move write method to QAPIGenC, make fname a str Date: Wed, 16 Dec 2020 20:59:24 -0500 Message-Id: <20201217015927.197287-10-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 --- Possibly un-needed in concert with a forthcoming patch by Markus, but I didn't have it in my hands at time of publishing. 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 71744f48a35..b346676d15a 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 12ea98fb61e..2dd99635e74 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171371; cv=none; d=zohomail.com; s=zohoarc; b=j5rDAHikAOLpJ/SQM0xm2IDEYthM8Tgc/wDHeZkgmFZLKPFd80NHJ6NRq1bRbsOXnB4ovn2lco6cD/H2jXPerGRpl3Gz6vVh7y2F2ssPkc0AdtBPHCiNiPBxPdwZP6iB3AiZtmoqIIRf186YK7VJuyWAVRvguQA6utx9ESEwYTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171371; 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=nQ3bg5bXX9ztJg0RPsfYoKkxqqZZn1Ehie9AJ9A8/M4=; b=Ef0pCIN9fRjj5E6ugO+gvIp9y7W3ws8OZWcYVeMAtgw+2vdDKwRKvfualkf/AvDurB2uLEA6m2Bz+f3Mpb326zhJXhyRoqilBshOL2pNFRp7wKm07le/n4DLdah8zAbqo7kdRVMz8VH8DuAN+NNJSZuV9f0YQIRLcFByKbhwJg8= 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 1608171371938977.797162448382; Wed, 16 Dec 2020 18:16:11 -0800 (PST) Received: from localhost ([::1]:51466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpipu-0001Lb-S4 for importer@patchew.org; Wed, 16 Dec 2020 21:16:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpia9-0002Ei-4s for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37887) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpia2-0007BQ-AP for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:52 -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-474-4FxZT4dsNmmU1NwbnudNug-1; Wed, 16 Dec 2020 20:59: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 3ED65800D55; Thu, 17 Dec 2020 01:59:42 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A0071E5; Thu, 17 Dec 2020 01:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170384; 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=nQ3bg5bXX9ztJg0RPsfYoKkxqqZZn1Ehie9AJ9A8/M4=; b=QiYdQFCgvG/x552bq8m+qwvmaBg0rFn4VdiAvBV1YguBnnhvSSAXqGW0IcePqGNz6fLv3z 3JmHVXBulJRvQFlLg/s1URDkqORq6ZeENKuCVDFY0AFm5ha1oQcMic/xrQoCZ09+Y5nT7P 4f9WJZ0gb4Chhy0DvqvzBUhCUB7V27s= X-MC-Unique: 4FxZT4dsNmmU1NwbnudNug-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 10/12] tests/qapi-schema: Add quotes to module name in test output Date: Wed, 16 Dec 2020 20:59:25 -0500 Message-Id: <20201217015927.197287-11-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 273f0f54e16..08aba8354e2 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 419284dae29..83a3d9bd69b 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 69666c39ad2..0dac23c80c1 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 42ae519656d..ace511ba5a9 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 0b654ddebb6..f7ab4987943 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 061f81e5090..81bdeb887b6 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 04356775cd1..361a58185e6 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 8868ca0dca9..4f5ab9fd596 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 e8db9d09d91..4adf0b3c185 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608171371; cv=none; d=zohomail.com; s=zohoarc; b=VuGra27nNJPVV2yJR8UwO7OhDnftOQz26rixzWqQSkVE1DIFx66P7nLHgKGxOaKdBqlh5vFwHEEpsU2Gi7yAROLfIGEvpMhgyhPLAhHOjuul4zXYuw3+ne/0k424N5c0GQx4iJ3ZBB0hGtBLGZOLuvF3OhmwnWqR+4uCyN89pps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608171371; 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=+P4ANSfFZIW4cJwGDNPbnf8NbHRt0LA/4nAzSNIWbz0=; b=BE9w0FslNiiPrjHOY547pagVFA/2Es5AcqAFg4sG8ONfCkdqpe7XxJgQ98YSWYJnnuOSoxMqfP+sL/M6a29ieAv31sGSCQIKD+KDwXPN8Op+mV9xD+aKaNLNm4UJsNulD7iy+2dvy2K2MhOo7MjOrZkP6oGa6fMYxVPF8rdzuLg= 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 1608171371376807.7572688700117; Wed, 16 Dec 2020 18:16:11 -0800 (PST) Received: from localhost ([::1]:51442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpipu-0001L7-Cm for importer@patchew.org; Wed, 16 Dec 2020 21:16:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiaN-0002RN-Bn for qemu-devel@nongnu.org; Wed, 16 Dec 2020 21:00:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpia3-0007Bc-DU for qemu-devel@nongnu.org; Wed, 16 Dec 2020 21:00:07 -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-ecOnbYOeMhmPWrvj7lVCzQ-1; Wed, 16 Dec 2020 20:59:44 -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 52AD710054FF; Thu, 17 Dec 2020 01:59:43 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B9031E5; Thu, 17 Dec 2020 01:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170386; 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=+P4ANSfFZIW4cJwGDNPbnf8NbHRt0LA/4nAzSNIWbz0=; b=jOTOB1Y7nRynvtzgxlXMptBk3s1qpP/LnTsWfcOs+pzNMveHEWgkrqD0dhlWVqyaOv0Qa7 qDGCOfx8x0TuRtUqtWXMbDnwOtNVLp2SLx/PHNLG8ONBdxm0UMT9vJHcwoCflx3RF9qg/r c0emPnZUQLM0Gwm6K/CLHeBlZeqMZWc= X-MC-Unique: ecOnbYOeMhmPWrvj7lVCzQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 11/12] qapi/schema: Name the builtin module "" instead of None Date: Wed, 16 Dec 2020 20:59:26 -0500 Message-Id: <20201217015927.197287-12-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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, 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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 2dd99635e74..1933090a2a0 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -310,14 +310,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 0449771dfe5..0235208966a 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.fname if info else No= ne) + 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 fname is None: - 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 a3a16284006..12eeea3aaff 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 3f49c307c56..76e34ee7f02 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 08aba8354e2..02000c06e5e 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 83a3d9bd69b..494533d7479 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 0dac23c80c1..059caa4e1d2 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 ace511ba5a9..4d9d2b519f4 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 f7ab4987943..31d64631b66 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 81bdeb887b6..1b35b329571 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 361a58185e6..aed689e7bd6 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 4f5ab9fd596..4a899ba63ec 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 Sat May 18 19:47:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608170557; cv=none; d=zohomail.com; s=zohoarc; b=BiKtOdekEGXiwIGuSa9vfVthorae1ozr6DAZf531z1onUu/9ZNqUhbos4xHVs+d24mCRhbVsOYvMZ/dA5nyRO2/xLFvvomfLy5iOzq98nDdD/5UxP64PywJ0qePeT+4FqUmC7fNw0A32GA+2FQ4iO0tVnrSdpD+kY5FBm2h7JM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608170557; 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=s5opNEmjkiJr+km2yMFbUbb4Ju/cuOKo5wovOyY19nc=; b=c5Wxe277ClRiD1l+fDuRTB3AFfv7NVR+WU8jdCmx89mbX9uJ4eXaQzvSKC5EiZDp4xUgq1PjZZ9JDiklMnqaaitfaE8b/AsH2aFdC/a4JCk2NzFWmDYJ317FLunkoUgJxx5Vy9TcwG8uif5iqHE8NclCsEoOorGDzFDsf/xoh2o= 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 1608170557519903.7566594644749; Wed, 16 Dec 2020 18:02:37 -0800 (PST) Received: from localhost ([::1]:46062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpicm-0004I0-F7 for importer@patchew.org; Wed, 16 Dec 2020 21:02:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpiaE-0002Jc-0T for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpia4-0007Bm-Hi for qemu-devel@nongnu.org; Wed, 16 Dec 2020 20:59:57 -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-148-hcEqBI7vNcGbO_qJzYEF8Q-1; Wed, 16 Dec 2020 20:59: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 3B6661005504; Thu, 17 Dec 2020 01:59:44 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-131.rdu2.redhat.com [10.10.112.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76D5C19C81; Thu, 17 Dec 2020 01:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608170387; 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=s5opNEmjkiJr+km2yMFbUbb4Ju/cuOKo5wovOyY19nc=; b=dHBRrWRpTWSK8Ln9hzDl0w4AYOlHEVMmgkPwXtgXXij/HUMoRCPmwh7BgKrbCMEJVTxYZ0 A4nzcZfzoMTVmWY/UoU7XaubLRmVi8gDI8hCzeCmCYgSbgsIIr7H6jlmTUUkh8HPGhW4F7 PU2IYz7geMCGWdmy+T0ZZQ9jjsbaxDk= X-MC-Unique: hcEqBI7vNcGbO_qJzYEF8Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 12/12] qapi: enable strict-optional checks Date: Wed, 16 Dec 2020 20:59:27 -0500 Message-Id: <20201217015927.197287-13-jsnow@redhat.com> In-Reply-To: <20201217015927.197287-1-jsnow@redhat.com> References: <20201217015927.197287-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: Eduardo Habkost , Michael Roth , Markus Armbruster , Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow 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 74fc6c82153..04bd5db5278 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