From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632944909001441.85408235433465; Wed, 29 Sep 2021 12:48:29 -0700 (PDT) Received: from localhost ([::1]:49716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfZ5-00027u-LL for importer@patchew.org; Wed, 29 Sep 2021 15:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfW0-0007TI-4U for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfVw-0006Bm-QR for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:15 -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-375-59oGITg4MamZlHSe0KXLfg-1; Wed, 29 Sep 2021 15:45:10 -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 0B81556C35; Wed, 29 Sep 2021 19:45:04 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6796526DEF; Wed, 29 Sep 2021 19:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944711; 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=r8V+Ogw9WNH215AikDA20SvTc2Qpd8O1Clg8V3SoAp4=; b=Uln9JXIb0PHFkbz1it5vtse7qX3okwwXbLTMVUoWEVTr+2te1YMvpi7iJ21izQTPs++yxV C/ip+BJdvhwP1OnKVAq53SdTbupN2Ne9cDdZTmpa2Gby95qDghzF5Zqm8q3uFRE/hvlBYv DMBxQUEeOwhyPiIpNnGeTFX85WI1XDU= X-MC-Unique: 59oGITg4MamZlHSe0KXLfg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 01/13] qapi/pylintrc: ignore 'consider-using-f-string' warning Date: Wed, 29 Sep 2021 15:44:16 -0400 Message-Id: <20210929194428.1038496-2-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632944909342100003 Content-Type: text/plain; charset="utf-8" Pylint 2.11.x adds this warning. We're not yet ready to pursue that conversion, so silence it for now. Signed-off-by: John Snow --- scripts/qapi/pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index c5275d5f59b..5b7dbc58ad8 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -23,6 +23,7 @@ disable=3Dfixme, too-many-branches, too-many-statements, too-many-instance-attributes, + consider-using-f-string, =20 [REPORTS] =20 --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945047813390.77806599208986; Wed, 29 Sep 2021 12:50:47 -0700 (PDT) Received: from localhost ([::1]:56860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfbK-0006rh-Ow for importer@patchew.org; Wed, 29 Sep 2021 15:50:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfW0-0007Td-9n for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfVx-0006Ck-C8 for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:16 -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-279--pRY0JnZMeqM0oZuKhlGiA-1; Wed, 29 Sep 2021 15:45:11 -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 EA7E78710FD; Wed, 29 Sep 2021 19:45:05 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC3E3CC7; Wed, 29 Sep 2021 19:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944712; 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=Vp1Z6jUrVyI8dXf9JGLwFdI3q50mjfk9QTys8vLuwTg=; b=ECnrfjcW1k0/w65GcUi20Bhink2T+p4zuOjyhGv0rJGwMKpjM6RegZuUqJIT2LCmPT5iZT 9OyC7LvBJdOwE8ZAnU10JDtFIXclRv3Cclt53jwbuCgqtB53/z3gJEDLzbVxCyC0v+GyaO R35sSsJiXJ/MsXohar1UcOq1Y8uELM4= X-MC-Unique: -pRY0JnZMeqM0oZuKhlGiA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 02/13] qapi/gen: use dict.items() to iterate over _modules Date: Wed, 29 Sep 2021 15:44:17 -0400 Message-Id: <20210929194428.1038496-3-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945048420100001 Content-Type: text/plain; charset="utf-8" New pylint warning. I could silence it, but this is the only occurrence in the entire tree, including everything in iotests/ and python/. Easier to just change this one instance. (The warning is emitted in cases where you are fetching the values anyway, so you may as well just take advantage of the iterator to avoid redundant lookups.) Signed-off-by: John Snow --- scripts/qapi/gen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index ab26d5c937a..2ec1e7b3b68 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -296,10 +296,9 @@ def _temp_module(self, name: str) -> Iterator[None]: self._current_module =3D old_module =20 def write(self, output_dir: str, opt_builtins: bool =3D False) -> None: - for name in self._module: + for name, (genc, genh) in self._module.items(): if QAPISchemaModule.is_builtin_module(name) and not opt_builti= ns: continue - (genc, genh) =3D self._module[name] genc.write(output_dir) genh.write(output_dir) =20 --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945068570207.70719616970064; Wed, 29 Sep 2021 12:51:08 -0700 (PDT) Received: from localhost ([::1]:58246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfbf-0007sA-G8 for importer@patchew.org; Wed, 29 Sep 2021 15:51:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfW7-0007cQ-Pv for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54033) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfW6-0006M3-4c for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:23 -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-535-GhyMCmF8OoGRYfhC5EgEVg-1; Wed, 29 Sep 2021 15:45:18 -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 1D4AB100792F; Wed, 29 Sep 2021 19:45:07 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58C41277C4; Wed, 29 Sep 2021 19:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944721; 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=H4wmRwo9I4SnMcomzCicuV3AAogfgQNNH0p/ykhYf6s=; b=VadJxxtZAXKot5VLC4nTPRF6Nt+xj00+V7cX+62u1Pvnr5jCUQ5OrXMnG+yk0rVnnEFdg7 AUQFqYPHfleJSZu5C5dyc1B7Oj0ltuY/qKGAg19MNPt97o325oJnliwW+uS2XrcFXopAvb kvpFKjRK80UMTmvdUH54y776/SnvuPw= X-MC-Unique: GhyMCmF8OoGRYfhC5EgEVg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 03/13] qapi/parser: fix unused check_args_section arguments Date: Wed, 29 Sep 2021 15:44:18 -0400 Message-Id: <20210929194428.1038496-4-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945070609100003 Content-Type: text/plain; charset="utf-8" Pylint informs us we're not using these arguments. Oops, it's right. Correct the error message and remove the remaining unused parameter. Fix test output now that the error message is improved. Fixes: e151941d1b Signed-off-by: John Snow --- scripts/qapi/parser.py | 16 +++++++++------- tests/qapi-schema/doc-bad-feature.err | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index f03ba2cfec8..bfd2dbfd9a2 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -753,16 +753,18 @@ def check_expr(self, expr): =20 def check(self): =20 - def check_args_section(args, info, what): + def check_args_section(args, what): bogus =3D [name for name, section in args.items() if not section.member] if bogus: raise QAPISemError( self.info, - "documented member%s '%s' %s not exist" - % ("s" if len(bogus) > 1 else "", - "', '".join(bogus), - "do" if len(bogus) > 1 else "does")) + "documented %s%s '%s' %s not exist" % ( + what, + "s" if len(bogus) > 1 else "", + "', '".join(bogus), + "do" if len(bogus) > 1 else "does" + )) =20 - check_args_section(self.args, self.info, 'members') - check_args_section(self.features, self.info, 'features') + check_args_section(self.args, 'member') + check_args_section(self.features, 'feature') diff --git a/tests/qapi-schema/doc-bad-feature.err b/tests/qapi-schema/doc-= bad-feature.err index e4c62adfa3e..49d1746c3d1 100644 --- a/tests/qapi-schema/doc-bad-feature.err +++ b/tests/qapi-schema/doc-bad-feature.err @@ -1 +1 @@ -doc-bad-feature.json:3: documented member 'a' does not exist +doc-bad-feature.json:3: documented feature 'a' does not exist --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945214999237.56883018795895; Wed, 29 Sep 2021 12:53:34 -0700 (PDT) Received: from localhost ([::1]:37030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfe1-0004Hw-Jn for importer@patchew.org; Wed, 29 Sep 2021 15:53:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWE-0007eL-9l for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWB-0006TF-Cl for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:29 -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-452-knD0WzDpMxGRnaWI8IH7WQ-1; Wed, 29 Sep 2021 15:45:24 -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 962CF8B0695; Wed, 29 Sep 2021 19:45:08 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7A9227067; Wed, 29 Sep 2021 19:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944726; 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=0KCb6iNGYUzpcG61oVv8RDctCBUpQc4Md8uKwiAchp0=; b=KfJ2CCpmISRUP72I9orBEmEqri4JZq2NTiktNXS1KLzYvBtcf2tM1ND+fsjsTIdV1L/Ubz acz7ogUSJU/73TwXXH5nVx+Cnnlmdj/wUQB/plyLiMIxxx60BmO9Q/tN0FvyMSbQQ4kURY szJigzxhK8OOM93T5wmbNSv65JKoBrI= X-MC-Unique: knD0WzDpMxGRnaWI8IH7WQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 04/13] qapi: Add spaces after symbol declaration for consistency Date: Wed, 29 Sep 2021 15:44:19 -0400 Message-Id: <20210929194428.1038496-5-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945216774100001 Content-Type: text/plain; charset="utf-8" Several QGA definitions omit a blank line after the symbol declaration. This works OK currently, but it's the only place where we do this. Adjust it for consistency. Future commits may wind up enforcing this formatting. Signed-off-by: John Snow --- This isn't strictly necessary and I don't actually get around to enforcing it in this series, but I figured I'd share it with the list anyway. We can just drop this patch but I wanted to see your thoughts. Signed-off-by: John Snow --- qapi/block-core.json | 1 + qga/qapi-schema.json | 3 +++ tests/qapi-schema/doc-good.json | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 4114f8b6fc3..52a6dae9522 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3132,6 +3132,7 @@ =20 ## # @BlockdevQcow2EncryptionFormat: +# # @aes: AES-CBC with plain64 initialization vectors # # Since: 2.10 diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index c60f5e669d7..94e4aacdcc6 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1140,6 +1140,7 @@ =20 ## # @GuestExec: +# # @pid: pid of child process in guest OS # # Since: 2.5 @@ -1171,6 +1172,7 @@ =20 ## # @GuestHostName: +# # @host-name: Fully qualified domain name of the guest OS # # Since: 2.10 @@ -1197,6 +1199,7 @@ =20 ## # @GuestUser: +# # @user: Username # @domain: Logon domain (windows only) # @login-time: Time of login of this user on the computer. If multiple diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index a20acffd8b9..86dc25d2bd8 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -53,6 +53,7 @@ =20 ## # @Enum: +# # @one: The _one_ {and only} # # Features: @@ -67,6 +68,7 @@ =20 ## # @Base: +# # @base1: # the first member ## @@ -75,6 +77,7 @@ =20 ## # @Variant1: +# # A paragraph # # Another paragraph (but no @var: line) @@ -91,11 +94,13 @@ =20 ## # @Variant2: +# ## { 'struct': 'Variant2', 'data': {} } =20 ## # @Object: +# # Features: # @union-feat1: a feature ## @@ -109,6 +114,7 @@ =20 ## # @Alternate: +# # @i: an integer # @b is undocumented # @@ -126,6 +132,7 @@ =20 ## # @cmd: +# # @arg1: the first argument # # @arg2: the second @@ -175,6 +182,7 @@ =20 ## # @EVT_BOXED: +# # Features: # @feat3: a feature ## --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945395919209.8147319267913; Wed, 29 Sep 2021 12:56:35 -0700 (PDT) Received: from localhost ([::1]:44970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfgw-0001cu-M8 for importer@patchew.org; Wed, 29 Sep 2021 15:56:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWO-0007jY-5n for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWG-0006Xm-Ea for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:39 -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-18-6pu-ePzhM4mAmdKUleYi4w-1; Wed, 29 Sep 2021 15:45:30 -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 E3653189CD1F; Wed, 29 Sep 2021 19:45:09 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01C512B3CD; Wed, 29 Sep 2021 19:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944731; 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=vgEu582rg+QZQ5sXfi6l5BL21SJgdH3Gt59RDW8pSD0=; b=hNYszFvtHOwglwYNtyThYVKkkFh62EOl83uR3rFCFGtAfqsmjYFUCtMvPxAf7fusEmG+SK 7LdLGODA2FDPA+R6m5dojDsMFDoxq4BeXr/QCWr/UaHF16N0sQd5CQYi5py4C/GyJ/mI/4 TG65isSbwE90Ey00L2OPGGZ2fgZFKg0= X-MC-Unique: 6pu-ePzhM4mAmdKUleYi4w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 05/13] qapi/parser: improve detection of '@symbol:' preface Date: Wed, 29 Sep 2021 15:44:20 -0400 Message-Id: <20210929194428.1038496-6-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945397278100001 Content-Type: text/plain; charset="utf-8" Leading and trailing whitespace are now discarded, addressing the FIXME comment. A new error is raised to detect this accidental case. Parsing for args sections is left alone here; the 'name' variable is moved into the only block where it is used. Signed-off-by: John Snow --- Tangentially related to delinting in that removing 'FIXME' comments is a goal for pylint. My goal is to allow 'TODO' to be checked in, but 'FIXME' should be fixed prior to inclusion. Arbitrary, but that's life for you. Signed-off-by: John Snow --- scripts/qapi/parser.py | 13 ++++++++----- tests/qapi-schema/doc-whitespace-leading-symbol.err | 1 + .../qapi-schema/doc-whitespace-leading-symbol.json | 6 ++++++ tests/qapi-schema/doc-whitespace-leading-symbol.out | 0 .../qapi-schema/doc-whitespace-trailing-symbol.err | 1 + .../qapi-schema/doc-whitespace-trailing-symbol.json | 6 ++++++ .../qapi-schema/doc-whitespace-trailing-symbol.out | 0 tests/qapi-schema/meson.build | 2 ++ 8 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 tests/qapi-schema/doc-whitespace-leading-symbol.err create mode 100644 tests/qapi-schema/doc-whitespace-leading-symbol.json create mode 100644 tests/qapi-schema/doc-whitespace-leading-symbol.out create mode 100644 tests/qapi-schema/doc-whitespace-trailing-symbol.err create mode 100644 tests/qapi-schema/doc-whitespace-trailing-symbol.json create mode 100644 tests/qapi-schema/doc-whitespace-trailing-symbol.out diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index bfd2dbfd9a2..2f93a752f66 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -549,18 +549,21 @@ def _append_body_line(self, line): =20 Else, append the line to the current section. """ - name =3D line.split(' ', 1)[0] - # FIXME not nice: things like '# @foo:' and '# @foo: ' aren't - # recognized, and get silently treated as ordinary text - if not self.symbol and not self.body.text and line.startswith('@'): - if not line.endswith(':'): + stripped =3D line.strip() + + if not self.symbol and not self.body.text and stripped.startswith(= '@'): + if not stripped.endswith(':'): raise QAPIParseError(self._parser, "line should end with '= :'") + if not stripped =3D=3D line: + raise QAPIParseError( + self._parser, "extra whitespace around symbol declarat= ion") self.symbol =3D line[1:-1] # FIXME invalid names other than the empty string aren't flagg= ed if not self.symbol: raise QAPIParseError(self._parser, "invalid name") elif self.symbol: # This is a definition documentation block + name =3D line.split(' ', 1)[0] if name.startswith('@') and name.endswith(':'): self._append_line =3D self._append_args_line self._append_args_line(line) diff --git a/tests/qapi-schema/doc-whitespace-leading-symbol.err b/tests/qa= pi-schema/doc-whitespace-leading-symbol.err new file mode 100644 index 00000000000..785468b90e2 --- /dev/null +++ b/tests/qapi-schema/doc-whitespace-leading-symbol.err @@ -0,0 +1 @@ +doc-whitespace-leading-symbol.json:4:1: extra whitespace around symbol dec= laration diff --git a/tests/qapi-schema/doc-whitespace-leading-symbol.json b/tests/q= api-schema/doc-whitespace-leading-symbol.json new file mode 100644 index 00000000000..128c781bec9 --- /dev/null +++ b/tests/qapi-schema/doc-whitespace-leading-symbol.json @@ -0,0 +1,6 @@ +# Documentation for expression has leading whitespace + +## +# @leading-whitespace: +## +{ 'command': 'leading-whitespace', 'data': {'a': 'int'} } diff --git a/tests/qapi-schema/doc-whitespace-leading-symbol.out b/tests/qa= pi-schema/doc-whitespace-leading-symbol.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/qapi-schema/doc-whitespace-trailing-symbol.err b/tests/q= api-schema/doc-whitespace-trailing-symbol.err new file mode 100644 index 00000000000..fe583b38008 --- /dev/null +++ b/tests/qapi-schema/doc-whitespace-trailing-symbol.err @@ -0,0 +1 @@ +doc-whitespace-trailing-symbol.json:4:1: extra whitespace around symbol de= claration diff --git a/tests/qapi-schema/doc-whitespace-trailing-symbol.json b/tests/= qapi-schema/doc-whitespace-trailing-symbol.json new file mode 100644 index 00000000000..da706c3d176 --- /dev/null +++ b/tests/qapi-schema/doc-whitespace-trailing-symbol.json @@ -0,0 +1,6 @@ +# Documentation for expression has extra whitespace + +## +# @trailing-whitespace: =20 +## +{ 'command': 'trailing-whitespace', 'data': {'a': 'int'} } diff --git a/tests/qapi-schema/doc-whitespace-trailing-symbol.out b/tests/q= api-schema/doc-whitespace-trailing-symbol.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 6187efbd58f..64ffbd1b3d4 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -82,6 +82,8 @@ schemas =3D [ 'doc-missing.json', 'doc-no-symbol.json', 'doc-undoc-feature.json', + 'doc-whitespace-leading-symbol.json', + 'doc-whitespace-trailing-symbol.json', 'double-type.json', 'duplicate-key.json', 'empty.json', --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945067342896.3445197923285; Wed, 29 Sep 2021 12:51:07 -0700 (PDT) Received: from localhost ([::1]:58162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfbc-0007p5-Uv for importer@patchew.org; Wed, 29 Sep 2021 15:51:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWI-0007gs-Dv for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWF-0006X8-Ox for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:34 -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-73-Nfxin3UfMuiRPL9x4krc9g-1; Wed, 29 Sep 2021 15:45:29 -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 87D8181C872; Wed, 29 Sep 2021 19:45:10 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76F9026573; Wed, 29 Sep 2021 19:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944731; 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=lbt2BBmASD3BBGEUtvZ/jnjqitVT1BlXIqz/f6NvVvQ=; b=Us0xakTwxL3xK15WaKLiNlrL4N8MfsjGK6lgQOeOqT+aYqI5qZWAS48dbgaIz5paB8c2ix yJn3U2Kvik6cVDmatWYY2ybJOQ200ICyb4+PoO0CSjpdONDGeS24h91UBf7fcCyv4K0Rt1 wk+3s+I+UHxmKUgfvWx7yWABYtR84oI= X-MC-Unique: Nfxin3UfMuiRPL9x4krc9g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 06/13] qapi/parser: remove FIXME comment from _append_body_line Date: Wed, 29 Sep 2021 15:44:21 -0400 Message-Id: <20210929194428.1038496-7-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945068610100001 Content-Type: text/plain; charset="utf-8" True, we do not check the validity of this symbol -- but we don't check the validity of definition names during parse, either -- that happens later, during the expr check. I don't want to introduce a dependency on expr.py:check_name_str here and introduce a cycle. Instead, rest assured that a documentation block is required for each definition. This requirement uses the names of each section to ensure that we fulfilled this requirement. e.g., let's say that block-core.json has a comment block for "Snapshot!Info" by accident. We'll see this error message: In file included from ../../qapi/block.json:8: ../../qapi/block-core.json: In struct 'SnapshotInfo': ../../qapi/block-core.json:38: documentation comment is for 'Snapshot!Info' That's a pretty decent error message. Now, let's say that we actually mangle it twice, identically: ../../qapi/block-core.json: In struct 'Snapshot!Info': ../../qapi/block-core.json:38: struct has an invalid name That's also pretty decent. If we forget to fix it in both places, we'll just be back to the first error. Therefore, let's just drop this FIXME and adjust the error message to not imply a more thorough check than is actually performed. Signed-off-by: John Snow --- scripts/qapi/parser.py | 6 ++++-- tests/qapi-schema/doc-empty-symbol.err | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 2f93a752f66..52748e8e462 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -558,9 +558,11 @@ def _append_body_line(self, line): raise QAPIParseError( self._parser, "extra whitespace around symbol declarat= ion") self.symbol =3D line[1:-1] - # FIXME invalid names other than the empty string aren't flagg= ed + # Invalid names are not checked here, but the name provided MU= ST + # match the following definition, which *is* validated. if not self.symbol: - raise QAPIParseError(self._parser, "invalid name") + raise QAPIParseError( + self._parser, "doc symbol name cannot be blank") elif self.symbol: # This is a definition documentation block name =3D line.split(' ', 1)[0] diff --git a/tests/qapi-schema/doc-empty-symbol.err b/tests/qapi-schema/doc= -empty-symbol.err index 81b90e882a7..a4981ee28ea 100644 --- a/tests/qapi-schema/doc-empty-symbol.err +++ b/tests/qapi-schema/doc-empty-symbol.err @@ -1 +1 @@ -doc-empty-symbol.json:4:1: invalid name +doc-empty-symbol.json:4:1: doc symbol name cannot be blank --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945228068576.3811233359996; Wed, 29 Sep 2021 12:53:48 -0700 (PDT) Received: from localhost ([::1]:37994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfeF-00050h-3L for importer@patchew.org; Wed, 29 Sep 2021 15:53:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWK-0007hY-CZ for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWI-0006Zd-Oe for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:36 -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-75-ltjnYfGFMG227h6VvtreWQ-1; Wed, 29 Sep 2021 15:45:33 -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 B02E0824FB2; Wed, 29 Sep 2021 19:45:11 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD7BF1972D; Wed, 29 Sep 2021 19:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944734; 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=4kLbZrRFkZsyh/na6cTKsezjy+ayXpcMxZvdGtgNfyE=; b=FwQQT+FVYum0VTyHk+9kHmiV1y1CEMTwy898pYbLN/vTJduFnFNuD9bcNxpjcT0ao/BQTV UWSvNFHaFzuOlprFPAJimZOUcmTyyZ+GkGQ5N5Tcg0uGBn0gjxXR9bdbP5MrLDhr9LyusB 8BjCjTvCjYBU77OPURzQiVMMXNwp5r0= X-MC-Unique: ltjnYfGFMG227h6VvtreWQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 07/13] qapi/parser: Simplify _end_section() Date: Wed, 29 Sep 2021 15:44:22 -0400 Message-Id: <20210929194428.1038496-8-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945229900100001 Content-Type: text/plain; charset="utf-8" The "if self._section" clause in end_section is mysterious: In which circumstances might we end a section when we don't have one? QAPIDoc always expects there to be a "current section", only except after a call to end_comment(). This actually *shouldn't* ever be 'None', so let's remove that logic so I don't wonder why it's like this again in three months. Signed-off-by: John Snow --- scripts/qapi/parser.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 52748e8e462..1fdc5bc7056 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -721,13 +721,21 @@ def _start_section(self, name=3DNone, indent=3D0): self.sections.append(self._section) =20 def _end_section(self): - if self._section: - text =3D self._section.text =3D self._section.text.strip() - if self._section.name and (not text or text.isspace()): - raise QAPIParseError( - self._parser, - "empty doc section '%s'" % self._section.name) - self._section =3D None + assert self._section is not None + + text =3D self._section.text =3D self._section.text.strip() + + # Only the 'body' section is allowed to have an empty body. + # All other sections, including anonymous ones, must have text. + if self._section !=3D self.body and not text: + # We do not create anonymous sections unless there is + # something to put in them; this is a parser bug. + assert self._section.name + raise QAPIParseError( + self._parser, + "empty doc section '%s'" % self._section.name) + + self._section =3D None =20 def _append_freeform(self, line): match =3D re.match(r'(@\S+:)', line) --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945387498627.8577790370427; Wed, 29 Sep 2021 12:56:27 -0700 (PDT) Received: from localhost ([::1]:44076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfgo-000113-I7 for importer@patchew.org; Wed, 29 Sep 2021 15:56:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWQ-0007lq-3y for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWN-0006dj-VN for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:41 -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-193-VHDNIYCZMlCABkp3VO-I6A-1; Wed, 29 Sep 2021 15:45:37 -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 E70818B84D7; Wed, 29 Sep 2021 19:45:12 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA99E19C59; Wed, 29 Sep 2021 19:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944738; 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=ttyL5yKkstBuidNsxns2YyTkIBprKJqaN9Gmb7f277U=; b=ez+iZPCRgOJpXu4mC4vK7IvMc0Va1JDwDCAnoQZwP5ZXHO1igat3HQlMOKLZEYVFcB9LjE gnZ/TLcNIpCnCQPTSPtFTbTzUY/ksVwN0tgw+VVj/GXlt7s+vTHu5cBIuFiZCUsfGbhw3T ppM4IRBvFXAfGyewMtjieu7NRaSkdqU= X-MC-Unique: VHDNIYCZMlCABkp3VO-I6A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 08/13] qapi/parser: Introduce NullSection Date: Wed, 29 Sep 2021 15:44:23 -0400 Message-Id: <20210929194428.1038496-9-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945388531100001 Content-Type: text/plain; charset="utf-8" Here's the weird bit. QAPIDoc generally expects -- virtually everywhere -- that it will always have a current section. The sole exception to this is in the case that end_comment() is called, which leaves us with *no* section. However, in this case, we also don't expect to actually ever mutate the comment contents ever again. NullSection is just a Null-object that allows us to maintain the invariant that we *always* have a current section, enforced by static typing -- allowing us to type that field as QAPIDoc.Section instead of the more ambiguous Optional[QAPIDoc.Section]. end_section is renamed to switch_section and now accepts as an argument the new section to activate, clarifying that no callers ever just unilaterally end a section; they only do so when starting a new section. Signed-off-by: John Snow --- For my money: Optional types can be a nuisance because an unfamiliar reader may wonder in what circumstances the field may be unset. This makes the condition quite a bit more explicit and statically provable. Doing it in this way (and not by creating a dummy section) will also continue to reject (rather noisily) any erroneous attempts to append additional lines after end_comment() has been called. Also, this section isn't indexed into .sections[] and isn't really visible in any way to external users of the class, so it seems like a harmless and low-cost way to formalize the "life cycle" of a QAPIDoc parser. Clean and clear as I can make it, in as few lines as I could muster. Signed-off-by: John Snow --- scripts/qapi/parser.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 1fdc5bc7056..123fc2f099c 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -478,6 +478,13 @@ def __init__(self, parser, name, indent=3D0): def connect(self, member): self.member =3D member =20 + class NullSection(Section): + """ + Empty section that signifies the end of a doc block. + """ + def append(self, line): + assert False, "BUG: Text appended after end_comment() called." + def __init__(self, parser, info): # self._parser is used to report errors with QAPIParseError. The # resulting error position depends on the state of the parser. @@ -525,7 +532,7 @@ def append(self, line): self._append_line(line) =20 def end_comment(self): - self._end_section() + self._switch_section(QAPIDoc.NullSection(self._parser)) =20 @staticmethod def _is_section_tag(name): @@ -702,9 +709,9 @@ def _start_symbol_section(self, symbols_dict, name, ind= ent): raise QAPIParseError(self._parser, "'%s' parameter name duplicated" % name) assert not self.sections - self._end_section() - self._section =3D QAPIDoc.ArgSection(self._parser, name, indent) - symbols_dict[name] =3D self._section + new_section =3D QAPIDoc.ArgSection(self._parser, name, indent) + self._switch_section(new_section) + symbols_dict[name] =3D new_section =20 def _start_args_section(self, name, indent): self._start_symbol_section(self.args, name, indent) @@ -716,13 +723,11 @@ def _start_section(self, name=3DNone, indent=3D0): if name in ('Returns', 'Since') and self.has_section(name): raise QAPIParseError(self._parser, "duplicated '%s' section" % name) - self._end_section() - self._section =3D QAPIDoc.Section(self._parser, name, indent) - self.sections.append(self._section) - - def _end_section(self): - assert self._section is not None + new_section =3D QAPIDoc.Section(self._parser, name, indent) + self._switch_section(new_section) + self.sections.append(new_section) =20 + def _switch_section(self, new_section): text =3D self._section.text =3D self._section.text.strip() =20 # Only the 'body' section is allowed to have an empty body. @@ -735,7 +740,7 @@ def _end_section(self): self._parser, "empty doc section '%s'" % self._section.name) =20 - self._section =3D None + self._section =3D new_section =20 def _append_freeform(self, line): match =3D re.match(r'(@\S+:)', line) --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945522812595.235891226386; Wed, 29 Sep 2021 12:58:42 -0700 (PDT) Received: from localhost ([::1]:51512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfiz-0005yd-Dk for importer@patchew.org; Wed, 29 Sep 2021 15:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWb-0007yc-Tc for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWY-0006mn-8Q for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45: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-144-W9EDOWDgM_eMed49srGTQw-1; Wed, 29 Sep 2021 15:45:44 -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 2D2171006ACC; Wed, 29 Sep 2021 19:45:14 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BD5F19C59; Wed, 29 Sep 2021 19:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944749; 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=lAZbcKIyhkiYdXCqmSV21zRsJ1QP7YAp5ksVs7z8ADg=; b=JLxsldVhLc/eRgLu0iyrDrswxXwDJO4/Uy/s2rHLThojz2qVh3psOmJvzW6c8cz72meDNJ dsDttKJxSe1wobA1SiCGaZRHezfL8cG0alIpREEKQvcAgxjJ+skAxLO2Yva7rjZ/1hl37K ZJ9RSi1582ogp0CTuF2bUtKhZNpSqIw= X-MC-Unique: W9EDOWDgM_eMed49srGTQw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 09/13] qapi/parser: add import cycle workaround Date: Wed, 29 Sep 2021 15:44:24 -0400 Message-Id: <20210929194428.1038496-10-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945524352100002 Content-Type: text/plain; charset="utf-8" There is a cycle that exists in the QAPI generator: [schema -> expr -> parser -> schema]. It exists because the QAPIDoc class needs the names of types defined by the schema module, but the schema module needs to import both expr.py/parser.py to do its actual parsing. Ultimately, the layering violation is that parser.py should not have any knowledge of specifics of the Schema. QAPIDoc performs double-duty here both as a parser *and* as a finalized object that is part of the schema. I see three paths here: (1) Just use the TYPE_CHECKING trick to eliminate the cycle which is only present during static analysis. (2) Don't bother to annotate connect_member() et al, give them 'object' or 'Any'. I don't particularly like this, because it diminishes the usefulness of type hints for documentation purposes. Still, it's an extremely quick fix. (3) Reimplement doc <--> definition correlation directly in schema.py, integrating doc fields directly into QAPISchemaMember and relieving the QAPIDoc class of the responsibility. Users of the information would instead visit the members first and retrieve their documentation instead of the inverse operation -- visiting the documentation and retrieving their members. I prefer (3), but (1) is the easiest way to have my cake (strong type hints) and eat it too (Not have import cycles). Do (1) for now, but plan for (3). See also: https://mypy.readthedocs.io/en/latest/runtime_troubles.html#import-cycles Signed-off-by: John Snow --- scripts/qapi/parser.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 123fc2f099c..30b1d98df0b 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -18,6 +18,7 @@ import os import re from typing import ( + TYPE_CHECKING, Dict, List, Optional, @@ -30,6 +31,12 @@ from .source import QAPISourceInfo =20 =20 +if TYPE_CHECKING: + # pylint: disable=3Dcyclic-import + # TODO: Remove cycle. [schema -> expr -> parser -> schema] + from .schema import QAPISchemaFeature, QAPISchemaMember + + # Return value alias for get_expr(). _ExprValue =3D Union[List[object], Dict[str, object], str, bool] =20 @@ -473,9 +480,9 @@ def append(self, line): class ArgSection(Section): def __init__(self, parser, name, indent=3D0): super().__init__(parser, name, indent) - self.member =3D None + self.member: Optional['QAPISchemaMember'] =3D None =20 - def connect(self, member): + def connect(self, member: 'QAPISchemaMember') -> None: self.member =3D member =20 class NullSection(Section): @@ -750,14 +757,14 @@ def _append_freeform(self, line): % match.group(1)) self._section.append(line) =20 - def connect_member(self, member): + def connect_member(self, member: 'QAPISchemaMember') -> None: if member.name not in self.args: # Undocumented TODO outlaw self.args[member.name] =3D QAPIDoc.ArgSection(self._parser, member.name) self.args[member.name].connect(member) =20 - def connect_feature(self, feature): + def connect_feature(self, feature: 'QAPISchemaFeature') -> None: if feature.name not in self.features: raise QAPISemError(feature.info, "feature '%s' lacks documentation" --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945177837521.570279676615; Wed, 29 Sep 2021 12:52:57 -0700 (PDT) Received: from localhost ([::1]:35316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfdQ-000300-Qe for importer@patchew.org; Wed, 29 Sep 2021 15:52:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWZ-0007w5-Hd for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWV-0006kC-29 for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45: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-435-bO6ihiqtOF-ZJC8O38cCfA-1; Wed, 29 Sep 2021 15:45: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 588F384BA47; Wed, 29 Sep 2021 19:45:15 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5688019C59; Wed, 29 Sep 2021 19:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944746; 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=VqlJCDEDfbNbMYTPdzxbbcitUekyh8rT6xK3kIX3EOw=; b=izdpPnPIQlx7lSIwTHCY6W//3sw406TUHftr/osIgAlroTZAdsAWCTmJnsqUl6urVTMbJx DP51aeMirBEcD1Hd+AxlbML7hfgqCpgARbHdcNgHX/51ip66iLKAbQsQd/FneL9sN6LjY/ xhBYFsKe6H4g/Dwt48cWIDqQx6fRBYU= X-MC-Unique: bO6ihiqtOF-ZJC8O38cCfA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 10/13] qapi/parser: add type hint annotations (QAPIDoc) Date: Wed, 29 Sep 2021 15:44:25 -0400 Message-Id: <20210929194428.1038496-11-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945180017100001 Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit consists of only annotations. Signed-off-by: John Snow --- scripts/qapi/parser.py | 67 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 30b1d98df0b..8a846079207 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -37,6 +37,9 @@ from .schema import QAPISchemaFeature, QAPISchemaMember =20 =20 +#: Represents a single Top Level QAPI schema expression. +TopLevelExpr =3D Dict[str, object] + # Return value alias for get_expr(). _ExprValue =3D Union[List[object], Dict[str, object], str, bool] =20 @@ -454,7 +457,8 @@ class QAPIDoc: """ =20 class Section: - def __init__(self, parser, name=3DNone, indent=3D0): + def __init__(self, parser: QAPISchemaParser, + name: Optional[str] =3D None, indent: int =3D 0): # parser, for error messages about indentation self._parser =3D parser # optional section name (argument/member or section name) @@ -463,7 +467,7 @@ def __init__(self, parser, name=3DNone, indent=3D0): # the expected indent level of the text of this section self._indent =3D indent =20 - def append(self, line): + def append(self, line: str) -> None: # Strip leading spaces corresponding to the expected indent le= vel # Blank lines are always OK. if line: @@ -478,7 +482,8 @@ def append(self, line): self.text +=3D line.rstrip() + '\n' =20 class ArgSection(Section): - def __init__(self, parser, name, indent=3D0): + def __init__(self, parser: QAPISchemaParser, + name: str, indent: int =3D 0): super().__init__(parser, name, indent) self.member: Optional['QAPISchemaMember'] =3D None =20 @@ -489,35 +494,34 @@ class NullSection(Section): """ Empty section that signifies the end of a doc block. """ - def append(self, line): + def append(self, line: str) -> None: assert False, "BUG: Text appended after end_comment() called." =20 - def __init__(self, parser, info): + def __init__(self, parser: QAPISchemaParser, info: QAPISourceInfo): # self._parser is used to report errors with QAPIParseError. The # resulting error position depends on the state of the parser. # It happens to be the beginning of the comment. More or less # servicable, but action at a distance. self._parser =3D parser self.info =3D info - self.symbol =3D None + self.symbol: Optional[str] =3D None self.body =3D QAPIDoc.Section(parser) - # dict mapping parameter name to ArgSection - self.args =3D OrderedDict() - self.features =3D OrderedDict() - # a list of Section - self.sections =3D [] + # dicts mapping parameter/feature names to their ArgSection + self.args: Dict[str, QAPIDoc.ArgSection] =3D OrderedDict() + self.features: Dict[str, QAPIDoc.ArgSection] =3D OrderedDict() + self.sections: List[QAPIDoc.Section] =3D [] # the current section self._section =3D self.body self._append_line =3D self._append_body_line =20 - def has_section(self, name): + def has_section(self, name: str) -> bool: """Return True if we have a section with this name.""" for i in self.sections: if i.name =3D=3D name: return True return False =20 - def append(self, line): + def append(self, line: str) -> None: """ Parse a comment line and add it to the documentation. =20 @@ -538,18 +542,18 @@ def append(self, line): line =3D line[1:] self._append_line(line) =20 - def end_comment(self): + def end_comment(self) -> None: self._switch_section(QAPIDoc.NullSection(self._parser)) =20 @staticmethod - def _is_section_tag(name): + def _is_section_tag(name: str) -> bool: return name in ('Returns:', 'Since:', # those are often singular or plural 'Note:', 'Notes:', 'Example:', 'Examples:', 'TODO:') =20 - def _append_body_line(self, line): + def _append_body_line(self, line: str) -> None: """ Process a line of documentation text in the body section. =20 @@ -594,7 +598,7 @@ def _append_body_line(self, line): # This is a free-form documentation block self._append_freeform(line) =20 - def _append_args_line(self, line): + def _append_args_line(self, line: str) -> None: """ Process a line of documentation text in an argument section. =20 @@ -640,7 +644,7 @@ def _append_args_line(self, line): =20 self._append_freeform(line) =20 - def _append_features_line(self, line): + def _append_features_line(self, line: str) -> None: name =3D line.split(' ', 1)[0] =20 if name.startswith('@') and name.endswith(':'): @@ -672,7 +676,7 @@ def _append_features_line(self, line): =20 self._append_freeform(line) =20 - def _append_various_line(self, line): + def _append_various_line(self, line: str) -> None: """ Process a line of documentation text in an additional section. =20 @@ -708,7 +712,11 @@ def _append_various_line(self, line): =20 self._append_freeform(line) =20 - def _start_symbol_section(self, symbols_dict, name, indent): + def _start_symbol_section( + self, + symbols_dict: Dict[str, 'QAPIDoc.ArgSection'], + name: str, + indent: int) -> None: # FIXME invalid names other than the empty string aren't flagged if not name: raise QAPIParseError(self._parser, "invalid parameter name") @@ -720,13 +728,14 @@ def _start_symbol_section(self, symbols_dict, name, i= ndent): self._switch_section(new_section) symbols_dict[name] =3D new_section =20 - def _start_args_section(self, name, indent): + def _start_args_section(self, name: str, indent: int) -> None: self._start_symbol_section(self.args, name, indent) =20 - def _start_features_section(self, name, indent): + def _start_features_section(self, name: str, indent: int) -> None: self._start_symbol_section(self.features, name, indent) =20 - def _start_section(self, name=3DNone, indent=3D0): + def _start_section(self, name: Optional[str] =3D None, + indent: int =3D 0) -> None: if name in ('Returns', 'Since') and self.has_section(name): raise QAPIParseError(self._parser, "duplicated '%s' section" % name) @@ -734,7 +743,7 @@ def _start_section(self, name=3DNone, indent=3D0): self._switch_section(new_section) self.sections.append(new_section) =20 - def _switch_section(self, new_section): + def _switch_section(self, new_section: 'QAPIDoc.Section') -> None: text =3D self._section.text =3D self._section.text.strip() =20 # Only the 'body' section is allowed to have an empty body. @@ -749,7 +758,7 @@ def _switch_section(self, new_section): =20 self._section =3D new_section =20 - def _append_freeform(self, line): + def _append_freeform(self, line: str) -> None: match =3D re.match(r'(@\S+:)', line) if match: raise QAPIParseError(self._parser, @@ -771,14 +780,16 @@ def connect_feature(self, feature: 'QAPISchemaFeature= ') -> None: % feature.name) self.features[feature.name].connect(feature) =20 - def check_expr(self, expr): + def check_expr(self, expr: TopLevelExpr) -> None: if self.has_section('Returns') and 'command' not in expr: raise QAPISemError(self.info, "'Returns:' is only valid for commands") =20 - def check(self): + def check(self) -> None: =20 - def check_args_section(args, what): + def check_args_section( + args: Dict[str, QAPIDoc.ArgSection], what: str + ) -> None: bogus =3D [name for name, section in args.items() if not section.member] if bogus: --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945512771831.8113299684544; Wed, 29 Sep 2021 12:58:32 -0700 (PDT) Received: from localhost ([::1]:50772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfip-0005TK-PP for importer@patchew.org; Wed, 29 Sep 2021 15:58:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWZ-0007wa-LJ for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWW-0006lV-BW for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45: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-408-SQvHoQVfOZu-kqRoa_Wu3g-1; Wed, 29 Sep 2021 15:45:46 -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 8322419253E1; Wed, 29 Sep 2021 19:45:16 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D79419C59; Wed, 29 Sep 2021 19:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944747; 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=Jtp/JKbPV04AKCYORABaL829YO1xhXEIzuagpsk0mqQ=; b=dTzwMyTE2e3cd2SHzF784puKLo1UiLYGvQFAC1eAIYMzsuBpUpIc213xRonTAOm/NQuj/J yCF2jXlUyS+sEPcins739l8C96Te6EuDBMPaQHalwRk/BaXviE9vWnlzeu1SYiJOolECBw J9U1fZZpmiRZP8slmspO6c9AEILmIkI= X-MC-Unique: SQvHoQVfOZu-kqRoa_Wu3g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 11/13] qapi/parser: enable mypy checks Date: Wed, 29 Sep 2021 15:44:26 -0400 Message-Id: <20210929194428.1038496-12-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945513407100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- As always, this can be merged with the previous commit. 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 54ca4483d6d..66253564297 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.parser] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.schema] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16329453578492.0749034833586393; Wed, 29 Sep 2021 12:55:57 -0700 (PDT) Received: from localhost ([::1]:42150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfgK-0007wj-PM for importer@patchew.org; Wed, 29 Sep 2021 15:55:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWb-0007xx-R9 for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56314) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWW-0006mL-TP for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:45: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-440-3bgxMeMRPPyFS8g95pKfEg-1; Wed, 29 Sep 2021 15:45:46 -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 2302B8EC898; Wed, 29 Sep 2021 19:45:18 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAEC119729; Wed, 29 Sep 2021 19:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944748; 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=yK2zQRqyjQfeWhO69DRcjNEI8lUvxV+5zY4py8k9rPo=; b=WWbExifY0rXVCVvuOCz9/6MGg9p+WpSznuXLt9AEcdD3+nrpGmLDbETKvbkAlw7H9V5b7u WiOf42PEuY3BI1lpiCrVuQtdaLPqoAb638rT9bGRBBl1LOFF77cfxWb3b+C0yngUH5++cl eiqq4z2FCXrHRfobmK/t5Su1uN1PG3I= X-MC-Unique: 3bgxMeMRPPyFS8g95pKfEg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 12/13] qapi/parser: Silence too-few-public-methods warning Date: Wed, 29 Sep 2021 15:44:27 -0400 Message-Id: <20210929194428.1038496-13-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945359603100001 Content-Type: text/plain; charset="utf-8" Eh. Not worth the fuss today. There are bigger fish to fry. Signed-off-by: John Snow --- scripts/qapi/parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 8a846079207..7511eedaa35 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -457,8 +457,10 @@ class QAPIDoc: """ =20 class Section: + # pylint: disable=3Dtoo-few-public-methods def __init__(self, parser: QAPISchemaParser, name: Optional[str] =3D None, indent: int =3D 0): + # parser, for error messages about indentation self._parser =3D parser # optional section name (argument/member or section name) @@ -494,6 +496,7 @@ class NullSection(Section): """ Empty section that signifies the end of a doc block. """ + # pylint: disable=3Dtoo-few-public-methods def append(self, line: str) -> None: assert False, "BUG: Text appended after end_comment() called." =20 --=20 2.31.1 From nobody Sun Feb 8 19:44:02 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632945477367163.09489663887553; Wed, 29 Sep 2021 12:57:57 -0700 (PDT) Received: from localhost ([::1]:49196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVfiG-0004Q1-By for importer@patchew.org; Wed, 29 Sep 2021 15:57:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWj-00082E-8V for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:46:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVfWh-0006uF-K0 for qemu-devel@nongnu.org; Wed, 29 Sep 2021 15:46:00 -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-497-X-w54u0yNcetowAvZbnljg-1; Wed, 29 Sep 2021 15:45:54 -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 C65F618C03ED; Wed, 29 Sep 2021 19:45:19 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65FFD19C59; Wed, 29 Sep 2021 19:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632944759; 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=UDYbapQxshJAqowJIOeSLVyA+LsWk2oGYns7Zw7QZJM=; b=iM3mZYEPZZOOzZVtc+0TuPGoDQs9gg/LgNfJdi1Mvy8QUu0KoIt7nhU44ma74w/IjcsG7u sV7HThh051bIFZaIhe62wv0asnfTzg0kCKsXEN1Skh27np/xxsqvd5UtPaNNvVHQLmNnar 1HlyXGMmPzIfoqw2amH3BS+brGCEZ1k= X-MC-Unique: X-w54u0yNcetowAvZbnljg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 13/13] qapi/parser: enable pylint checks Date: Wed, 29 Sep 2021 15:44:28 -0400 Message-Id: <20210929194428.1038496-14-jsnow@redhat.com> In-Reply-To: <20210929194428.1038496-1-jsnow@redhat.com> References: <20210929194428.1038496-1-jsnow@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=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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , Markus Armbruster , Eric Blake , 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) X-ZM-MESSAGEID: 1632945478551100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- This can be merged with the previous commit, if desired. 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 5b7dbc58ad8..b259531a726 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=3Dparser.py, - schema.py, +ignore-patterns=3Dschema.py, =20 =20 [MESSAGES CONTROL] --=20 2.31.1