From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617125060; cv=none; d=zohomail.com; s=zohoarc; b=Ux37FF+Ko9xqGLDLQiMtz0dgOHsp1U0FN4XevKlplqOJHxGsj0Tzei7qFgaAFmgOtzsmHoU8ICzmI7ClwV/xN1y9+s9I7/aHGEWR5dNYENMBVthNo0QbfrOIiC8AAU0QK0fZfvbmkGsB25b1xVedCbdGptVgoXA0RrroE1UTWmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617125060; 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=tXrsww6zU1KZ7+CwRwV7pqErVi6LOxARsOF0HRvkXI8=; b=jDjHciGnSTRw7GAaIgy2er2QJkQ2ToUNbFwpto70UvyOoUAmeoaoYqQt6v4NYzEWSUsmD0Se9ZcD0bXEqUweaYZt8gMv3QVsn18TZ2837WwG9RbenaUy8DCCN23ePoxj3rPTxu2n/GKzgmHxpO8aywYWlKvkEO3tz8vk6CL7wkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617125060269298.18847197484604; Tue, 30 Mar 2021 10:24:20 -0700 (PDT) Received: from localhost ([::1]:59940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI6F-0005mg-2D for importer@patchew.org; Tue, 30 Mar 2021 13:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1C-0000Il-3E for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI10-0003Wt-5I for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:05 -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-526-uQNBvtOVOASaYEjwYgMJOg-1; Tue, 30 Mar 2021 13:18:48 -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 8F7981005D4F; Tue, 30 Mar 2021 17:18:47 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF89E60CD7; Tue, 30 Mar 2021 17:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124732; 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=tXrsww6zU1KZ7+CwRwV7pqErVi6LOxARsOF0HRvkXI8=; b=gqGWiGAKXzgcZ0Awj71XZ4d8BKZIhOjNODAWJlEzqjLUpGof0nijRDnOtHb85SSfvYYgfO Dl0vVQD8S8egRb5SGlsAIg4s2CXL8xB9G6Srom95qCR4kEXT8h56t7yOcUo3ggsUcftNKN sKrUIhtiSezQ3lzYBjjFgFR5fykWUE4= X-MC-Unique: uQNBvtOVOASaYEjwYgMJOg-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 1/8] qapi/error: Repurpose QAPIError as a generic exception base class Date: Tue, 30 Mar 2021 13:18:37 -0400 Message-Id: <20210330171844.1197918-2-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Rename QAPIError to QAPISourceError, and then create a new QAPIError class that serves as the basis for all of our other custom exceptions. Add docstrings to explain the intended function of each error class. Signed-off-by: John Snow --- 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 b7b86b5dff..458b1f477e 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 01cdd753cd..1849c3e45f 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 @@ -878,7 +878,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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617124904; cv=none; d=zohomail.com; s=zohoarc; b=XFAj6229j7dn6BGDMg/1hrTdEc81CPruUBmivbBRKtIe2gLjfWU4p7swFPGVNu3mw7OCp7l9RT/fcxIu6l69KueUSzO43sk1ZMHwmDYvIpkrQP58G6R81ip+eXAShbEKVJAa/z72iB0XqkKyxxmETBzW9HHPX+eBK/qf1WtTX1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617124904; 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=uTJh8wwABPHJt0QcIYVBGq4Be28vbdcsgYXMbbo+OWI=; b=Sh6ecKr0RhLEe49qH7bfB8K/eQyVjrPh5cCP/bJJrshJHlzhG4/XXVmfoFOhh3//GvgG6TmYv2JGxKn2VaaFh+5Pq3ob5feQbtdqmfN4bbaQorFNdVQgpuE4leGLPhWPWSgnjqcif44ksDMT7qo7tyNPKeUXQ1w/L61FhKMpFWo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617124904360182.00910855692496; Tue, 30 Mar 2021 10:21:44 -0700 (PDT) Received: from localhost ([::1]:51354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI3i-0002CY-5K for importer@patchew.org; Tue, 30 Mar 2021 13:21:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1A-0000IO-O0 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38225) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI0z-0003Wp-Fi for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:04 -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-319-A45wsFosN2e1s2LE6FZPXQ-1; Tue, 30 Mar 2021 13:18:50 -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 A7B7D18C8C11; Tue, 30 Mar 2021 17:18:48 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEA9E60861; Tue, 30 Mar 2021 17:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124732; 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=uTJh8wwABPHJt0QcIYVBGq4Be28vbdcsgYXMbbo+OWI=; b=Spaad34ZQ1cmn9ec40gkl9x5fiLJkWW9GDZKLnYtJ5ZAPxYew7a1eB583/tex5PHwe99gc SDM5VrNJu+AN4w5Mu81H+P56ag2x9bGwz/NYy8Cy3Hq7DohBlKIJOZaYuHPRkM2wLdeVR3 VfqG1cTI6KYx0GdhwVILhALMA58b4g8= X-MC-Unique: A45wsFosN2e1s2LE6FZPXQ-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 2/8] qapi/error: Use Python3-style super() Date: Tue, 30 Mar 2021 13:18:38 -0400 Message-Id: <20210330171844.1197918-3-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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=unavailable 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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617125191; cv=none; d=zohomail.com; s=zohoarc; b=XkfXKBav7vMx1Vw+aVX2xr2XS98sJTpZl+lgElYcmVIp/fwkohpeNf1mr8SzQCASR0S0J6tytgK10L+DbEf7l7UdITDVE06NMJmMbDS2ANM+z6LxgnP9IFU18gmBQ8qaai0h5J2xI+nbkl1UzlnkuHCFPSM2YLOVzio7zi3oqU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617125191; 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=VLhOpDZ5KoMONYdgU/kg5BWAuuPKYn7GxOoOsYDu6Ew=; b=klzWqmIVW2BLzVabyX2xPMzk8fs9h2uRYiFcL6sq5q9Zy/ggwLvhX0N/Ft7azCZYsmDrp3EVNvM3bcD+LNTs5ja8+TEC5E1PiDaALrSdPbTwLGpE2JPc0vPjfkbmExgU8MyyqWDx893vBgNqqaTeM4e+RVKcljcjnl2bns3NQCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617125191951895.9545465659336; Tue, 30 Mar 2021 10:26:31 -0700 (PDT) Received: from localhost ([::1]:39140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI8M-0000Sx-5N for importer@patchew.org; Tue, 30 Mar 2021 13:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1D-0000J4-3N for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI18-0003Yb-4B for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:06 -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-164-tt_8_CqrOkiqJ2G79G8qtA-1; Tue, 30 Mar 2021 13:18:51 -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 7AB528006E; Tue, 30 Mar 2021 17:18:50 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id E496560861; Tue, 30 Mar 2021 17:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124735; 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=VLhOpDZ5KoMONYdgU/kg5BWAuuPKYn7GxOoOsYDu6Ew=; b=CN0s0mGaPr0GuoASoRCmoeF0HqowJ1dQPGmjs6cjHU1zVU3irwh3Zf7BJsj1MCVfQF9e/F YpW+Sz02TQco1xsoWmCMqhmfjGGHfBlrsTSZHb3jLhAWblLgm5OS21fGvyeyoS10aOWW4k q4R8QdeY4808IA1/SfdxZTansqRlQqU= X-MC-Unique: tt_8_CqrOkiqJ2G79G8qtA-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 3/8] qapi/error: Make QAPISourceError 'col' parameter optional Date: Tue, 30 Mar 2021 13:18:39 -0400 Message-Id: <20210330171844.1197918-4-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It's already treated as optional, with some callers and subclasses 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 --- 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 1849c3e45f..dcf8a86139 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -878,8 +878,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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617125059; cv=none; d=zohomail.com; s=zohoarc; b=fP0tsPKCjHgiRIqG6JkQQkZ3/Qon+KPklIdbYsrWupQR/6I5I40uGOp2GOiBQoBfdspov/tSidvXMvTg6eDJIt5Rjub0XB87Ehe8Xr+cJh/iTEcbeYJpEdjs47LAvFQytKL77J2xdcreSEo+ng4tubfoRlxFSAgV4HbSGOBFIS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617125059; 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=/Zs7bJ9iCN+tCvPmX1K3cDzPWx5yizxLZ7/b1MG1C1g=; b=jsLZ6z+3TcHNoGWDQ4+kyLA+6Qvlqh7x6kWV+aj2vFoMjVMroO0j6oaeMwCw8QQaeNYVeAKWWtga1jaJQkeOq2guqJlMh/elf6f+VQw2Ib512PWKPyKXrSUVVO9AqYZ5dITEbjKFQQmldgeJlT3lasJ049wESu87NKH52WF0KVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617125059904515.062546570691; Tue, 30 Mar 2021 10:24:19 -0700 (PDT) Received: from localhost ([::1]:59986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI6E-0005nj-O4 for importer@patchew.org; Tue, 30 Mar 2021 13:24:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1C-0000In-5U for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI13-0003YR-9P for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:05 -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-496-pX5Bj7JgMW2yaORBEtHi7Q-1; Tue, 30 Mar 2021 13:18:52 -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 EC91D18C8C01; Tue, 30 Mar 2021 17:18:51 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDB1060861; Tue, 30 Mar 2021 17:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124735; 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=/Zs7bJ9iCN+tCvPmX1K3cDzPWx5yizxLZ7/b1MG1C1g=; b=QkXyaa+81/jJ/j9uStPQjWMUKN9GHFeX3qpX1Z/pDq77EDg/ZYagWnFk4QzGvHLhqhZD6D 8B/oQWFGCSiAuyAemzrBxeOz72loP3ujuIO9nA4oE5lKNzCcU/Mb9g65nyyUVQd3YWMOcK FlEBfNRPZG3gjSSz8b6119n8o2QitI0= X-MC-Unique: pX5Bj7JgMW2yaORBEtHi7Q-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 4/8] qapi/error: Change assertion Date: Tue, 30 Mar 2021 13:18:40 -0400 Message-Id: <20210330171844.1197918-5-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Eventually, we'll be able to prove that 'info.line' must be an int and is never None at static analysis time, and this assert can go away. Until then, it's a type error to assume that self.info is not None. Signed-off-by: John Snow --- 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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617125268; cv=none; d=zohomail.com; s=zohoarc; b=SJtekvY50pv+uqvqRaVCS3cG+xhuIQU0TCId/vn6DF35sFX4WSrknVzJi4DnWYab6oNpSXO7+jzLSHujNr2HmaA8xdB4SgFYSKZPnRoaVyn5jqzreFJdpgxYJAKnepat3jnxQ070/sk4PV79SWUBI3k93aTHxngT35BZ8nOwRcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617125268; 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=WnVIpPwaZAR/evFnFyQWgIANQrh0sUYrPklTXugkzrI=; b=kHZdBGJrp/2uTF0bcG/aNN4sVzPXt3D2WgD3ZP9nNfYBbAQtJlqJ35fBJsks7pmfTSFRNQw23rfmHGY04IxLda4q8oxUPDgiYyEsQzH+P9EaDNY8V3ykR5LYl32KvnrP21LNnyjQrsB1xMyB1MoTJgE40aG/EUIBPmt//Y/beNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617125268760767.7520581297299; Tue, 30 Mar 2021 10:27:48 -0700 (PDT) Received: from localhost ([::1]:43320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI9b-00029p-MB for importer@patchew.org; Tue, 30 Mar 2021 13:27:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1D-0000J8-G1 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI19-0003ZU-3v for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:07 -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-240-0KQrk5O5OMCWFzYcfjdpag-1; Tue, 30 Mar 2021 13:18:54 -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 6A4BD8026AD; Tue, 30 Mar 2021 17:18:53 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1629560861; Tue, 30 Mar 2021 17:18:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124738; 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=WnVIpPwaZAR/evFnFyQWgIANQrh0sUYrPklTXugkzrI=; b=VIsynqUP5KvVy+fc2lSrcI8T803iq80vuBKfCEh6MfqSLrpDlrdkDYMFjSHg2Izg284cxQ J3u1uZMF7JaCb7G0aeAQzh8TRXBf5xnFcGItgad6JqoLOvf6UoagRLaCkf31w1eL1jGFOh 2y8IZXxA5c6nqc8Aw6RcJWQPhalRtlw= X-MC-Unique: 0KQrk5O5OMCWFzYcfjdpag-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 5/8] qapi/error.py: move QAPIParseError to parser.py Date: Tue, 30 Mar 2021 13:18:41 -0400 Message-Id: <20210330171844.1197918-6-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: John Snow --- scripts/qapi/error.py | 12 ------------ scripts/qapi/parser.py | 14 +++++++++++++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index d0bc7af6e7..2183b8c6b7 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -33,17 +33,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 d5bf91f2b0..140f582ad9 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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617124923; cv=none; d=zohomail.com; s=zohoarc; b=Ad5OqNbFRGkR1uLkIrj5qO/bk3UGU0px5Sd9FgwWulWltn8SsUBJzw850rjd60ESf+hjmvwkjoLzDAlrvWjDOJngWsobDwnezmCRU/tyI98CKRJegCV3sI6r/vHIdju8M0dLliixHMWol/EYuw4S7anHxxcu+FgFKE47/n0hcTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617124923; 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=BseVY3DgI+ew3MKuM4+Bqi8TNaaPM9Pl3fq6rpkmELk=; b=RXuszk6lrf2Vk+EMeJ1R7+bfDTRTLCPRa+IYcIL1Gyj2z2mlq5y88bEn5X//iyVSQFf3CHfcPfey5O5mkDoYd77GNLxg26oegRPi17AgHNsq6DlZ+50s8tJ0f7LB06ZPEC1GmDfquhKHWz6b/J04nPXq8dWAvOPMRWzMFDH30RE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161712492349152.91973223784919; Tue, 30 Mar 2021 10:22:03 -0700 (PDT) Received: from localhost ([::1]:52058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI42-0002W1-CD for importer@patchew.org; Tue, 30 Mar 2021 13:22:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1N-0000LA-N8 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI19-0003ZX-T3 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:17 -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-503-DDrLkVRmMByEYdY0eNI9gA-1; Tue, 30 Mar 2021 13:18:56 -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 BF832108BD0B; Tue, 30 Mar 2021 17:18:54 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8B5360861; Tue, 30 Mar 2021 17:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124739; 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=BseVY3DgI+ew3MKuM4+Bqi8TNaaPM9Pl3fq6rpkmELk=; b=ZWUYRHK98FftyvLusC/ESO9jimHGWrqueq5KruiJXThWgAz/MXX4uybe9iMsdnSkn99gYc UKQsiQqEltUfb+MlGjmgYk715n9tjt789ynPNyyNVBft5NGfV63U6MIwJZycSkIo1QoHBu 0JsDI4ypbYALKM4XsKdxC3Nqx8XhDlM= X-MC-Unique: DDrLkVRmMByEYdY0eNI9gA-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 6/8] qapi/error.py: enable pylint checks Date: Tue, 30 Mar 2021 13:18:42 -0400 Message-Id: <20210330171844.1197918-7-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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=unavailable 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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- 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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617124905; cv=none; d=zohomail.com; s=zohoarc; b=L4mA5yQDAJZe/gWoEQPJxSsHOzLr6xPyu3p2oOqKTb6+mvCuoXzR2NcizdcS2STwDjwspYHPMd70f973YxXtCAjyqSdXI4vc0t8+iijCJjXi81+6lWsJTTnNgiz3zkFC6YpJVXXeBgQ/6m1jhIfmWLtNtx9VczWV272+D0eKXVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617124905; 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=Yy2KDBGt63RHFos2sPk1VkUB0gymERc4cCZyUbvON2M=; b=j3PbMUvRB+J3OUNrOr0nOM9tPvtuqcBAqk/BEUjPETn1PYbHJtEAeHIuAzaKEfOCyOziDDI0b29eR55CUVqOmZCLMoP8Ah6LRbEecN934F+Oq9kkqYvKSyoNrFawWJeOeLftGpDkUErwxnq3AdYxQsuWJfcWJXXdtW31D7aiJtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161712490524833.545241539255244; Tue, 30 Mar 2021 10:21:45 -0700 (PDT) Received: from localhost ([::1]:51522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI3k-0002Gu-4B for importer@patchew.org; Tue, 30 Mar 2021 13:21:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1H-0000KJ-1v for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1A-0003Zj-08 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:10 -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-405-GtM_C4qdPQubMwiy7mVkoA-1; Tue, 30 Mar 2021 13:19:00 -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 2379318C8C00; Tue, 30 Mar 2021 17:18:59 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1498360861; Tue, 30 Mar 2021 17:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124742; 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=Yy2KDBGt63RHFos2sPk1VkUB0gymERc4cCZyUbvON2M=; b=JZDE9uBe4tvmwDc/GXB3CqV+ooTSwUrLGvi6u00OBOfC+Diyf/CbZ5j3M8bU+QWh+i0ZlL 10DAxgO5ThxYcfX/BqcV0iQri0iv34fWfTR2JfY0VHG9CapWGUpPJ8gzEIQOcxHNWaMh/v 644nmpQyzzWSTRwxM2F0oi0y4iTe5+U= X-MC-Unique: GtM_C4qdPQubMwiy7mVkoA-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 7/8] qapi/error: Add type hints Date: Tue, 30 Mar 2021 13:18:43 -0400 Message-Id: <20210330171844.1197918-8-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" No functional change. Signed-off-by: John Snow --- 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 2183b8c6b7..6ba54821c9 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -11,6 +11,10 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 +from typing import Optional + +from .source import QAPISourceInfo + =20 class QAPIError(Exception): """Base class for all exceptions from the QAPI package.""" @@ -18,13 +22,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.30.2 From nobody Mon May 6 13:36:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617125194; cv=none; d=zohomail.com; s=zohoarc; b=oHYWWZLf5ytO1sOxTQ2dOdUGbMVKBU3kTQGHG6VVy/YZGmvcivKueRwh9dNz9wxbmG/7EXBN9Sfn5xBr27zN2jPU4EQrhYfVvXFJEAd2COsZMsnqQV4ylBClBRBYRDfX8uGVmjPj+dE8nZ+5bl6fzz1v78Fl1DOTbs8zhQyB0hU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617125194; 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=mWblpa47kQMKXizt8nHrFY5rb8quFHkiLPOvpY5aBNc=; b=IDBs7XbcaF8AE9C0hhyh7dVRJ8ehSH5paXe4XRKA5zalKyfadXm8Zo8XsTTQHp5n5hyumiyrvfnuGnVlflE0LGLdG94BydzZJkpWTBPBIE2IEMp8nvY2mWeR0O2mu5tOaJr6tMmmE5c3DzYR+1Y9zZNTeP/5zIpwajcanzzKb2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617125194818177.08501560422906; Tue, 30 Mar 2021 10:26:34 -0700 (PDT) Received: from localhost ([::1]:39182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRI8O-0000Tr-1F for importer@patchew.org; Tue, 30 Mar 2021 13:26:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1Q-0000NR-IW for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRI1D-0003b3-79 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 13:19:19 -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-346-ATybsIuYObW-CI-jU8aang-1; Tue, 30 Mar 2021 13:19:04 -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 8412F1005D58; Tue, 30 Mar 2021 17:19:03 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-61.rdu2.redhat.com [10.10.117.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43C4060861; Tue, 30 Mar 2021 17:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617124746; 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=mWblpa47kQMKXizt8nHrFY5rb8quFHkiLPOvpY5aBNc=; b=g+YhBCqG9NLBIkanWDMg5NMLHTF3cPgZFn9kvuLd9MMs8i3czAOOPgB2DeeR6i5eJg4Ret /+CyOBprrg0CY/uxzx7nX8M0F+SAeozLLjgLBvqxQWxtopJnhvomVmrIP7Q6Xtz5tvVUES Nv/VtZ0kMlU6jhM5GWWy19gXld6wKus= X-MC-Unique: ATybsIuYObW-CI-jU8aang-1 From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v2 8/8] qapi/error.py: enable mypy checks Date: Tue, 30 Mar 2021 13:18:44 -0400 Message-Id: <20210330171844.1197918-9-jsnow@redhat.com> In-Reply-To: <20210330171844.1197918-1-jsnow@redhat.com> References: <20210330171844.1197918-1-jsnow@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=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_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 , Eduardo Habkost , Michael Roth , Michael Roth , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- (This can be squashed with the previous commit when staged.) Signed-off-by: John Snow --- 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.30.2