From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619785988; cv=none; d=zohomail.com; s=zohoarc; b=VPzrLAHzSZzZFEkJlTFwEN+okpyZRU6oXv8v4jxXfqr94LDGPJLvsaNs5yJF+f3FqGMsblEVyQ4trygOVoZ2Z2h4uP2nzcE/Evs7hRauCQEuHoyk3AQWH5MqC6mEWgIdzQNHkeMkXdSIH3cI6obxxwvIM3Cx3h6TA1zMQy7vOfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619785988; 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=gYWdfQ1Xz39dlCgGPZDN+OPcgzulItKuPaIbBZJ/BXI=; b=Mfez1m3xNn6dTMvYWWs27t+QBH4A+/4Gu1yr7jFKVtp7OY0dNfTbDPlhOVjMhBNktg29tA3/9qS4I4ZuR0VmKIJTtaJJzds57Dfuq6IISbHVLsuzQQm8NmuTZaPNyFeSzvJXwX/iJ/jNp1SXTz971RJoUIaswTpo3/bThzwrsv0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619785988740536.9439428557076; Fri, 30 Apr 2021 05:33:08 -0700 (PDT) Received: from localhost ([::1]:54590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSKR-00012P-Fx for importer@patchew.org; Fri, 30 Apr 2021 08:33:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdd-0002xY-Kb for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007au-QG for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-AZrOHFuiPT6V0cdZ22padQ-1; Fri, 30 Apr 2021 07:48:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 277B881841D; Fri, 30 Apr 2021 11:48:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB9442B431; Fri, 30 Apr 2021 11:48:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6ED87113525E; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783323; 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=gYWdfQ1Xz39dlCgGPZDN+OPcgzulItKuPaIbBZJ/BXI=; b=aqK2KOoz3M97JNay4S9OFLHtD8ZIsfbhdNQORwwHi/mX03gf2My09wX1zBX8qaVJuSzKlx XXDlVYvYNmHBQoGWDd3uaIcz51VaFrjxVcRypRMC+vQOqw8Ajz+pr4E7dbzjVizWoeosdU guXMNSIBXH/XH4zhVTp9L4dzpjZvHW4= X-MC-Unique: AZrOHFuiPT6V0cdZ22padQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 01/25] qapi/expr: Comment cleanup Date: Fri, 30 Apr 2021 13:48:14 +0200 Message-Id: <20210430114838.2912740-2-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow The linter yaps after 0825f62c842. Fix this trivial issue to restore the linter baseline. (Yes, ideally -- and soon -- the linter will be part of CI so we don't clutter up the log with fixups. For now, though, the baseline is useful for testing intermediate commits as types are added to the QAPI library.) Signed-off-by: John Snow Message-Id: <20210421182032.3521476-2-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 540b3982b1..c207481f7e 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -241,7 +241,7 @@ def check_enum(expr, info): source =3D "%s '%s'" % (source, member_name) # Enum members may start with a digit if member_name[0].isdigit(): - member_name =3D 'd' + member_name # Hack: hide the digit + member_name =3D 'd' + member_name # Hack: hide the digit check_name_lower(member_name, info, source, permit_upper=3Dpermissive, permit_underscore=3Dpermissive) --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619788846; cv=none; d=zohomail.com; s=zohoarc; b=H1dpn6wmYefk6CJvSFcyRCEF9mqBVRq/xuvLkVNJDAqkXgmo+lwDSx+acC7f9v0kybjM8kVp53HPAo95j4p/wmG9G11r5FMB/pnJnKYjxn9fjO15uhusGo2+jwMPgD+tfzmHzS9R4XdqS1dMccmZPQTyH0LqpBHje3gyJ/slJv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619788846; 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=o07Ko4c+6YGB5mkVzUKZPLsPwNfzYAk8soOZvFri+tk=; b=dECuZBbEqZPeJmNSRj8SZchUAuXBcRN2Fd4Lg7Ro9/1RawXLOtFZAC3yVHGzqAIL1Yoj1zcefvnVtj7DOkm4AybEFkhkDRgToWXX/UBEmEwHG7hSkZ2zcc94NpH8ZpV84LVUi+Z/jmqs8iCePMUm8NU0bNumDiQ2syd6ggFSRNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619788846455100.75590160085949; Fri, 30 Apr 2021 06:20:46 -0700 (PDT) Received: from localhost ([::1]:42714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcT4W-0005CG-CX for importer@patchew.org; Fri, 30 Apr 2021 09:20:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdf-00032u-UN for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007al-Ry for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-YVPYvokQPAuF33NvuLWJNg-1; Fri, 30 Apr 2021 07:48:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2954618B614F; Fri, 30 Apr 2021 11:48:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E92172AC86; Fri, 30 Apr 2021 11:48:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 71E19113525F; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783323; 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=o07Ko4c+6YGB5mkVzUKZPLsPwNfzYAk8soOZvFri+tk=; b=OhnrV3h+xJv/Pwbq5w5DWzjSSAAK8A6IJSdhWAb1sSz3Pze/wHo2o45hLr/tbvsG3BzjgH 6ms+2eTbpCDSR/PdG4QpULgqhKSjtkeRjIRmKyrd9QOooW/AkwsLQVyiP8s4Qs8aAsKwz3 F2wMMzrLZWd8HZD+Ps/9RR2y/aYEgi0= X-MC-Unique: YVPYvokQPAuF33NvuLWJNg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 02/25] qapi/expr.py: Remove 'info' argument from nested check_if_str Date: Fri, 30 Apr 2021 13:48:15 +0200 Message-Id: <20210430114838.2912740-3-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow The function can just use the argument from the scope above. Otherwise, we get shadowed argument errors because the parameter name clashes with the name of a variable already in-scope. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Message-Id: <20210421182032.3521476-3-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index c207481f7e..3fda5d5082 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -122,7 +122,7 @@ def check_flags(expr, info): =20 def check_if(expr, info, source): =20 - def check_if_str(ifcond, info): + def check_if_str(ifcond): if not isinstance(ifcond, str): raise QAPISemError( info, @@ -142,9 +142,9 @@ def check_if_str(ifcond, info): raise QAPISemError( info, "'if' condition [] of %s is useless" % source) for elt in ifcond: - check_if_str(elt, info) + check_if_str(elt) else: - check_if_str(ifcond, info) + check_if_str(ifcond) expr['if'] =3D [ifcond] =20 =20 --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619788176; cv=none; d=zohomail.com; s=zohoarc; b=kyeWMfuQnnmWAx09OwxmhyHQkS3VXa3hBGWwWnJNGUhNOSZn1lL13PakDQHaydjaRcN3XeLZ/b/sWAhN65UJBSi4HeNGggY96SN1y3UvnfzH35xG21uVvWJCi51A4hM2KHW9ZLezL21clXdYDIOXTiBPRynTVMcRfyU8QkwkvIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619788176; 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=chTGHOqyfOnL8fMoI7lEF5ENPfOjdFqGYkVQwgBwyIw=; b=LCz8922TSl/rf9hgPRKNVHAzNOEHVS2loVshrwTnAqYt0Afc3MYxezF5mpd46Me75zJIPm1eygQq1DezskcSTO1Idnx3S3Q1uNICyzPfkQqDfl41P6i57GEnntTfvDpcx6NMNiaNsdv5O46uSIu9qwp2C8blQO6xDv5EwrCEAVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619788176646915.0111535226642; Fri, 30 Apr 2021 06:09:36 -0700 (PDT) Received: from localhost ([::1]:40114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSti-0000NQ-Ci for importer@patchew.org; Fri, 30 Apr 2021 09:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0002q0-G2 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007ap-ML for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-mu2DuT41N5mFdfe97VqSbg-1; Fri, 30 Apr 2021 07:48:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28F68107ACC7; Fri, 30 Apr 2021 11:48:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E94887013A; Fri, 30 Apr 2021 11:48:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 77DD91132D66; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783323; 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=chTGHOqyfOnL8fMoI7lEF5ENPfOjdFqGYkVQwgBwyIw=; b=ag3xGvvu4tBky9/Mw3B9E2mhi8bVUFse/u48Bcg9HoxcV1I6hfV8Ig4+hPJdk6Mn3ebH/p zqF2WYQJO5j/rvrPztLmzRynLdyBSrhBC0hKRbKrb/HWtjbEzbvVEjeAcY7cpXlD7VUElv vLQSa/Ek0fyx5EBuTb2LC1rea9f6og8= X-MC-Unique: mu2DuT41N5mFdfe97VqSbg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 03/25] qapi/expr.py: Check for dict instead of OrderedDict Date: Fri, 30 Apr 2021 13:48:16 +0200 Message-Id: <20210430114838.2912740-4-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow OrderedDict is a subtype of dict, so we can check for a more general form. These functions do not themselves depend on it being any particular type. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Message-Id: <20210421182032.3521476-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 3fda5d5082..b4bbcd54c0 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -14,7 +14,6 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 -from collections import OrderedDict import re =20 from .common import c_name @@ -149,7 +148,7 @@ def check_if_str(ifcond): =20 =20 def normalize_members(members): - if isinstance(members, OrderedDict): + if isinstance(members, dict): for key, arg in members.items(): if isinstance(arg, dict): continue @@ -180,7 +179,7 @@ def check_type(value, info, source, if not allow_dict: raise QAPISemError(info, "%s should be a type name" % source) =20 - if not isinstance(value, OrderedDict): + if not isinstance(value, dict): raise QAPISemError(info, "%s should be an object or type name" % source) =20 --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787981; cv=none; d=zohomail.com; s=zohoarc; b=NomzxSt3H5wETJ/g8GknDvpX3Yh2oq393lCSVoVfX+mYw/o794gmllX+E9Qn7ftvtr/mGXKQM+PRcxZ/zSTLOs9kvn4zBkXfGUaQaqh8y/W95gJMGhH1UfXlCTw74+O8NDpELeKQSrN/GmMi+EuxHFght0vTNOPBNnKRlGDY3Mk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787981; 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=yDiIZiEjofbfvGZV/7yGhfq/xQtHIP/s27KtMtTDdbI=; b=G0zpm2+m8qzSJbKl6o+Ktw4VaiS6zcyls2INO/bKbAnYEdjAmrBwzCBQeITgilFBryA7EMmlBoBnw1r1Oz9w/tSKoeAa5l3KhfdG5TYCb4Ao/m7NJcHaAZZIYe6t+g6NjAJDUvJfc8mbTeC+mLlsoqM3+b83dmorYWpAmQvVu10= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787981407557.5809980837107; Fri, 30 Apr 2021 06:06:21 -0700 (PDT) Received: from localhost ([::1]:33422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSqa-0005z8-8W for importer@patchew.org; Fri, 30 Apr 2021 09:06:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdZ-0002oI-V9 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdU-0007an-7P for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-aBsI9z9-PM6P_f5AbCN2CQ-1; Fri, 30 Apr 2021 07:48:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29B7F9F92F; Fri, 30 Apr 2021 11:48:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB9D017177; Fri, 30 Apr 2021 11:48:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7B8FF1132B25; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783323; 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=yDiIZiEjofbfvGZV/7yGhfq/xQtHIP/s27KtMtTDdbI=; b=KvK8W7MT1ijgdG2SGI7dZ2RM12tUKz3gRJ5mg623dj1Er/ZALSYtzyW8Tgvgq6aBYqfsZI /WKzvoFM1gM8BBKNmniIGqUP+8lHDPSs+dlDL3rlMPrrPz2KMRQjv+kShYLYIV+Aj9IqV3 sVwXPzpzg9Eyyw96mG1SAsyHkOI9deY= X-MC-Unique: aBsI9z9-PM6P_f5AbCN2CQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 04/25] qapi/expr.py: constrain incoming expression types Date: Fri, 30 Apr 2021 13:48:17 +0200 Message-Id: <20210430114838.2912740-5-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow mypy does not know the types of values stored in Dicts that masquerade as objects. Help the type checker out by constraining the type. Signed-off-by: John Snow Message-Id: <20210421182032.3521476-5-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index b4bbcd54c0..06a0081001 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -15,9 +15,20 @@ # See the COPYING file in the top-level directory. =20 import re +from typing import Dict, Optional =20 from .common import c_name from .error import QAPISemError +from .parser import QAPIDoc +from .source import QAPISourceInfo + + +# Deserialized JSON objects as returned by the parser. +# The values of this mapping are not necessary to exhaustively type +# here (and also not practical as long as mypy lacks recursive +# types), because the purpose of this module is to interrogate that +# type. +_JSONObject =3D Dict[str, object] =20 =20 # Names consist of letters, digits, -, and _, starting with a letter. @@ -315,9 +326,20 @@ def check_event(expr, info): =20 def check_exprs(exprs): for expr_elem in exprs: - expr =3D expr_elem['expr'] - info =3D expr_elem['info'] - doc =3D expr_elem.get('doc') + # Expression + assert isinstance(expr_elem['expr'], dict) + for key in expr_elem['expr'].keys(): + assert isinstance(key, str) + expr: _JSONObject =3D expr_elem['expr'] + + # QAPISourceInfo + assert isinstance(expr_elem['info'], QAPISourceInfo) + info: QAPISourceInfo =3D expr_elem['info'] + + # Optional[QAPIDoc] + tmp =3D expr_elem.get('doc') + assert tmp is None or isinstance(tmp, QAPIDoc) + doc: Optional[QAPIDoc] =3D tmp =20 if 'include' in expr: continue --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619786945; cv=none; d=zohomail.com; s=zohoarc; b=ITWHio+upKorYQjT6JgvARdhd9rVac4jtnRQpW1JFOqDC/YqYoG6TqY6PNhtlKJwjauUdz4ISUc3zUoiSz48zGM2F4yauh/RMq4dpmhbJor5afT79Ya+Kcetaeryr3lLo/emjaFY7zzxHbjXHE3tHLKE5SmyFEmYnmT2qwDYkWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619786945; 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=drn60Os5/CglmQ/gPhlP7Mt9xzBeYP4PYNYSko44izU=; b=R6zOqHc0J0rWOcRM6MqkHdiJsSpcUni5TsaGPTVI1zbUiWT3dEzf1/Op+RIOOhGtXXY+PVvL/Y2gv9sj45FZYlDlcRJou7dWQF2A0eH1psOxcMD1vRg9P4rH27PuhSOAc4hB2xiKqjF0GS5MHCEZ0gqR4c1MBJqM3vTH60JmSkA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619786945338953.6788655796819; Fri, 30 Apr 2021 05:49:05 -0700 (PDT) Received: from localhost ([::1]:39694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSZr-0001bu-Uf for importer@patchew.org; Fri, 30 Apr 2021 08:49:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRde-00030A-ME for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007bq-RE for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-34MNqPSMO2agseCpnWFI8Q-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F351C107ACE4; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C12AF1007607; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 804C711329A1; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783324; 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=drn60Os5/CglmQ/gPhlP7Mt9xzBeYP4PYNYSko44izU=; b=D6OxjUM4DVm0bTn7KaEASmvQ6awmD7CF4L7H69esZYEy9fuw/aJy1Q6xnuoNxssr7gPHv5 iYz5bJM4YBeGWbX1KYAYLnuanoXgd9/6/3YC/uFrEREuFY8JR4KUJgcjkeQVMo9VjsSr+7 5xoNPVSJ6X90PzyXcSKqLzojSRpsiLo= X-MC-Unique: 34MNqPSMO2agseCpnWFI8Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 05/25] qapi/expr.py: Add assertion for union type 'check_dict' Date: Fri, 30 Apr 2021 13:48:18 +0200 Message-Id: <20210430114838.2912740-6-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow mypy isn't fond of allowing you to check for bool membership in a collection of str elements. Guard this lookup for precisely when we were given a name. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Message-Id: <20210421182032.3521476-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 06a0081001..3ab78a555d 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -194,7 +194,9 @@ def check_type(value, info, source, raise QAPISemError(info, "%s should be an object or type name" % source) =20 - permissive =3D allow_dict in info.pragma.member_name_exceptions + permissive =3D False + if isinstance(allow_dict, str): + permissive =3D allow_dict in info.pragma.member_name_exceptions =20 # value is a dictionary, check that each member is okay for (key, arg) in value.items(): --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619788514; cv=none; d=zohomail.com; s=zohoarc; b=moZTg5hO5GhtwMuXCpY28YCmLGXQ73bk6oLlknkCmNfKvQ9OZi8G3609o8QhZJEbLp8F9dE3m/MaSh22O5SgO93YvxBR0T9S9z4yv8IJMfoCqCBXWgxrFrk4CYbu3wK701Ap808hl6h96uIGrJLMGDifWABMMqwaBdd1UhdXUlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619788514; 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=6cZDgMVx66+SufvLpSKmUpoX4Iftlv9NtLi3v26zPxE=; b=RlhgULlEuX5ZwvhX06SrKW/HZa04usC2dnAM0/YcnQ4PkgcBIdGYeCP4Fc7x4yJqCL+Fc5v+QBmZFeL++ma3oEP8J9bsSY1EoEnBMZJdjFxvmKC94jztDmbyrH8IR/lqQKwma3z17BjvJoiwYuEcs5xxQv62Z+3nJcgTWhpBeY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619788514218881.8491883423446; Fri, 30 Apr 2021 06:15:14 -0700 (PDT) Received: from localhost ([::1]:54300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSzA-0006b4-SL for importer@patchew.org; Fri, 30 Apr 2021 09:15:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdc-0002ue-GI for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007bs-Pd for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-z0qcryZcMOKAufvhtzg4Iw-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB7EC8189ED; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B987F19C45; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8388611329A3; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783324; 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=6cZDgMVx66+SufvLpSKmUpoX4Iftlv9NtLi3v26zPxE=; b=hXzMtjOYKY30kZURcasdw1MNQGN+Itc0go3vdsKO7N/Aw03F6HxKxg8PBSclq91y3YceAy vPugeMET+0LRk9NG3wbG69+9GmF4KMijqX5FjsEUuZL8eUQl+g6v0HO0vD5m2PyL6plBqe pu0wENvoazF1tIlNeRl0UibPPne+57o= X-MC-Unique: z0qcryZcMOKAufvhtzg4Iw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 06/25] qapi/expr.py: move string check upwards in check_type Date: Fri, 30 Apr 2021 13:48:19 +0200 Message-Id: <20210430114838.2912740-7-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow For readability purposes only, shimmy the early return upwards to the top of the function, so cases proceed in order from least to most complex. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Message-Id: <20210421182032.3521476-7-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 3ab78a555d..c0d18dcc01 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -171,6 +171,10 @@ def check_type(value, info, source, if value is None: return =20 + # Type name + if isinstance(value, str): + return + # Array type if isinstance(value, list): if not allow_array: @@ -181,10 +185,6 @@ def check_type(value, info, source, source) return =20 - # Type name - if isinstance(value, str): - return - # Anonymous type =20 if not allow_dict: --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787913; cv=none; d=zohomail.com; s=zohoarc; b=jJW0G+WrAbEsZvfyrkWdoKsjcG31jmT6DHAN0ZIo5/DjwL5Rof9OlXC4hoQDCRo+GBjr1x7uAAqEJp9hl833O43zCVAuzWzpDD6fO6F9oDV9o7qvLwi4wm47JOxQDYoXq+bBxyn4hAAkgwGkxszzmuctHrwrVEZhuScHMfyg9Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787913; 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=6XJuKpyiY2vd2HpmRFb1AQJLLHDSb8Me7iGXrQxWbys=; b=gujelGLSHNj8b9e2QhrVJWCbC/nbCCtK23j5G2F2AUAcHuJfiFcBfiZM8RwEnzB1nr1Xs51UiidsCdJwSiP5ZVB+8lg3gilchQCMO629uhRBiShTG4/4fWtnXb2Xh7dJq5ol4d4orNLtHxWM8jfqTjC9j3iSZ92dxrc7aMsBewE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16197879136081016.5978144207513; Fri, 30 Apr 2021 06:05:13 -0700 (PDT) Received: from localhost ([::1]:59056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSpU-0004p0-OV for importer@patchew.org; Fri, 30 Apr 2021 09:05:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdg-00033m-79 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52134) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cP-RI for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-143-iQv5O1-oNDaDsYWWh2uefg-1; Fri, 30 Apr 2021 07:48:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 189C8A0BD0; Fri, 30 Apr 2021 11:48:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7D3E2BFE6; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8769711329AF; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783326; 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=6XJuKpyiY2vd2HpmRFb1AQJLLHDSb8Me7iGXrQxWbys=; b=H5J0ocZgCnKnohSjwv0RpNYYK4E1OZ9yj4Ovow06CQDl/4UzvLgvaqCichKJfdvETpyHLv edCaPhUEZ1V17Z5yJ+6MD6Go+Hu+OxAvsQWd5SNEwepctrl0u3uJPwk2IGQbV5xWHBrMEW wlxnrmKE41Zcdz19NJxZYLV740Z3Hao= X-MC-Unique: iQv5O1-oNDaDsYWWh2uefg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 07/25] qapi/expr.py: Check type of union and alternate 'data' member Date: Fri, 30 Apr 2021 13:48:20 +0200 Message-Id: <20210430114838.2912740-8-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Prior to this commit, specifying a non-object value here causes the QAPI parser to crash in expr.py with a stack trace with (likely) an AttributeError when we attempt to call that value's items() method. This member needs to be an object (Dict), and not anything else. Add a check for this with a nicer error message, and formalize that check with new test cases that exercise that error. Signed-off-by: John Snow Message-Id: <20210421182032.3521476-8-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 7 +++++++ tests/qapi-schema/alternate-data-invalid.err | 2 ++ tests/qapi-schema/alternate-data-invalid.json | 4 ++++ tests/qapi-schema/alternate-data-invalid.out | 0 tests/qapi-schema/meson.build | 2 ++ tests/qapi-schema/union-invalid-data.err | 2 ++ tests/qapi-schema/union-invalid-data.json | 6 ++++++ tests/qapi-schema/union-invalid-data.out | 0 8 files changed, 23 insertions(+) create mode 100644 tests/qapi-schema/alternate-data-invalid.err create mode 100644 tests/qapi-schema/alternate-data-invalid.json create mode 100644 tests/qapi-schema/alternate-data-invalid.out create mode 100644 tests/qapi-schema/union-invalid-data.err create mode 100644 tests/qapi-schema/union-invalid-data.json create mode 100644 tests/qapi-schema/union-invalid-data.out diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index c0d18dcc01..03624bdf3f 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -283,6 +283,9 @@ def check_union(expr, info): raise QAPISemError(info, "'discriminator' requires 'base'") check_name_is_str(discriminator, info, "'discriminator'") =20 + if not isinstance(members, dict): + raise QAPISemError(info, "'data' must be an object") + for (key, value) in members.items(): source =3D "'data' member '%s'" % key if discriminator is None: @@ -298,6 +301,10 @@ def check_alternate(expr, info): =20 if not members: raise QAPISemError(info, "'data' must not be empty") + + if not isinstance(members, dict): + raise QAPISemError(info, "'data' must be an object") + for (key, value) in members.items(): source =3D "'data' member '%s'" % key check_name_lower(key, info, source) diff --git a/tests/qapi-schema/alternate-data-invalid.err b/tests/qapi-sche= ma/alternate-data-invalid.err new file mode 100644 index 0000000000..55f1033aef --- /dev/null +++ b/tests/qapi-schema/alternate-data-invalid.err @@ -0,0 +1,2 @@ +alternate-data-invalid.json: In alternate 'Alt': +alternate-data-invalid.json:2: 'data' must be an object diff --git a/tests/qapi-schema/alternate-data-invalid.json b/tests/qapi-sch= ema/alternate-data-invalid.json new file mode 100644 index 0000000000..7d5d905581 --- /dev/null +++ b/tests/qapi-schema/alternate-data-invalid.json @@ -0,0 +1,4 @@ +# Alternate type requires an object for 'data' +{ 'alternate': 'Alt', + 'data': ['rubbish', 'nonsense'] +} diff --git a/tests/qapi-schema/alternate-data-invalid.out b/tests/qapi-sche= ma/alternate-data-invalid.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 8ba6917132..d7163e6601 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -14,6 +14,7 @@ schemas =3D [ 'alternate-conflict-string.json', 'alternate-conflict-bool-string.json', 'alternate-conflict-num-string.json', + 'alternate-data-invalid.json', 'alternate-empty.json', 'alternate-invalid-dict.json', 'alternate-nested.json', @@ -192,6 +193,7 @@ schemas =3D [ 'union-clash-branches.json', 'union-empty.json', 'union-invalid-base.json', + 'union-invalid-data.json', 'union-optional-branch.json', 'union-unknown.json', 'unknown-escape.json', diff --git a/tests/qapi-schema/union-invalid-data.err b/tests/qapi-schema/u= nion-invalid-data.err new file mode 100644 index 0000000000..e26cf769a3 --- /dev/null +++ b/tests/qapi-schema/union-invalid-data.err @@ -0,0 +1,2 @@ +union-invalid-data.json: In union 'TestUnion': +union-invalid-data.json:2: 'data' must be an object diff --git a/tests/qapi-schema/union-invalid-data.json b/tests/qapi-schema/= union-invalid-data.json new file mode 100644 index 0000000000..395ba24d39 --- /dev/null +++ b/tests/qapi-schema/union-invalid-data.json @@ -0,0 +1,6 @@ +# the union data type must be an object. +{ 'union': 'TestUnion', + 'base': 'int', + 'discriminator': 'int', + 'data': ['rubbish', 'nonsense'] +} diff --git a/tests/qapi-schema/union-invalid-data.out b/tests/qapi-schema/u= nion-invalid-data.out new file mode 100644 index 0000000000..e69de29bb2 --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619785705; cv=none; d=zohomail.com; s=zohoarc; b=CgeYv5gSKWn6RmTWSx7AhPFyQQudVHt9uIT54i37SqnLBxhHnwDnoJrcDgNzkMUV02aLz8ObK19r93guWKVR4qL788eeLFL3a5KRfHEkmUwUhr9y0ZEHJkxLtNOmJNb90WVc49lqZk0SyYNiPTaa/bRGFTWlkSLdQbov3eqhU5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619785705; 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=fRQZnMXI/BD0ivljuQHMhAnr4wf7XVrKqv2B7Y3NW8I=; b=DOmUbmyS1ZWz1AyFKlKk4z/i5gSDFU1Gmo2o+9mxb/QjqcFr8Bo4XfyX1QfVowVFpMtAZYsBwzJhoadIDoC671cz724G8G1+a2HWJheUI3tHTZICg9ncO8Vswow8tXmRjKSLlQGEEBsE8gVt2ZYy8b72EGsPIKqAk4w9xgwwKig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16197857053080.48622276075013815; Fri, 30 Apr 2021 05:28:25 -0700 (PDT) Received: from localhost ([::1]:47302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSFs-0006U9-8n for importer@patchew.org; Fri, 30 Apr 2021 08:28:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdZ-0002oR-Uy for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007bw-MT for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-geVoI2vpOuSkA-eTrJuKXQ-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E82D518B6324; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B785D17177; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8B5A11131C01; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=fRQZnMXI/BD0ivljuQHMhAnr4wf7XVrKqv2B7Y3NW8I=; b=FrHgqfc3q0h8Or/Rt0aUGCneFo1CAzFMvAmbZHeU2ZuVes7mKVzBuGwHYbeT9+sFYteLZ+ G4TSpe/SNkKjPcYfNVhJ/ya8xQHWSUQlvVoBcXWtXdl6dI3W7DOrUbkQC9MyKJ+vDGcidr /8kAT0qEE61I3lSIETCH6UbrMYXa8w0= X-MC-Unique: geVoI2vpOuSkA-eTrJuKXQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 08/25] qapi/expr.py: Add casts in a few select cases Date: Fri, 30 Apr 2021 13:48:21 +0200 Message-Id: <20210430114838.2912740-9-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Casts are instructions to the type checker only, they aren't "safe" and should probably be avoided in general. In this case, when we perform type checking on a nested structure, the type of each field does not "stick". (See PEP 647 for an example of "type narrowing" that does "stick". It is available in Python 3.10, so we can't use it yet.) We don't need to assert that something is a str if we've already checked or asserted that it is -- use a cast instead for these cases. Signed-off-by: John Snow Message-Id: <20210421182032.3521476-9-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 03624bdf3f..f3a4a8536e 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -15,7 +15,7 @@ # See the COPYING file in the top-level directory. =20 import re -from typing import Dict, Optional +from typing import Dict, Optional, cast =20 from .common import c_name from .error import QAPISemError @@ -261,7 +261,7 @@ def check_enum(expr, info): =20 =20 def check_struct(expr, info): - name =3D expr['struct'] + name =3D cast(str, expr['struct']) # Checked in check_exprs members =3D expr['data'] =20 check_type(members, info, "'data'", allow_dict=3Dname) @@ -269,7 +269,7 @@ def check_struct(expr, info): =20 =20 def check_union(expr, info): - name =3D expr['union'] + name =3D cast(str, expr['union']) # Checked in check_exprs base =3D expr.get('base') discriminator =3D expr.get('discriminator') members =3D expr['data'] @@ -368,8 +368,8 @@ def check_exprs(exprs): else: raise QAPISemError(info, "expression is missing metatype") =20 - name =3D expr[meta] - check_name_is_str(name, info, "'%s'" % meta) + check_name_is_str(expr[meta], info, "'%s'" % meta) + name =3D cast(str, expr[meta]) info.set_defn(meta, name) check_defn_name_str(name, info, meta) =20 --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787731; cv=none; d=zohomail.com; s=zohoarc; b=EKYI/Ng1vGYeiOXR01N0xfIaZk6c4OROiwm5mHoZvE+Gs0YRUVhJeITJVljg+xyjjfwV1MQQm0MffKLtg4wEICCd7rf4rvvZNNZNkK6jn7a+J3l9GK+QEqdJx7oKdPLIxcQ4UO7pmA10A9E/khMZoXmeFPlM5ZWpbJB+SLMN9cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787731; 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=11b1QMUVpG/RaoRPjejp/+besHwAC/Jx9yoFpHWltGQ=; b=iF1v/ISLpr1TE6sAiYNm9Ey/OlvQjLBxgShM446xg6cRrjpXduxdhurAWZy1cwq6z1vjNDdNDULN8N+wtj8NTwxUneZSUfsqiVo3NRafERe5RQenXfydoK4erZYkh7D7jz1dLq2Cvuar1Gy+wj0OCoS4ZejtFTRe31dgtTdffsM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787731239791.353934271928; Fri, 30 Apr 2021 06:02:11 -0700 (PDT) Received: from localhost ([::1]:51624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSmX-0001a8-Fk for importer@patchew.org; Fri, 30 Apr 2021 09:02:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdf-00032Y-Oa for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007c2-S5 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-ppvLXsMqOYyVSUnsm_Ol5w-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E691A107ACE3; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B730060937; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8ED251141CBD; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=11b1QMUVpG/RaoRPjejp/+besHwAC/Jx9yoFpHWltGQ=; b=ErNZszg467DWdyMh01xaWLuuUi6XogsucloW8W9P/sPOU+vgCM6SmfPLkTFdR59i3tmFLu BNkb2r6vyRrOQaBfbPANgyXzHfWkKlbCghb/hupymu9IbVynB9MjLurMdGQh9c34BrfFsv zeOrQ5WTGx6rJGE49Gxhhbw11uLvA7E= X-MC-Unique: ppvLXsMqOYyVSUnsm_Ol5w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 09/25] qapi/expr.py: Modify check_keys to accept any Collection Date: Fri, 30 Apr 2021 13:48:22 +0200 Message-Id: <20210430114838.2912740-10-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow This is a minor adjustment that lets parameters @required and @optional take tuple arguments, in particular (). Later patches will make use of that. (Iterable would also have worked, but Iterable also includes things like generator expressions which are consumed upon iteration, which would require a rewrite to make sure that each input was only traversed once. Collection implies the "can re-iterate" property.) Signed-off-by: John Snow Message-Id: <20210421182032.3521476-10-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index f3a4a8536e..396c8126d6 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -102,7 +102,7 @@ def pprint(elems): "%s misses key%s %s" % (source, 's' if len(missing) > 1 else '', pprint(missing))) - allowed =3D set(required + optional) + allowed =3D set(required) | set(optional) unknown =3D set(value) - allowed if unknown: raise QAPISemError( --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787242; cv=none; d=zohomail.com; s=zohoarc; b=Qa+8pklHCUR82/n8yzOhXQR9ws7fFkIfxMtsYi0yPiCCqwlhCn+/HcQtE2zE9mtneVLcvVxNOtVHmu46O3Pzk+qqDVHpnZF6GGNIPuypjagDRRgG8Oty7hOFswSO2MyuNw5RHqyztUNcIzmpbL96tOFDoRNIy8VT6103pH2izck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787242; 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=DLq0fyj+TAYwEYUHuzH4aKDCKUddnYVXsHlexhiQS6g=; b=VVGcf3d+iU8893owGziIxR2yK/Hs54dod7exbcFyV7ouh8oL1eQN76nBAXeKTl+Fb9X9Qa5+Wm3PmG6XUR3W+STypQDV+TRGrfDXSZvLbFiS2ZGDcYF8Dm4zpWSasuUIomNyK4P0PrIATAcJQJ02XRQeDWG0ELHosqlfR2P0jXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787242421124.25289713910104; Fri, 30 Apr 2021 05:54:02 -0700 (PDT) Received: from localhost ([::1]:55364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSef-0008Gt-B0 for importer@patchew.org; Fri, 30 Apr 2021 08:54:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdc-0002vN-OV for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007c5-Ot for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-n3QZaA1PM1CGBvrvr5nTAw-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C9C08042A3; Fri, 30 Apr 2021 11:48:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B84075D9C6; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9340C114200B; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=DLq0fyj+TAYwEYUHuzH4aKDCKUddnYVXsHlexhiQS6g=; b=SdwEgWVY8+fbV5Y/HK45NCOo8GKPl+didFfowyOc1JiksSZCqWMpCEtErUvDi2N/CktS60 GW4T2GipziGgmq0u3ttMbRsH0skPW1Ubx4S4sW2mqHsHXsVsusMxXnfzjCChhMG4gPq4pq QcoUUjt8vEmFzG+cXhaSeIt4YICc7SM= X-MC-Unique: n3QZaA1PM1CGBvrvr5nTAw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 10/25] qapi/expr.py: add type hint annotations Date: Fri, 30 Apr 2021 13:48:23 +0200 Message-Id: <20210430114838.2912740-11-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Message-Id: <20210421182032.3521476-11-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 68 +++++++++++++++++++++++++++---------------- scripts/qapi/mypy.ini | 5 ---- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 396c8126d6..4ebed4c488 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -15,7 +15,15 @@ # See the COPYING file in the top-level directory. =20 import re -from typing import Dict, Optional, cast +from typing import ( + Collection, + Dict, + Iterable, + List, + Optional, + Union, + cast, +) =20 from .common import c_name from .error import QAPISemError @@ -39,12 +47,14 @@ r'([a-z][a-z0-9_-]*)$', re.IGNORECASE) =20 =20 -def check_name_is_str(name, info, source): +def check_name_is_str(name: object, + info: QAPISourceInfo, + source: str) -> None: if not isinstance(name, str): raise QAPISemError(info, "%s requires a string name" % source) =20 =20 -def check_name_str(name, info, source): +def check_name_str(name: str, info: QAPISourceInfo, source: str) -> str: # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty' # and 'q_obj_*' implicit type names. match =3D valid_name.match(name) @@ -53,16 +63,16 @@ def check_name_str(name, info, source): return match.group(3) =20 =20 -def check_name_upper(name, info, source): +def check_name_upper(name: str, info: QAPISourceInfo, source: str) -> None: stem =3D check_name_str(name, info, source) if re.search(r'[a-z-]', stem): raise QAPISemError( info, "name of %s must not use lowercase or '-'" % source) =20 =20 -def check_name_lower(name, info, source, - permit_upper=3DFalse, - permit_underscore=3DFalse): +def check_name_lower(name: str, info: QAPISourceInfo, source: str, + permit_upper: bool =3D False, + permit_underscore: bool =3D False) -> None: stem =3D check_name_str(name, info, source) if ((not permit_upper and re.search(r'[A-Z]', stem)) or (not permit_underscore and '_' in stem)): @@ -70,13 +80,13 @@ def check_name_lower(name, info, source, info, "name of %s must not use uppercase or '_'" % source) =20 =20 -def check_name_camel(name, info, source): +def check_name_camel(name: str, info: QAPISourceInfo, source: str) -> None: stem =3D check_name_str(name, info, source) if not re.match(r'[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$', stem): raise QAPISemError(info, "name of %s must use CamelCase" % source) =20 =20 -def check_defn_name_str(name, info, meta): +def check_defn_name_str(name: str, info: QAPISourceInfo, meta: str) -> Non= e: if meta =3D=3D 'event': check_name_upper(name, info, meta) elif meta =3D=3D 'command': @@ -90,9 +100,13 @@ def check_defn_name_str(name, info, meta): info, "%s name should not end in '%s'" % (meta, name[-4:])) =20 =20 -def check_keys(value, info, source, required, optional): +def check_keys(value: _JSONObject, + info: QAPISourceInfo, + source: str, + required: Collection[str], + optional: Collection[str]) -> None: =20 - def pprint(elems): + def pprint(elems: Iterable[str]) -> str: return ', '.join("'" + e + "'" for e in sorted(elems)) =20 missing =3D set(required) - set(value) @@ -112,7 +126,7 @@ def pprint(elems): pprint(unknown), pprint(allowed))) =20 =20 -def check_flags(expr, info): +def check_flags(expr: _JSONObject, info: QAPISourceInfo) -> None: for key in ['gen', 'success-response']: if key in expr and expr[key] is not False: raise QAPISemError( @@ -130,9 +144,9 @@ def check_flags(expr, info): "are incompatible") =20 =20 -def check_if(expr, info, source): +def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None: =20 - def check_if_str(ifcond): + def check_if_str(ifcond: object) -> None: if not isinstance(ifcond, str): raise QAPISemError( info, @@ -158,7 +172,7 @@ def check_if_str(ifcond): expr['if'] =3D [ifcond] =20 =20 -def normalize_members(members): +def normalize_members(members: object) -> None: if isinstance(members, dict): for key, arg in members.items(): if isinstance(arg, dict): @@ -166,8 +180,11 @@ def normalize_members(members): members[key] =3D {'type': arg} =20 =20 -def check_type(value, info, source, - allow_array=3DFalse, allow_dict=3DFalse): +def check_type(value: Optional[object], + info: QAPISourceInfo, + source: str, + allow_array: bool =3D False, + allow_dict: Union[bool, str] =3D False) -> None: if value is None: return =20 @@ -214,7 +231,8 @@ def check_type(value, info, source, check_type(arg['type'], info, key_source, allow_array=3DTrue) =20 =20 -def check_features(features, info): +def check_features(features: Optional[object], + info: QAPISourceInfo) -> None: if features is None: return if not isinstance(features, list): @@ -231,7 +249,7 @@ def check_features(features, info): check_if(f, info, source) =20 =20 -def check_enum(expr, info): +def check_enum(expr: _JSONObject, info: QAPISourceInfo) -> None: name =3D expr['enum'] members =3D expr['data'] prefix =3D expr.get('prefix') @@ -260,7 +278,7 @@ def check_enum(expr, info): check_if(member, info, source) =20 =20 -def check_struct(expr, info): +def check_struct(expr: _JSONObject, info: QAPISourceInfo) -> None: name =3D cast(str, expr['struct']) # Checked in check_exprs members =3D expr['data'] =20 @@ -268,7 +286,7 @@ def check_struct(expr, info): check_type(expr.get('base'), info, "'base'") =20 =20 -def check_union(expr, info): +def check_union(expr: _JSONObject, info: QAPISourceInfo) -> None: name =3D cast(str, expr['union']) # Checked in check_exprs base =3D expr.get('base') discriminator =3D expr.get('discriminator') @@ -296,7 +314,7 @@ def check_union(expr, info): check_type(value['type'], info, source, allow_array=3Dnot base) =20 =20 -def check_alternate(expr, info): +def check_alternate(expr: _JSONObject, info: QAPISourceInfo) -> None: members =3D expr['data'] =20 if not members: @@ -313,7 +331,7 @@ def check_alternate(expr, info): check_type(value['type'], info, source) =20 =20 -def check_command(expr, info): +def check_command(expr: _JSONObject, info: QAPISourceInfo) -> None: args =3D expr.get('data') rets =3D expr.get('returns') boxed =3D expr.get('boxed', False) @@ -324,7 +342,7 @@ def check_command(expr, info): check_type(rets, info, "'returns'", allow_array=3DTrue) =20 =20 -def check_event(expr, info): +def check_event(expr: _JSONObject, info: QAPISourceInfo) -> None: args =3D expr.get('data') boxed =3D expr.get('boxed', False) =20 @@ -333,7 +351,7 @@ def check_event(expr, info): check_type(args, info, "'data'", allow_dict=3Dnot boxed) =20 =20 -def check_exprs(exprs): +def check_exprs(exprs: List[_JSONObject]) -> List[_JSONObject]: for expr_elem in exprs: # Expression assert isinstance(expr_elem['expr'], dict) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 0a000d58b3..7797c83432 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -8,11 +8,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.expr] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.parser] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619786757; cv=none; d=zohomail.com; s=zohoarc; b=IDY6G7j2I36Pcitbjus+29jigPWS/4PuRcoXcs+9r4Nw4cc/0wA1DEgvnb1eK1FAdCJqXg78qEZRbimxR5k/AGeNkJW5LMM92ldenQW36ctU9Wbbdfmi+LRZ1As6d3BKc21lVJPlRi0FRBvPef9+z609uBhdVtpQNdsECetngN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619786757; 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=NwT3F/58naBOGw7YmtkMLSX6g53NOQqEYyZVboPvrsw=; b=EPv07GpNWq8yIU45dFvDX/BCZPd/jW+a9pPd4289yfoG6Zy7WDcLCP1juZpCghKF9hLgvuwaLZ3FLBB6uJrYuZkxHpMJTSj3cNmL8DAvRW1FEQti/CAc3DgAWO9BX64tMfcI6+2n7hVNp8jpyDDDIOs0+cd5om5z+5xI/FyYd+Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619786757234397.56347107702175; Fri, 30 Apr 2021 05:45:57 -0700 (PDT) Received: from localhost ([::1]:59322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSWp-0006Sh-Vx for importer@patchew.org; Fri, 30 Apr 2021 08:45:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdb-0002rr-CZ for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cH-N6 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-eIGRzYaLMKa8rH-sZ-nWCg-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6F32A0BC8; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B78CA1690D; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 971101142030; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=NwT3F/58naBOGw7YmtkMLSX6g53NOQqEYyZVboPvrsw=; b=EfpyTMZOd2+Zh9yYeDEcVK+hGfKTJWT9jo39Y5XmVR8htUt69V9s3VjlPGlpf01ZYHwD2d 772bMQlikv1BKcKdukZy1aiFw5YPCeYMxNF8EQjMVsAfsJN5A0u7RGUb1MG2I6dGttfw6z vwm7pWpSXDLPgZuJoVjzig1/fZwWYKA= X-MC-Unique: eIGRzYaLMKa8rH-sZ-nWCg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 11/25] qapi/expr.py: Consolidate check_if_str calls in check_if Date: Fri, 30 Apr 2021 13:48:24 +0200 Message-Id: <20210430114838.2912740-12-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow This is a small rewrite to address some minor style nits. Don't compare against the empty list to check for the empty condition, and move the normalization forward to unify the check on the now-normalized structure. With the check unified, the local nested function isn't needed anymore and can be brought down into the normal flow of the function. With the nesting level changed, shuffle the error strings around a bit to get them to fit in 79 columns. Note: although ifcond is typed as Sequence[str] elsewhere, we *know* that the parser will produce real, bona-fide lists. It's okay to check isinstance(ifcond, list) here. Signed-off-by: John Snow Message-Id: <20210421182032.3521476-12-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 4ebed4c488..de7fc16fac 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -146,30 +146,29 @@ def check_flags(expr: _JSONObject, info: QAPISourceIn= fo) -> None: =20 def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None: =20 - def check_if_str(ifcond: object) -> None: - if not isinstance(ifcond, str): + ifcond =3D expr.get('if') + if ifcond is None: + return + + if isinstance(ifcond, list): + if not ifcond: + raise QAPISemError( + info, "'if' condition [] of %s is useless" % source) + else: + # Normalize to a list + ifcond =3D expr['if'] =3D [ifcond] + + for elt in ifcond: + if not isinstance(elt, str): raise QAPISemError( info, "'if' condition of %s must be a string or a list of string= s" % source) - if ifcond.strip() =3D=3D '': + if not elt.strip(): raise QAPISemError( info, "'if' condition '%s' of %s makes no sense" - % (ifcond, source)) - - ifcond =3D expr.get('if') - if ifcond is None: - return - if isinstance(ifcond, list): - if ifcond =3D=3D []: - raise QAPISemError( - info, "'if' condition [] of %s is useless" % source) - for elt in ifcond: - check_if_str(elt) - else: - check_if_str(ifcond) - expr['if'] =3D [ifcond] + % (elt, source)) =20 =20 def normalize_members(members: object) -> None: --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787376; cv=none; d=zohomail.com; s=zohoarc; b=ARWqU/BOuQT17SNqSm3Pqbzm4sF0P2vJc4B1TmtSvsbwNObG00qOmGtw6FLe5//PEuMNgvplJV83CDXV4uJTPBzcDPuW2JvBjGk7IURcH5TPQSKEs1OiQ8Gy4OuWhJBI2PG8h4rKecq6FTE/V9mQHH1hdtJrjZyE7tXKht3PGGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787376; 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=sAyqwdh6yzgO3Xdes/yOwLV6FsTvmcG8Us8WfMENcsE=; b=GPJ01lhS6y9X94CcGErycbF3dP5mF/9IMOHwe1PrrSuFp0JfGJJnRepKITV/AogMiOoHhVMKxibq+t8S8oPPPQE8MoE3YHpaU7Jp5bTSy8LJ8ibTOnftBr1XcbJBXcJ53GEUEwgyXhMkNO1axfagjF/iRCTQC7w0tlF+2lJc5/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787376124485.58451550286975; Fri, 30 Apr 2021 05:56:16 -0700 (PDT) Received: from localhost ([::1]:35720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSgp-0003Qa-1E for importer@patchew.org; Fri, 30 Apr 2021 08:56:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdd-0002wp-8B for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60281) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007bz-OX for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-1JJ5BMmaPbWj7d1YxHIKPA-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E945710060CA; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7F461724C; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9AEF9114423C; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=sAyqwdh6yzgO3Xdes/yOwLV6FsTvmcG8Us8WfMENcsE=; b=BrQuT0UfXeJAMs8HuZXF2LMRJzFL4cgSvzFVt1z4xQT3xXt1jDFk4+HgHPveKJDOXHvLcA EyLEp3TnQF59IwZpitGrrPzv8PEZ8K/xabzxL+r3ivyi40kLD3f+gdb6WOOiYhUtVB+imI n1D4oeN/ONO3QG71HKZPXmxmM/3f3Ks= X-MC-Unique: 1JJ5BMmaPbWj7d1YxHIKPA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 12/25] qapi/expr.py: Remove single-letter variable Date: Fri, 30 Apr 2021 13:48:25 +0200 Message-Id: <20210430114838.2912740-13-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Signed-off-by: John Snow Message-Id: <20210421182032.3521476-13-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index de7fc16fac..5e4d5f80aa 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -238,14 +238,14 @@ def check_features(features: Optional[object], raise QAPISemError(info, "'features' must be an array") features[:] =3D [f if isinstance(f, dict) else {'name': f} for f in features] - for f in features: + for feat in features: source =3D "'features' member" - assert isinstance(f, dict) - check_keys(f, info, source, ['name'], ['if']) - check_name_is_str(f['name'], info, source) - source =3D "%s '%s'" % (source, f['name']) - check_name_lower(f['name'], info, source) - check_if(f, info, source) + assert isinstance(feat, dict) + check_keys(feat, info, source, ['name'], ['if']) + check_name_is_str(feat['name'], info, source) + source =3D "%s '%s'" % (source, feat['name']) + check_name_str(feat['name'], info, source) + check_if(feat, info, source) =20 =20 def check_enum(expr: _JSONObject, info: QAPISourceInfo) -> None: --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787063; cv=none; d=zohomail.com; s=zohoarc; b=MrvdepBxAHp75uS3G/cUNYcNr69U2wb5z9S4SPi9Zf76sJ0FwCI3Gr2robPoC5bmavmv2iKPjXi0pB5o9i7roM+JisKVZyjd10wmMnDs3lU/XOs9XRzqAJU0LI3jVGt09LErhh2Crk6lp6qCIEng/hdbx/+IlWRrj3SZCpbobQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787063; 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=xTIuCP5jK5afa0XVa4+KDzQAP/z7hpF9Y58VxeVGhSE=; b=U60E+ab05nFK4uRBgLOdhL+yT1bsyxli/x0YpobcceXKkDEk9zMUIl5ABfxklO6Z29oqpNRDXR+3Vlr7BMNwncmCyIYfjoEOII5yF+UjrfdRVn2N5q9/hYyml1lRgnQwqfEanWdr3/7Swb7/MCn6IkVbpZCYtBcEPmLkgk7gwVQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787063599716.3739781296177; Fri, 30 Apr 2021 05:51:03 -0700 (PDT) Received: from localhost ([::1]:47052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSbl-0004mr-CQ for importer@patchew.org; Fri, 30 Apr 2021 08:51:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0002qs-RZ for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cL-NO for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-my2XLi-QOxuSOqs5WjAoWQ-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9616A0BCC; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8E4A18024; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9EEDF1129C41; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=xTIuCP5jK5afa0XVa4+KDzQAP/z7hpF9Y58VxeVGhSE=; b=UwBdQdRubY7FsajdiAryiqW4vvi25yaeZqTzjvNjvq0/hBSPlpNfNTdeykqH9x2RQgKAHL 1L/lOevM886tti29bbUCx+QG6kSapQHJWgDUP2TZjEN/03cacwqJG81qDYIGQuRACY8sKq evinyqLMlJQJzi2qPsTGtrWkWDKolQ0= X-MC-Unique: my2XLi-QOxuSOqs5WjAoWQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 13/25] qapi/expr.py: enable pylint checks Date: Fri, 30 Apr 2021 13:48:26 +0200 Message-Id: <20210430114838.2912740-14-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Signed-off-by: John Snow Tested-by: Eduardo Habkost Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20210421182032.3521476-14-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/pylintrc | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index b9e077a164..fb0386d529 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -3,7 +3,6 @@ # Add files or directories matching the regex patterns to the ignore list. # The regex matches against base names, not paths. ignore-patterns=3Derror.py, - expr.py, parser.py, schema.py, =20 --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619788323; cv=none; d=zohomail.com; s=zohoarc; b=deWw6j8iSq9lqwswn4Xscwy1crxDVH/mZLd/Nh5d7Tvb0tQ56V86BAbCnDmiH+qve3hebFSWO59JNINU9GzfgOy19Plam97xuAgi9TB4eUShOYf/SpoxfiLpVibjE8DG+t78z/hJkHms2siPKFpZ9oKllNd7mki112TxQNJ8Xn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619788323; 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=eymAHEgkCoZvQ1D+5sgN3VhJ4eH7mJzsbVWC1uQa1U8=; b=MPpTUQLVUWcMkCvAAMzEW5p3QrJIG9yKdjXKEPFI95k2w6i5pZQa5Qv5cX4r9QE0qlJAnnOWy7TghsGTn7vxMm1lCNrc3BYzKmgcmEzY/9w7gsMjx4WvkIXaxj0MR+SIpwCGTHvGzHwrgHORpWS6GR0OAYtdUZW3XN48gdg2G8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161978832304423.547932925037344; Fri, 30 Apr 2021 06:12:03 -0700 (PDT) Received: from localhost ([::1]:46560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSw5-0003DO-T6 for importer@patchew.org; Fri, 30 Apr 2021 09:12:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdb-0002rO-1T for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cA-NN for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235-CyeKmX5NMSuVbkWmasc_jg-1; Fri, 30 Apr 2021 07:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E51188015BA; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B79C82B431; Fri, 30 Apr 2021 11:48:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A248D1129C42; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783325; 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=eymAHEgkCoZvQ1D+5sgN3VhJ4eH7mJzsbVWC1uQa1U8=; b=F08/c6UMoFSHVVLBmNaEd+9UFR4FgWSVzUhkdGKZYRL2EXjSAnkjKL5802rm7RSkOttdLU 6LvpsLa10curRbQrmhzA7sE7cR1/4xI3wVFtEkvvfsm4NQ3fOJEoktTitKm39Lpt1DulhJ wQONssLS9uTuHjLXbnwm4ltslDQ+OwM= X-MC-Unique: CyeKmX5NMSuVbkWmasc_jg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 14/25] qapi/expr: Only explicitly prohibit 'Kind' nor 'List' for type names Date: Fri, 30 Apr 2021 13:48:27 +0200 Message-Id: <20210430114838.2912740-15-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Per list review: qapi-code-gen.txt reserves suffixes Kind and List only for type names, but the code rejects them for events and commands, too. It turns out we reject them earlier anyway: In check_name_upper() for event names, and in check_name_lower() for command names. Still, adjust the code for clarity over what precisely we are guarding against. Signed-off-by: John Snow Message-Id: <20210421182032.3521476-15-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 5e4d5f80aa..c33caf00d9 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -95,9 +95,9 @@ def check_defn_name_str(name: str, info: QAPISourceInfo, = meta: str) -> None: permit_underscore=3Dname in info.pragma.command_name_exception= s) else: check_name_camel(name, info, meta) - if name.endswith('Kind') or name.endswith('List'): - raise QAPISemError( - info, "%s name should not end in '%s'" % (meta, name[-4:])) + if name.endswith('Kind') or name.endswith('List'): + raise QAPISemError( + info, "%s name should not end in '%s'" % (meta, name[-4:])) =20 =20 def check_keys(value: _JSONObject, --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619786595; cv=none; d=zohomail.com; s=zohoarc; b=OEpq4sqVKy4MOWZTmA8ho6WCI0cgLGUCHLGYEBGz+fh340v5kR4cYPUO9/We4Oao0x/YegHUCwskxvbFpYjfzUf4aVHgFFL3Zb+0J/ZvCO5pQr5Wj5t/VwXJgbU/MN+3p3kW0HkG6SJig02uLO4yT2lXDlq5Mpb8rMMNO4oFm90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619786595; 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=IaqmwRyPHkUwBhT6M0d+2egmb1Zv0ln/tCXglbvxVfM=; b=ewUcztZqasAiFpWW2MpVJI0Md+cVmbEcPf8a8wYSuFNuqw4ho5/344VcQMXCxiUfU2y6tF5QJPQFWv/Fqz+esPE4UGsl5eBxBG8QFQerRJXbgWH/KCYQdq85vZdbPPnJJN871fGCE9MgDsoCreJKpravgC7ZW5FC5MGwbpKYKO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619786595325843.6289288990986; Fri, 30 Apr 2021 05:43:15 -0700 (PDT) Received: from localhost ([::1]:50376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSUE-0002pP-6F for importer@patchew.org; Fri, 30 Apr 2021 08:43:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdh-00037K-EE for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cm-SG for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-Pr7SHOhPOhmFdb99dG0eBA-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3D2781E20A; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3732D5B684; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A682C11275F3; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783327; 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=IaqmwRyPHkUwBhT6M0d+2egmb1Zv0ln/tCXglbvxVfM=; b=Qbmjt9TqhqBUHVuNODpJySznZ7x4KSzjbaX5hvJQQe447oLYtiidi7nvDwouRwox40AhJS ayLmKgrzOKD/VTqpRffFprJDPcWSV04/XiVTI3GS4aQ39VyIMel1p5aO8vxmDNMKNgxG3T VrxHCXoWg8TmgLzo2zE61ydJ+mxl2xA= X-MC-Unique: Pr7SHOhPOhmFdb99dG0eBA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 15/25] qapi/expr.py: Add docstrings Date: Fri, 30 Apr 2021 13:48:28 +0200 Message-Id: <20210430114838.2912740-16-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Now with more :words:! Signed-off-by: John Snow Message-Id: <20210421182032.3521476-16-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 256 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 251 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index c33caf00d9..0b66d80842 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # -# Check (context-free) QAPI schema expression structure -# # Copyright IBM, Corp. 2011 # Copyright (c) 2013-2019 Red Hat Inc. # @@ -14,6 +12,24 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 +""" +Normalize and validate (context-free) QAPI schema expression structures. + +`QAPISchemaParser` parses a QAPI schema into abstract syntax trees +consisting of dict, list, str, bool, and int nodes. This module ensures +that these nested structures have the correct type(s) and key(s) where +appropriate for the QAPI context-free grammar. + +The QAPI schema expression language allows for certain syntactic sugar; +this module also handles the normalization process of these nested +structures. + +See `check_exprs` for the main entry point. + +See `schema.QAPISchema` for processing into native Python data +structures and contextual semantic validation. +""" + import re from typing import ( Collection, @@ -39,9 +55,7 @@ _JSONObject =3D Dict[str, object] =20 =20 -# Names consist of letters, digits, -, and _, starting with a letter. -# An experimental name is prefixed with x-. A name of a downstream -# extension is prefixed with __RFQDN_. The latter prefix goes first. +# See check_name_str(), below. valid_name =3D re.compile(r'(__[a-z0-9.-]+_)?' r'(x-)?' r'([a-z][a-z0-9_-]*)$', re.IGNORECASE) @@ -50,11 +64,33 @@ def check_name_is_str(name: object, info: QAPISourceInfo, source: str) -> None: + """ + Ensure that ``name`` is a ``str``. + + :raise QAPISemError: When ``name`` fails validation. + """ if not isinstance(name, str): raise QAPISemError(info, "%s requires a string name" % source) =20 =20 def check_name_str(name: str, info: QAPISourceInfo, source: str) -> str: + """ + Ensure that ``name`` is a valid QAPI name. + + A valid name consists of ASCII letters, digits, ``-``, and ``_``, + starting with a letter. It may be prefixed by a downstream prefix + of the form __RFQDN_, or the experimental prefix ``x-``. If both + prefixes are present, the __RFDQN_ prefix goes first. + + A valid name cannot start with ``q_``, which is reserved. + + :param name: Name to check. + :param info: QAPI schema source file information. + :param source: Error string describing what ``name`` belongs to. + + :raise QAPISemError: When ``name`` fails validation. + :return: The stem of the valid name, with no prefixes. + """ # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty' # and 'q_obj_*' implicit type names. match =3D valid_name.match(name) @@ -64,6 +100,19 @@ def check_name_str(name: str, info: QAPISourceInfo, sou= rce: str) -> str: =20 =20 def check_name_upper(name: str, info: QAPISourceInfo, source: str) -> None: + """ + Ensure that ``name`` is a valid event name. + + This means it must be a valid QAPI name as checked by + `check_name_str()`, but where the stem prohibits lowercase + characters and ``-``. + + :param name: Name to check. + :param info: QAPI schema source file information. + :param source: Error string describing what ``name`` belongs to. + + :raise QAPISemError: When ``name`` fails validation. + """ stem =3D check_name_str(name, info, source) if re.search(r'[a-z-]', stem): raise QAPISemError( @@ -73,6 +122,21 @@ def check_name_upper(name: str, info: QAPISourceInfo, s= ource: str) -> None: def check_name_lower(name: str, info: QAPISourceInfo, source: str, permit_upper: bool =3D False, permit_underscore: bool =3D False) -> None: + """ + Ensure that ``name`` is a valid command or member name. + + This means it must be a valid QAPI name as checked by + `check_name_str()`, but where the stem prohibits uppercase + characters and ``_``. + + :param name: Name to check. + :param info: QAPI schema source file information. + :param source: Error string describing what ``name`` belongs to. + :param permit_upper: Additionally permit uppercase. + :param permit_underscore: Additionally permit ``_``. + + :raise QAPISemError: When ``name`` fails validation. + """ stem =3D check_name_str(name, info, source) if ((not permit_upper and re.search(r'[A-Z]', stem)) or (not permit_underscore and '_' in stem)): @@ -81,12 +145,39 @@ def check_name_lower(name: str, info: QAPISourceInfo, = source: str, =20 =20 def check_name_camel(name: str, info: QAPISourceInfo, source: str) -> None: + """ + Ensure that ``name`` is a valid user-defined type name. + + This means it must be a valid QAPI name as checked by + `check_name_str()`, but where the stem must be in CamelCase. + + :param name: Name to check. + :param info: QAPI schema source file information. + :param source: Error string describing what ``name`` belongs to. + + :raise QAPISemError: When ``name`` fails validation. + """ stem =3D check_name_str(name, info, source) if not re.match(r'[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$', stem): raise QAPISemError(info, "name of %s must use CamelCase" % source) =20 =20 def check_defn_name_str(name: str, info: QAPISourceInfo, meta: str) -> Non= e: + """ + Ensure that ``name`` is a valid definition name. + + Based on the value of ``meta``, this means that: + - 'event' names adhere to `check_name_upper()`. + - 'command' names adhere to `check_name_lower()`. + - Else, meta is a type, and must pass `check_name_camel()`. + These names must not end with ``Kind`` nor ``List``. + + :param name: Name to check. + :param info: QAPI schema source file information. + :param meta: Meta-type name of the QAPI expression. + + :raise QAPISemError: When ``name`` fails validation. + """ if meta =3D=3D 'event': check_name_upper(name, info, meta) elif meta =3D=3D 'command': @@ -105,6 +196,17 @@ def check_keys(value: _JSONObject, source: str, required: Collection[str], optional: Collection[str]) -> None: + """ + Ensure that a dict has a specific set of keys. + + :param value: The dict to check. + :param info: QAPI schema source file information. + :param source: Error string describing this ``value``. + :param required: Keys that *must* be present. + :param optional: Keys that *may* be present. + + :raise QAPISemError: When unknown keys are present. + """ =20 def pprint(elems: Iterable[str]) -> str: return ', '.join("'" + e + "'" for e in sorted(elems)) @@ -127,6 +229,16 @@ def pprint(elems: Iterable[str]) -> str: =20 =20 def check_flags(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Ensure flag members (if present) have valid values. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: + When certain flags have an invalid value, or when + incompatible flags are present. + """ for key in ['gen', 'success-response']: if key in expr and expr[key] is not False: raise QAPISemError( @@ -145,7 +257,25 @@ def check_flags(expr: _JSONObject, info: QAPISourceInf= o) -> None: =20 =20 def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None: + """ + Normalize and validate the ``if`` member of an object. =20 + The ``if`` member may be either a ``str`` or a ``List[str]``. + A ``str`` value will be normalized to ``List[str]``. + + :forms: + :sugared: ``Union[str, List[str]]`` + :canonical: ``List[str]`` + + :param expr: The expression containing the ``if`` member to validate. + :param info: QAPI schema source file information. + :param source: Error string describing ``expr``. + + :raise QAPISemError: + When the "if" member fails validation, or when there are no + non-empty conditions. + :return: None, ``expr`` is normalized in-place as needed. + """ ifcond =3D expr.get('if') if ifcond is None: return @@ -172,6 +302,21 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, = source: str) -> None: =20 =20 def normalize_members(members: object) -> None: + """ + Normalize a "members" value. + + If ``members`` is a dict, for every value in that dict, if that + value is not itself already a dict, normalize it to + ``{'type': value}``. + + :forms: + :sugared: ``Dict[str, Union[str, TypeRef]]`` + :canonical: ``Dict[str, TypeRef]`` + + :param members: The members value to normalize. + + :return: None, ``members`` is normalized in-place as needed. + """ if isinstance(members, dict): for key, arg in members.items(): if isinstance(arg, dict): @@ -184,6 +329,26 @@ def check_type(value: Optional[object], source: str, allow_array: bool =3D False, allow_dict: Union[bool, str] =3D False) -> None: + """ + Normalize and validate the QAPI type of ``value``. + + Python types of ``str`` or ``None`` are always allowed. + + :param value: The value to check. + :param info: QAPI schema source file information. + :param source: Error string describing this ``value``. + :param allow_array: + Allow a ``List[str]`` of length 1, which indicates an array of + the type named by the list element. + :param allow_dict: + Allow a dict. Its members can be struct type members or union + branches. When the value of ``allow_dict`` is in pragma + ``member-name-exceptions``, the dict's keys may violate the + member naming rules. The dict members are normalized in place. + + :raise QAPISemError: When ``value`` fails validation. + :return: None, ``value`` is normalized in-place as needed. + """ if value is None: return =20 @@ -232,6 +397,22 @@ def check_type(value: Optional[object], =20 def check_features(features: Optional[object], info: QAPISourceInfo) -> None: + """ + Normalize and validate the ``features`` member. + + ``features`` may be a ``list`` of either ``str`` or ``dict``. + Any ``str`` element will be normalized to ``{'name': element}``. + + :forms: + :sugared: ``List[Union[str, Feature]]`` + :canonical: ``List[Feature]`` + + :param features: The features member value to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: When ``features`` fails validation. + :return: None, ``features`` is normalized in-place as needed. + """ if features is None: return if not isinstance(features, list): @@ -249,6 +430,15 @@ def check_features(features: Optional[object], =20 =20 def check_enum(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Normalize and validate this expression as an ``enum`` definition. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: When ``expr`` is not a valid ``enum``. + :return: None, ``expr`` is normalized in-place as needed. + """ name =3D expr['enum'] members =3D expr['data'] prefix =3D expr.get('prefix') @@ -278,6 +468,15 @@ def check_enum(expr: _JSONObject, info: QAPISourceInfo= ) -> None: =20 =20 def check_struct(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Normalize and validate this expression as a ``struct`` definition. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: When ``expr`` is not a valid ``struct``. + :return: None, ``expr`` is normalized in-place as needed. + """ name =3D cast(str, expr['struct']) # Checked in check_exprs members =3D expr['data'] =20 @@ -286,6 +485,15 @@ def check_struct(expr: _JSONObject, info: QAPISourceIn= fo) -> None: =20 =20 def check_union(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Normalize and validate this expression as a ``union`` definition. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: when ``expr`` is not a valid ``union``. + :return: None, ``expr`` is normalized in-place as needed. + """ name =3D cast(str, expr['union']) # Checked in check_exprs base =3D expr.get('base') discriminator =3D expr.get('discriminator') @@ -314,6 +522,15 @@ def check_union(expr: _JSONObject, info: QAPISourceInf= o) -> None: =20 =20 def check_alternate(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Normalize and validate this expression as an ``alternate`` definition. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: When ``expr`` is not a valid ``alternate``. + :return: None, ``expr`` is normalized in-place as needed. + """ members =3D expr['data'] =20 if not members: @@ -331,6 +548,15 @@ def check_alternate(expr: _JSONObject, info: QAPISourc= eInfo) -> None: =20 =20 def check_command(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Normalize and validate this expression as a ``command`` definition. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: When ``expr`` is not a valid ``command``. + :return: None, ``expr`` is normalized in-place as needed. + """ args =3D expr.get('data') rets =3D expr.get('returns') boxed =3D expr.get('boxed', False) @@ -342,6 +568,15 @@ def check_command(expr: _JSONObject, info: QAPISourceI= nfo) -> None: =20 =20 def check_event(expr: _JSONObject, info: QAPISourceInfo) -> None: + """ + Normalize and validate this expression as an ``event`` definition. + + :param expr: The expression to validate. + :param info: QAPI schema source file information. + + :raise QAPISemError: When ``expr`` is not a valid ``event``. + :return: None, ``expr`` is normalized in-place as needed. + """ args =3D expr.get('data') boxed =3D expr.get('boxed', False) =20 @@ -351,6 +586,17 @@ def check_event(expr: _JSONObject, info: QAPISourceInf= o) -> None: =20 =20 def check_exprs(exprs: List[_JSONObject]) -> List[_JSONObject]: + """ + Validate and normalize a list of parsed QAPI schema expressions. + + This function accepts a list of expressions and metadata as returned + by the parser. It destructively normalizes the expressions in-place. + + :param exprs: The list of expressions to normalize and validate. + + :raise QAPISemError: When any expression fails validation. + :return: The same list of expressions (now modified). + """ for expr_elem in exprs: # Expression assert isinstance(expr_elem['expr'], dict) --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619788679; cv=none; d=zohomail.com; s=zohoarc; b=X+URDf/bgIHs/XDIgOaH8brFG43IyDzkh1LN/okGeiee7SAvwIMIccCs+s9HjIU4or9VSRWMpiH+5bzJYL2wHKoOLIk58d0FumSVhUncqx/9lxSZdq4EsxpX1qRNd+Xu0/tZWKVEeRO09NzPcwjF0nRSobRsBK/p+caWylXsFO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619788679; 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=X6NpMhuJWOQOimDlzB0elciEPqzf6UsQgc/SRXrByP8=; b=laCMTQfIG22eOwOKad23H6vsywF9ypl9BS9/X6F1PX5XfX+67gosdFIUMO8+VknZ1NhQ8uh9EmXvtV/MlDS/Cy6rpw+m0XvpZ9eB/j9ZhOsON4n6RuPTMishv8riS9qTUOtsSx1KJYqm1gUeeICMRUQ6t9LcVZtVXMvaN8YSWC4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619788679871804.8085153832675; Fri, 30 Apr 2021 06:17:59 -0700 (PDT) Received: from localhost ([::1]:34624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcT1q-0001oJ-K6 for importer@patchew.org; Fri, 30 Apr 2021 09:17:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdd-0002yU-TS for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cb-QK for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-hLpi1VviO8SFqlCQoA-12Q-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CDDB81CEFC; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39ABD5D9C6; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A9E8F11268A2; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783326; 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=X6NpMhuJWOQOimDlzB0elciEPqzf6UsQgc/SRXrByP8=; b=MPB4tuKUGk+02nq4wTH5tU3ougpwZCiSqvEDz3JrUVBYE7lWQ/91eI8zbFNAW9etcwptAu tqFJCCkd8B2qWU8qrFCChGV5ZkYGyu+IUT7gWcgTI0j6xfEYUnaa7RyX5QEIh7zEzC7hNY 7PGqQ+NFtpdUHQzOxE+udhZScN4IiK4= X-MC-Unique: hLpi1VviO8SFqlCQoA-12Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 16/25] qapi/expr.py: Use tuples instead of lists for static data Date: Fri, 30 Apr 2021 13:48:29 +0200 Message-Id: <20210430114838.2912740-17-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow It is -- maybe -- possibly -- three nanoseconds faster. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Message-Id: <20210421182032.3521476-17-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 0b66d80842..225a82e20d 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -239,11 +239,11 @@ def check_flags(expr: _JSONObject, info: QAPISourceIn= fo) -> None: When certain flags have an invalid value, or when incompatible flags are present. """ - for key in ['gen', 'success-response']: + for key in ('gen', 'success-response'): if key in expr and expr[key] is not False: raise QAPISemError( info, "flag '%s' may only use false value" % key) - for key in ['boxed', 'allow-oob', 'allow-preconfig', 'coroutine']: + for key in ('boxed', 'allow-oob', 'allow-preconfig', 'coroutine'): if key in expr and expr[key] is not True: raise QAPISemError( info, "flag '%s' may only use true value" % key) --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619786753; cv=none; d=zohomail.com; s=zohoarc; b=Pt40CYO1rf6bDoBRRJBdC9yoGhRC8+4mCs7m8JobfosI3kKlGcQOsSCXAXQYCGaujMBYDuWRrHU7Vb+tIjQ3C/VhCRYHTsblBVfUmgepn9JyZ2eM/5dLEiSadAxIwOP+DUCUzlrMp3Ttm/ZYRecjURqEqs1CkbhXDPuh094lrTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619786753; 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=LUrr7xlM4q9cZFthCQUZLMCa2hMQaEW2oGNCSJDPoLU=; b=MSX8GGhdNjIRYLwRxWz0D5O8VRLOe1KpI3pocAW5Xde4OCDY1qvUCWvHZqC2LRVG1XXBuagGQ7+auhxtvabCHt6Jwg1DtShjfJ601Etf6VTTSjGN8+VkDtt63esAdXmhQ1OGZNaGpRKEXdsoVNL0U2ymhZvc9fNzcfwzCOGy9RQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619786753620925.3988898590387; Fri, 30 Apr 2021 05:45:53 -0700 (PDT) Received: from localhost ([::1]:59090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSWm-0006Mc-D3 for importer@patchew.org; Fri, 30 Apr 2021 08:45:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdh-00037u-M4 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cW-SI for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-33bMOSaTP1agqPfRfrp6HA-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CB8C18B9EA1; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39B275D9D7; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id ADBF911268B3; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783326; 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=LUrr7xlM4q9cZFthCQUZLMCa2hMQaEW2oGNCSJDPoLU=; b=KSFK6Yn7zD6z8dOUxkgFavq+0b5/sD5hF5iCCioZPEXi+rBnJy66JwHo8mDusZLJkjsqSK SGIx8ylnqZfX+PRs5hOMqnooUWEFa9LZkXccTJHS3gIbOvs0g1AlQ075pl5NUHXcMAds+2 Dm2oF6odrCuxRqAzA28XRiFPdDRY910= X-MC-Unique: 33bMOSaTP1agqPfRfrp6HA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 17/25] qapi/expr: Update authorship and copyright information Date: Fri, 30 Apr 2021 13:48:30 +0200 Message-Id: <20210430114838.2912740-18-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: John Snow Signed-off-by: John Snow Message-Id: <20210421182032.3521476-18-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/expr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 225a82e20d..496f7e0333 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # # Copyright IBM, Corp. 2011 -# Copyright (c) 2013-2019 Red Hat Inc. +# Copyright (c) 2013-2021 Red Hat Inc. # # Authors: # Anthony Liguori # Markus Armbruster # Eric Blake # Marc-Andr=C3=A9 Lureau +# John Snow # # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619789554; cv=none; d=zohomail.com; s=zohoarc; b=E1RcOJg4PNurRi2DNvXj/81mXgQiZ3DF4b/wY+c9a7h5H6LNV+fFJUfT2ud3Hmq1YPh4uJqv/xiTPXYaR7906h/VBxaNfJBmEgijdhOcW58dH/8fyGouD2o11dLB4SRtjVet8GA7K4/hvVIJ87ofafMmuBXYH+ofY5MitNLoV/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619789554; 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=mEfHypjQmGDiH9T5GGiqIdq6M5E5GSWw8PmioRJSgZY=; b=V5hCEo6IBTcXoo5/kgaorWSpug0FOinuWU0IR+N2RhQA/WTo/GjKZwOsOsJOfsfz/MTIz04eTAzyV/VEjH451Ol4hVwz9sjsBri2CVUW0H61oZAy7sDdKuyJjicsyiYQ+wsY1bxCSWXe1LCWW3lBPi/r1dhHwnhIZpU4J67ELjw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619789554961988.382920416814; Fri, 30 Apr 2021 06:32:34 -0700 (PDT) Received: from localhost ([::1]:45892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcTFx-0001h8-Q3 for importer@patchew.org; Fri, 30 Apr 2021 09:32:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdj-0003Cq-UG for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0007f5-55 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-8WM3UfooPROohIQFbyG7ZA-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67546800C7A; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3926A60937; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B1EC911268B4; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783329; 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=mEfHypjQmGDiH9T5GGiqIdq6M5E5GSWw8PmioRJSgZY=; b=SQM5n1TxOyK4pITTyCstcNY3GN/BEnlNHTtlYf7rBvnv4jRkt8YDojc5ASctYgyIowFCmN +f4S8Z05loSnBQA2hjxDw83+JDMgaTcqBeLx8mc8jlI/c0s9H6VTQTcL+iP/Fh0fg5suaN UPGe7w+lmMHPXEz7XQrLYV90nUPVvMg= X-MC-Unique: 8WM3UfooPROohIQFbyG7ZA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 18/25] qapi/error: Repurpose QAPIError as an abstract base exception class Date: Fri, 30 Apr 2021 13:48:31 +0200 Message-Id: <20210430114838.2912740-19-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Rename QAPIError to QAPISourceError, and then create a new QAPIError class that serves as the basis for all of our other custom exceptions, without specifying any class properties. This leaves QAPIError as a package-wide error class that's suitable for any current or future errors. (Right now, we don't have any errors that DON'T also want to specify a Source location, but this MAY change. In these cases, a common abstract ancestor would be desired.) Add docstrings to explain the intended function of each error class. Signed-off-by: John Snow Message-Id: <20210421192233.3542904-2-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- docs/sphinx/qapidoc.py | 3 ++- scripts/qapi/error.py | 11 +++++++++-- scripts/qapi/schema.py | 5 +++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index b7a2d39c10..87c67ab23f 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -34,7 +34,8 @@ from sphinx.util.nodes import nested_parse_with_titles import sphinx from qapi.gen import QAPISchemaVisitor -from qapi.schema import QAPIError, QAPISemError, QAPISchema +from qapi.error import QAPIError, QAPISemError +from qapi.schema import QAPISchema =20 =20 # Sphinx up to 1.6 uses AutodocReporter; 1.7 and later diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index ae60d9e2fe..126dda7c9b 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -13,6 +13,11 @@ =20 =20 class QAPIError(Exception): + """Base class for all exceptions from the QAPI package.""" + + +class QAPISourceError(QAPIError): + """Error class for all exceptions identifying a source location.""" def __init__(self, info, col, msg): Exception.__init__(self) self.info =3D info @@ -27,7 +32,8 @@ def __str__(self): return loc + ': ' + self.msg =20 =20 -class QAPIParseError(QAPIError): +class QAPIParseError(QAPISourceError): + """Error class for all QAPI schema parsing errors.""" def __init__(self, parser, msg): col =3D 1 for ch in parser.src[parser.line_pos:parser.pos]: @@ -38,6 +44,7 @@ def __init__(self, parser, msg): super().__init__(parser.info, col, msg) =20 =20 -class QAPISemError(QAPIError): +class QAPISemError(QAPISourceError): + """Error class for semantic QAPI errors.""" def __init__(self, info, msg): super().__init__(info, None, msg) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 703b446fd2..c277fcacc5 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -20,7 +20,7 @@ from typing import Optional =20 from .common import POINTER_SUFFIX, c_name -from .error import QAPIError, QAPISemError +from .error import QAPISemError, QAPISourceError from .expr import check_exprs from .parser import QAPISchemaParser =20 @@ -875,7 +875,8 @@ def _def_entity(self, ent): other_ent =3D self._entity_dict.get(ent.name) if other_ent: if other_ent.info: - where =3D QAPIError(other_ent.info, None, "previous defini= tion") + where =3D QAPISourceError(other_ent.info, None, + "previous definition") raise QAPISemError( ent.info, "'%s' is already defined\n%s" % (ent.name, where)) --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619786404; cv=none; d=zohomail.com; s=zohoarc; b=GPJ/ilfPyXOZLopDNAcx/t8UySxZAy7oroK4gtVapXkD5uUEw7o1unF3nbJUDkkuvWGe1GCMNSDH+7DHRhjUi0EdzxHZTV1T7OG5swUWYN/UrPiYyxpeJ3mdEhaCMXx4e0Z8feFngzkkTDqmuNOeC5naRHZmIDceiyWhM2IpgwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619786404; 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=wHf/VdPlxT2GIRzl59Pi/M0q/6maniPpxRB8d3ulxfI=; b=ajDtY2TVr3OM2GoZ5hsM01CQoTp0Vg5TO6kEBVmCogmf25Co6kToah4HwRXU41yFSDbOxeO57E6K9dsCiT7OQUCEC0Orvsx6AKg2ga91fjV3wLDS1v0xLW+6std+QXhXhFG9S/DxKL3fyaU/Eys8RJyLY5zZY6APHb7dA5VP5CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619786404637666.8685295389816; Fri, 30 Apr 2021 05:40:04 -0700 (PDT) Received: from localhost ([::1]:41744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSR9-0007di-H0 for importer@patchew.org; Fri, 30 Apr 2021 08:40:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdh-00037X-Gy for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdZ-0007ds-6r for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-GIl8nf3zOuqTQY4AX8NfaQ-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B238107ACCA; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C3901724C; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B707411268B9; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783328; 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=wHf/VdPlxT2GIRzl59Pi/M0q/6maniPpxRB8d3ulxfI=; b=XQiz24QsoFAnL8Eigqf+PPl5ST9XTFk6rxRkxmjs/Z1x0fNVCne90Y4bvAVIE1wUu2z/FD /FawXFLAuzJGVjqQ2SEpcoqtpCEXo3Refu9EMi+lalvyFK/OEdqBVQmwJcUdwWn/o4849h /qo656ZC6ztE4dRO15rRAbGyvEk2d0w= X-MC-Unique: GIl8nf3zOuqTQY4AX8NfaQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 19/25] qapi/error: Use Python3-style super() Date: Fri, 30 Apr 2021 13:48:32 +0200 Message-Id: <20210430114838.2912740-20-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Missed in commit 2cae67bcb5 "qapi: Use super() now we have Python 3". Signed-off-by: John Snow Reviewed-by: Markus Armbruster Message-Id: <20210421192233.3542904-3-jsnow@redhat.com> Signed-off-by: Markus Armbruster --- scripts/qapi/error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index 126dda7c9b..38bd7c4dd6 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -19,7 +19,7 @@ class QAPIError(Exception): class QAPISourceError(QAPIError): """Error class for all exceptions identifying a source location.""" def __init__(self, info, col, msg): - Exception.__init__(self) + super().__init__() self.info =3D info self.col =3D col self.msg =3D msg --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619789135; cv=none; d=zohomail.com; s=zohoarc; b=g9q0yIUuEv7oyOIxUoC2/X9H9l3rxHjrDbm6iRKl9zAVtzRqjNK847xtRX+sqSzMGQHHXokjdaIS2bos7uPQ/YYZgfSv3mWr/MkU6I9Xvm2wNVHY0YXv2V6K/ylVP0IukVo7Er1qC+HkJ/qyZgX4aIsZdbAgOqVx5Svq45RUyCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619789135; 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=g6OcT1pIRTkzyuMLuYlD84/27Eczd3vK+NG6JfBu9dY=; b=UNmiqJKWkZsBYunCa0EF99jMDGgFN2PKGFyhMBjxUz1JhguDfKludXpcTY0UkGNU3pa951jCMS41MVJzSZ8DtM8wpeaIWgysS+QErl3n+JMkaQJKDj3npO0vGU9ADB0Pt7DjKsJOoeQgiyxhAJLP3FqNdR3Hz/PKDYGGvu+vMbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619789135156331.487240048334; Fri, 30 Apr 2021 06:25:35 -0700 (PDT) Received: from localhost ([::1]:57406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcT9C-00037p-3T for importer@patchew.org; Fri, 30 Apr 2021 09:25:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdj-0003AX-15 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30117) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0007ev-2v for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-5PCZxb6XMi-nPNrbN_8etA-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B50CA0CB0; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C0461690D; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BCEAA1126833; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783329; 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=g6OcT1pIRTkzyuMLuYlD84/27Eczd3vK+NG6JfBu9dY=; b=ggZIYXGOivr0eTM+CTXM+/KJB88dYitfcsrc5Uhct46rpoBhW5+aoa9rkAwLvKSnHSLkZ9 EEAdwmIrHeW4ZHgvpE28LQGhn5pTe9jDlo2EJ+P2H3R3wqVwqwp54uRGNQixcD2+g3IQOR y4lJXagyNF4QDB2+QnC8m0QgCA+eG7A= X-MC-Unique: 5PCZxb6XMi-nPNrbN_8etA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 20/25] qapi/error: Make QAPISourceError 'col' parameter optional Date: Fri, 30 Apr 2021 13:48:33 +0200 Message-Id: <20210430114838.2912740-21-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow It's already treated as optional, with one direct caller and some subclass callers passing 'None'. Make it officially optional, which requires moving the position of the argument to come after all required parameters. QAPISemError becomes functionally identical to QAPISourceError. Keep the name to preserve its semantic meaning and avoid code churn, but remove the now-useless __init__ wrapper. Signed-off-by: John Snow Message-Id: <20210421192233.3542904-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/error.py | 8 +++----- scripts/qapi/schema.py | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index 38bd7c4dd6..d179a3bd0c 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -18,11 +18,11 @@ class QAPIError(Exception): =20 class QAPISourceError(QAPIError): """Error class for all exceptions identifying a source location.""" - def __init__(self, info, col, msg): + def __init__(self, info, msg, col=3DNone): super().__init__() self.info =3D info - self.col =3D col self.msg =3D msg + self.col =3D col =20 def __str__(self): loc =3D str(self.info) @@ -41,10 +41,8 @@ def __init__(self, parser, msg): col =3D (col + 7) % 8 + 1 else: col +=3D 1 - super().__init__(parser.info, col, msg) + super().__init__(parser.info, msg, col) =20 =20 class QAPISemError(QAPISourceError): """Error class for semantic QAPI errors.""" - def __init__(self, info, msg): - super().__init__(info, None, msg) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index c277fcacc5..3a4172fb74 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -875,8 +875,7 @@ def _def_entity(self, ent): other_ent =3D self._entity_dict.get(ent.name) if other_ent: if other_ent.info: - where =3D QAPISourceError(other_ent.info, None, - "previous definition") + where =3D QAPISourceError(other_ent.info, "previous defini= tion") raise QAPISemError( ent.info, "'%s' is already defined\n%s" % (ent.name, where)) --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787084; cv=none; d=zohomail.com; s=zohoarc; b=ZNpPebuH8Ux5GjPClRtVgegy2mpjoXXx2CATAYh9b0dwslZKMQAJ9Sc0zjNXVg9TtHXnPl8LpAn0zqR9riQPzeEnMqbkpDnH3UxxBpbnP+FCnd5DVsAGnT44vhpyggQzUjI4RuOP5x14SdxMcKIjGo9h/gVOF1Mh3NZxu36tQc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787084; 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=dvzxiwWIiJfK3zjc8szVz6zobSb0IjOU8jD+7ZTfsCE=; b=Z17gJ78ZsnFLP/8s1l6Y67YIdY1WpV91PCyBf5rb+3N7WQYL7ai3qPJOVScXQ0EIX7Ema2d99QlhXSSUDaRCuXvCWiChZkaYTBmL5yE2QU7f2vmxTZLnOAvXonRSuPTfiLHioituhFBTuFM0/fVHw57XkdEEy3P2iEawfsnq/VA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787084272875.680172003587; Fri, 30 Apr 2021 05:51:24 -0700 (PDT) Received: from localhost ([::1]:47896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSc7-000587-8b for importer@patchew.org; Fri, 30 Apr 2021 08:51:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdj-0003BZ-Dv for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0007f1-55 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-uFMdQoc2O7653-zGwOoU4w-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6ABD68015D5; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BAC013470; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C216C112683F; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783329; 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=dvzxiwWIiJfK3zjc8szVz6zobSb0IjOU8jD+7ZTfsCE=; b=ckMwK3ayMx8gTClgEYXzylLve/3u8/9roJyAmebcCX3Ii4rFYKtGRc6SMhSGzWUxTJonPh NPOJUnl/WSbcDD5FKA+JA4/cTyXcsX8JIsv97oPALZRptKCxLQw6JKXGxE9cvlCtjvRrDy dhokCh+JikznhUcnstFHXf7Rq605Gq4= X-MC-Unique: uFMdQoc2O7653-zGwOoU4w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 21/25] qapi/error: assert QAPISourceInfo is not None Date: Fri, 30 Apr 2021 13:48:34 +0200 Message-Id: <20210430114838.2912740-22-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Built-in stuff is not parsed from a source file, and therefore have no QAPISourceInfo. If such None info was used for reporting an error, built-in stuff would be broken. Programming error. Instead of reporting a confusing error with bogus source location then, we better crash. We currently crash only if self.col was set. Assert that self.info is not None in order to crash reliably. We can not yet change the type of the initializer to prove this cannot happen at static analysis time before the remainder of the code is fully typed. Signed-off-by: John Snow Message-Id: <20210421192233.3542904-5-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/error.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index d179a3bd0c..d0bc7af6e7 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -25,6 +25,7 @@ def __init__(self, info, msg, col=3DNone): self.col =3D col =20 def __str__(self): + assert self.info is not None loc =3D str(self.info) if self.col is not None: assert self.info.line is not None --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619786930; cv=none; d=zohomail.com; s=zohoarc; b=kun+/GI56mrVR8dsLUsFzuXd6zc5OM1XRFjN2V4cnlMfz6eB+posd4XK2FxEjsbcDAmc25s6K2llcfNaP308V2omN43ZGHQ8DZ3eBpAd2QVyQVw4xjKmuYpgPQ4fZB+1WRCuZp3yTTHGrAVrL2eIHcyWFoNSeDuN59TgBqr414E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619786930; 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=Q7MwkBRcS4OYnctBGXwpmy9Ekf252cnk2QdcqynuEs4=; b=mVqWuahAQvk4HXy2Z9YohcNBb+TnDj+hye3rcgYE68SRfgVKCm8zHBp1SuHmLFIrmRuCeu2ZIZkm39mTlwQ15YApT4411Z1xPxWHpiNxmDDc/cCBhh+fHqxYBSZWQqV26W1tvrygEZzwdV7d2Mr6KvDp0ixAwjV+LpnAUtLf/CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619786930722541.6224015762424; Fri, 30 Apr 2021 05:48:50 -0700 (PDT) Received: from localhost ([::1]:39406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSZb-0001Un-WF for importer@patchew.org; Fri, 30 Apr 2021 08:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdj-0003As-5n for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36499) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0007f4-8t for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-BOZGt-R6Py6-foJilpUu_A-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CA4D107ACE6; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E3765F707; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C888E1125643; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783329; 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=Q7MwkBRcS4OYnctBGXwpmy9Ekf252cnk2QdcqynuEs4=; b=hWYwlldkY+cFWLAbSc/4QMtwQ1YNmax8X21K0imNOnbevqJilucYt2IzF08caT/aF0BOiA 96JHDJsl8y+YNwA5/B+mHu2Kvne37HZkse+WrEtpbJ8SgI2VBjEPnLfMlb9DuTajstx3JY uXHgSnl6VKlXwC8u5kxXC6CsWDu2/ck= X-MC-Unique: BOZGt-R6Py6-foJilpUu_A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 22/25] qapi/error.py: move QAPIParseError to parser.py Date: Fri, 30 Apr 2021 13:48:35 +0200 Message-Id: <20210430114838.2912740-23-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Keeping it in error.py will create some cyclic import problems when we add types to the QAPISchemaParser. Callers don't need to know the details of QAPIParseError unless they are parsing or dealing directly with the parser, so this won't create any harsh new requirements for callers in the general case. Update error.py with a little docstring that gives a nod to where the error may now be found. Signed-off-by: John Snow Message-Id: <20210421192233.3542904-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/error.py | 22 ++++++++-------------- scripts/qapi/parser.py | 14 +++++++++++++- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index d0bc7af6e7..6723c5a9d9 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # -# QAPI error classes -# # Copyright (c) 2017-2019 Red Hat Inc. # # Authors: @@ -11,6 +9,14 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 +""" +QAPI error classes + +Common error classes used throughout the package. Additional errors may +be defined in other modules. At present, `QAPIParseError` is defined in +parser.py. +""" + =20 class QAPIError(Exception): """Base class for all exceptions from the QAPI package.""" @@ -33,17 +39,5 @@ def __str__(self): return loc + ': ' + self.msg =20 =20 -class QAPIParseError(QAPISourceError): - """Error class for all QAPI schema parsing errors.""" - def __init__(self, parser, msg): - col =3D 1 - for ch in parser.src[parser.line_pos:parser.pos]: - if ch =3D=3D '\t': - col =3D (col + 7) % 8 + 1 - else: - col +=3D 1 - super().__init__(parser.info, msg, col) - - class QAPISemError(QAPISourceError): """Error class for semantic QAPI errors.""" diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 58267c3db9..ca5e8e18e0 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -18,10 +18,22 @@ import os import re =20 -from .error import QAPIParseError, QAPISemError +from .error import QAPISemError, QAPISourceError from .source import QAPISourceInfo =20 =20 +class QAPIParseError(QAPISourceError): + """Error class for all QAPI schema parsing errors.""" + def __init__(self, parser, msg): + col =3D 1 + for ch in parser.src[parser.line_pos:parser.pos]: + if ch =3D=3D '\t': + col =3D (col + 7) % 8 + 1 + else: + col +=3D 1 + super().__init__(parser.info, msg, col) + + class QAPISchemaParser: =20 def __init__(self, fname, previously_included=3DNone, incl_info=3DNone= ): --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619789036; cv=none; d=zohomail.com; s=zohoarc; b=XV0b7RD2giP8u7yh018E1Im3pc1aHnL1l15w3Ya03HRHLExFzY3riKqow79LnLvm+13wVqmtpJaA7d1FzJKI6VmAInTw9qGRhapdQKKhiP8Y3v9kv1RwZybCSLnNlNMHIkqVA5L+dFDt2/ZHgTsbEgU7DnwNvh52UW5RhixVK5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619789036; 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=iBg/ym/n45oHP1aQyKX21kkURKZniK0VAYPgZT1QO8k=; b=hiWQIbiGfg2JXT7Ss21rkFmMoHy3rFcLlN9YPTKi5WBlNMZyZW880pmQtNQezGJ23tJbjMmCqDRjuZryPjJYl0f2HPjJe6eybcWWUvQX1LSZeRQZveZHhZvekKWRkxdJftXFhS+TXWcP6WZx60wyyCsFV84York7y6e+2dK/GkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619789036606449.21525004414787; Fri, 30 Apr 2021 06:23:56 -0700 (PDT) Received: from localhost ([::1]:50846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcT7a-0000P2-Kd for importer@patchew.org; Fri, 30 Apr 2021 09:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdi-00039V-A6 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007cY-SE for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-t52yDZG0POmmbkLns9lG3Q-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CB7DA0CB1; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3ED3F5B685; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CFDC81125648; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783326; 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=iBg/ym/n45oHP1aQyKX21kkURKZniK0VAYPgZT1QO8k=; b=TRZttye3T8Q3cyOkgGnrwo+eCbSUE8A/Xn59i4oWZu/3XiMBcXBY3lG68YVL2ZndUazOpQ GiFSzXDoTe8vrdOXhobnSiJasqS71WFgC8gZihrYKiLyHBvyu5NrZ2G61UrO48b9Jh9eoe MndLwbBlHwBOSQp/L77f0WnCx7QBwHk= X-MC-Unique: t52yDZG0POmmbkLns9lG3Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 23/25] qapi/error.py: enable pylint checks Date: Fri, 30 Apr 2021 13:48:36 +0200 Message-Id: <20210430114838.2912740-24-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Signed-off-by: John Snow Message-Id: <20210421192233.3542904-7-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/pylintrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index fb0386d529..88efbf71cb 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -2,8 +2,7 @@ =20 # Add files or directories matching the regex patterns to the ignore list. # The regex matches against base names, not paths. -ignore-patterns=3Derror.py, - parser.py, +ignore-patterns=3Dparser.py, schema.py, =20 =20 --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619789370; cv=none; d=zohomail.com; s=zohoarc; b=XQm69jZuTU9MolkRnlZAMELj52IAqgvzFayX+ltni+U6RryLSnptiL24CyjN3ZRRqBtkRifj4I/vevFXhl346tnDJsGoj4ll8FJdeIj3HUcxQUafHd+a1GEXfvD92ZOpauopsK/zS13veNOgzDNyOlqHj6+o/rvYHufcGyB4pDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619789370; 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=HK9Am/s++cp+DYjcueL/EURRsL0Cdh4+c8/C8808Ovo=; b=WhjFZ5qCtX6ILfc5BT3HtH85OB+DCkQkK9BOaI09N17tGL8AZ43qWC714Y+1r3Yx8uMSZKWvRa5wKkdJtMbTzaEiZx2ZhfvdDtWqehiwYDoKAsouiY1swsUH+VxZrEgxE5itJoFn0mezBz4RBU0PEj0NbJ6BFJInxOpxhpP5YPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619789370431758.7133358867101; Fri, 30 Apr 2021 06:29:30 -0700 (PDT) Received: from localhost ([::1]:37470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcTCy-0006cF-7Q for importer@patchew.org; Fri, 30 Apr 2021 09:29:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdj-0003CU-Nf for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRda-0007fE-B4 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-ZcqdUDNvOo6fLFvk8h873Q-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74819A0CB2; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43EDC1007607; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D6AC01125649; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783329; 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=HK9Am/s++cp+DYjcueL/EURRsL0Cdh4+c8/C8808Ovo=; b=X8fguWqep9145UnuMkXSq9UV4iHxw0oScLQOSdIKrBPPnovPt+Gy0tA2B97btQeyzaX/8F L3mm0vdutzXQXzaip2a53qO0JU+M3xVa08eDRYzs1/sWJnECPkm0gufJkiBAjK+nTic1Zy 6DispIa0KsX6v7Fg0YEJCvQpZH4YJIs= X-MC-Unique: ZcqdUDNvOo6fLFvk8h873Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 24/25] qapi/error: Add type hints Date: Fri, 30 Apr 2021 13:48:37 +0200 Message-Id: <20210430114838.2912740-25-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow No functional change. Note: QAPISourceError's info parameter is Optional[] because schema.py treats the info property of its various classes as Optional to accommodate built-in types, which have no source. See prior commit 'qapi/error: assert QAPISourceInfo is not None'. Signed-off-by: John Snow Message-Id: <20210421192233.3542904-8-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/error.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index 6723c5a9d9..e35e4ddb26 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -17,6 +17,10 @@ parser.py. """ =20 +from typing import Optional + +from .source import QAPISourceInfo + =20 class QAPIError(Exception): """Base class for all exceptions from the QAPI package.""" @@ -24,13 +28,16 @@ class QAPIError(Exception): =20 class QAPISourceError(QAPIError): """Error class for all exceptions identifying a source location.""" - def __init__(self, info, msg, col=3DNone): + def __init__(self, + info: Optional[QAPISourceInfo], + msg: str, + col: Optional[int] =3D None): super().__init__() self.info =3D info self.msg =3D msg self.col =3D col =20 - def __str__(self): + def __str__(self) -> str: assert self.info is not None loc =3D str(self.info) if self.col is not None: --=20 2.26.3 From nobody Sat May 18 03:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619787503; cv=none; d=zohomail.com; s=zohoarc; b=nUdoRAbyvwGHPs8JPjXV1FiHEGFnr86cTjIiqNQAAhnaFCBhqWTxXziyD+vNaYVTSmi8oqHFTr9/zG6mBjnq9XBm1ZJatg4+E8DaHG9rRyySPKzS7DstLQVbSYg81vzTes8o2g1CsKk/MxmGGz0s3wRqdfPvaBy577xdg+x1gPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619787503; 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=RaIM/FHktTkX4B1ZVJiIbLVXSjdkCEehUrVXC9OM5GU=; b=ZZqJLdwiHGJ/U1gyWpjloz6SYZyMY6OYvUhONifjl7LuRdpJLVqdrsSuv66802Fg/+aUjaPbB0a2ebpBCUQfktXx1dGJ4Uv+Tt+JXD+FQSsNPPCyBdjPuCeEptxxSNso/L6GD7shf4By1OZzU3m1y+vmQt6xNdHRZ5ZxIAEtMlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619787503562679.6245158853702; Fri, 30 Apr 2021 05:58:23 -0700 (PDT) Received: from localhost ([::1]:44370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcSis-0006z3-By for importer@patchew.org; Fri, 30 Apr 2021 08:58:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdf-00031u-EO for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcRdX-0007ch-Nu for qemu-devel@nongnu.org; Fri, 30 Apr 2021 07:48:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-HZaSauuuPK622ewHLxpoMw-1; Fri, 30 Apr 2021 07:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 735BF10066E8; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 441F016923; Fri, 30 Apr 2021 11:48:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DDF06112564A; Fri, 30 Apr 2021 13:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619783326; 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=RaIM/FHktTkX4B1ZVJiIbLVXSjdkCEehUrVXC9OM5GU=; b=iD9CBfQEc3tVrY78oIIrhQ6uVqVJrlRQXX6iZoU2C0C6pWuNK6VjGmq5X5qA92UeAEv85l YZZg1Lzk5KSZioDmRs60uBbVIw/Ix8ZI5wptjpb1Lo/UA2LpGGgvDqLxuo89KWHRpoTU0j YWmaSd8wAc3rR5Y6gYs63Fi70WIwt/U= X-MC-Unique: HZaSauuuPK622ewHLxpoMw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 25/25] qapi/error.py: enable mypy checks Date: Fri, 30 Apr 2021 13:48:38 +0200 Message-Id: <20210430114838.2912740-26-armbru@redhat.com> In-Reply-To: <20210430114838.2912740-1-armbru@redhat.com> References: <20210430114838.2912740-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Signed-off-by: John Snow Message-Id: <20210421192233.3542904-9-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/mypy.ini | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 7797c83432..54ca4483d6 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -3,11 +3,6 @@ strict =3D True disallow_untyped_calls =3D False python_version =3D 3.6 =20 -[mypy-qapi.error] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.parser] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False --=20 2.26.3