From nobody Sun May 5 13:42:56 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=1600815573; cv=none; d=zohomail.com; s=zohoarc; b=LOVMU1LdWfwoplequfDhycaQ3i9j49KPz6ZM4yNYFZk2TN4f6Etrl7KStCxz/uNGgrc5CLjA6Ow+R7cKiKRITEchCIbKumG/pDmdzTvCztX8JY4dZGSUGrqeCHKv0k2BmKVbqCwfxhncS6ZZnkhdGO9/pQx3Uk6RI8pKT+/ZW/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815573; 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=1JdZ+TveSLm9WMvQZT4ODeQh1hliceCe++JyKAmqb6c=; b=EslZqTi41HH8QOakC/22Jn9XA0lctL/clECjYLzjauCroZUmm17h+FKtTLBW8S1W5kIrDHrf9LC3AAZeb6va8PXnw9tw+XSZ7/Xej5v/DQE2+l9OlvsWVNwSMY+5OChi20pehGT/zI2Iaq0YoatDpQYw/eQrq+W5xWY3lqySlKw= 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 1600815573532606.6186045729147; Tue, 22 Sep 2020 15:59:33 -0700 (PDT) Received: from localhost ([::1]:38398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrG0-0006lZ-6c for importer@patchew.org; Tue, 22 Sep 2020 18:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2A-0001uh-Or for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:48547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr29-0000IW-1a for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:14 -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-86-ov5rF7CUNMqcuA5kdQrP3g-1; Tue, 22 Sep 2020 18:45:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54912186DD28; Tue, 22 Sep 2020 22:45:09 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EB045C1A3; Tue, 22 Sep 2020 22:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814712; 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=1JdZ+TveSLm9WMvQZT4ODeQh1hliceCe++JyKAmqb6c=; b=ROqTwWxh7kDVxGmEHEkCiwCxnzYToCgszn9vo4rzoHzzEAezsoP9Bwpz31pHmbLX5juSfa deaJsTWk/d0LpxXfroy/usUPGQaHo5/soO7lvqdyt4bq0faQDFr3EVn09u6+KCrHEmGoH4 bnpjJ5J5DvoFsZbBmRcz18OAkYjb7VA= X-MC-Unique: ov5rF7CUNMqcuA5kdQrP3g-1 From: John Snow To: Markus Armbruster Subject: [PATCH 01/25] qapi/schema: add Visitable mixin Date: Tue, 22 Sep 2020 18:44:37 -0400 Message-Id: <20200922224501.4087749-2-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" Python doesn't have anything quite exactly like Traits, Interfaces, or Mixins; but we can approximate it. Add a 'Visitable' class that enforces a type signature for the visit() method; this way, mypy is ensuring that even for otherwise unrelated classes that do not inherit from a common base, this signature will always be forced to be compatible. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 51af0449f5..55434f5c82 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -25,7 +25,13 @@ from .parser import QAPISchemaParser =20 =20 -class QAPISchemaEntity: +class Visitable: + """Abstract duck that suggests a class is visitable.""" + def visit(self, visitor: 'QAPISchemaVisitor') -> None: + raise NotImplementedError + + +class QAPISchemaEntity(Visitable): meta: Optional[str] =3D None =20 def __init__(self, name: str, info, doc, ifcond=3DNone, features=3DNon= e): @@ -136,7 +142,7 @@ def visit_event(self, name, info, ifcond, features, arg= _type, boxed): pass =20 =20 -class QAPISchemaModule: +class QAPISchemaModule(Visitable): def __init__(self, name): self.name =3D name self._entity_list =3D [] @@ -812,7 +818,7 @@ def visit(self, visitor): self.arg_type, self.boxed) =20 =20 -class QAPISchema: +class QAPISchema(Visitable): def __init__(self, fname): self.fname =3D fname parser =3D QAPISchemaParser(fname) --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815887; cv=none; d=zohomail.com; s=zohoarc; b=OP4tc2vHH1RN2TeG7oeN0lbJqnJdW/slCaWZmXgP7Hj/wwEGd331b46Y1CzHzi5kQ0edxDB4yUfozIPsGQc56Jst00OspsILlBXFLNWhZdKqC6PawOkXmNFtdBsRh+ZwDqiawjHLv9hwIo+zIr2P0BUwJxj3vaChkUsi6YpXk5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815887; 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=941wT9PRkLq+7LgTx6a7Ln++uVA8C62LzKgt4uutqu4=; b=m9n7KuWzqqjpQyFGDSHpi4sjToxZRA8Dq0g38LHEl1fH/aBbfEhvbqWl0tpdCq4w17yCy+31mIHpx2oThZKjGIEC8cF5qc1vb/PRChhoLK2llIehOcwsgX5Cuch628x0I7+AEXJ2Vf/Zv6c4zHnJOkm60BJtPkXEcXwPnlLO+J0= 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 1600815887153769.5996987857429; Tue, 22 Sep 2020 16:04:47 -0700 (PDT) Received: from localhost ([::1]:54576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrL3-0005Xx-Pi for importer@patchew.org; Tue, 22 Sep 2020 19:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2E-000203-OG for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2B-0000Kk-Uy for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:18 -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-176-xVehLaCBMpepa1M_ndME-A-1; Tue, 22 Sep 2020 18:45:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E66E1005E77; Tue, 22 Sep 2020 22:45:10 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80A225C1A3; Tue, 22 Sep 2020 22:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814715; 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=941wT9PRkLq+7LgTx6a7Ln++uVA8C62LzKgt4uutqu4=; b=KOXVY82krVeOqnmiZOj+BYS+Szic9Bb4wK5CjI5YCjVhFVK42Vb8tm8d+ZaDAXMTU9Qip6 +mptmJIdanAMZiV7/Nqxvy5ul3C4RIkmzvtnCaj3B1PwouUwOl2lHfZCGkwoSC0sI8XP8y ZgRBOadGq+a41JuSKuk+gPQBb0jXR3E= X-MC-Unique: xVehLaCBMpepa1M_ndME-A-1 From: John Snow To: Markus Armbruster Subject: [PATCH 02/25] qapi/schema.py: Move meta-type into class instances Date: Tue, 22 Sep 2020 18:44:38 -0400 Message-Id: <20200922224501.4087749-3-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We are using meta as a class variable, but union types use this as a mutable value which changes the value for the class, not the instance. Use the empty string as the default/empty value for ease of typing. It is still false-ish, so it will work just fine. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 55434f5c82..0201b42095 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -17,7 +17,6 @@ import os import re from collections import OrderedDict -from typing import Optional =20 from .common import c_name, POINTER_SUFFIX from .error import QAPISourceError, QAPISemError @@ -32,8 +31,6 @@ def visit(self, visitor: 'QAPISchemaVisitor') -> None: =20 =20 class QAPISchemaEntity(Visitable): - meta: Optional[str] =3D None - def __init__(self, name: str, info, doc, ifcond=3DNone, features=3DNon= e): assert name is None or isinstance(name, str) for f in features or []: @@ -51,6 +48,15 @@ def __init__(self, name: str, info, doc, ifcond=3DNone, = features=3DNone): self._ifcond =3D ifcond or [] self.features =3D features or [] self._checked =3D False + self._meta =3D '' + + @property + def meta(self) -> str: + return self._meta + + @meta.setter + def meta(self, value: str) -> None: + self._meta =3D value =20 def c_name(self): return c_name(self.name) @@ -212,8 +218,6 @@ def describe(self): =20 =20 class QAPISchemaBuiltinType(QAPISchemaType): - meta =3D 'built-in' - def __init__(self, name, json_type, c_type): super().__init__(name, None, None) assert not c_type or isinstance(c_type, str) @@ -221,6 +225,7 @@ def __init__(self, name, json_type, c_type): 'value') self._json_type_name =3D json_type self._c_type_name =3D c_type + self._meta =3D 'built-in' =20 def c_name(self): return self.name @@ -245,8 +250,6 @@ def visit(self, visitor): =20 =20 class QAPISchemaEnumType(QAPISchemaType): - meta =3D 'enum' - def __init__(self, name, info, doc, ifcond, features, members, prefix): super().__init__(name, info, doc, ifcond, features) for m in members: @@ -255,6 +258,7 @@ def __init__(self, name, info, doc, ifcond, features, m= embers, prefix): assert prefix is None or isinstance(prefix, str) self.members =3D members self.prefix =3D prefix + self._meta =3D 'enum' =20 def check(self, schema): super().check(schema) @@ -289,13 +293,12 @@ def visit(self, visitor): =20 =20 class QAPISchemaArrayType(QAPISchemaType): - meta =3D 'array' - def __init__(self, name, info, element_type): super().__init__(name, info, None) assert isinstance(element_type, str) self._element_type_name =3D element_type self.element_type =3D None + self._meta =3D 'array' =20 def check(self, schema): super().check(schema) @@ -344,7 +347,7 @@ def __init__(self, name, info, doc, ifcond, features, # flat union has base, variants, and no local_members # simple union has local_members, variants, and no base super().__init__(name, info, doc, ifcond, features) - self.meta =3D 'union' if variants else 'struct' + self._meta =3D 'union' if variants else 'struct' assert base is None or isinstance(base, str) for m in local_members: assert isinstance(m, QAPISchemaObjectTypeMember) @@ -456,8 +459,6 @@ def visit(self, visitor): =20 =20 class QAPISchemaAlternateType(QAPISchemaType): - meta =3D 'alternate' - def __init__(self, name, info, doc, ifcond, features, variants): super().__init__(name, info, doc, ifcond, features) assert isinstance(variants, QAPISchemaVariants) @@ -465,6 +466,7 @@ def __init__(self, name, info, doc, ifcond, features, v= ariants): variants.set_defined_in(name) variants.tag_member.set_defined_in(self.name) self.variants =3D variants + self._meta =3D 'alternate' =20 def check(self, schema): super().check(schema) @@ -716,8 +718,6 @@ def __init__(self, name, info, typ, ifcond=3DNone): =20 =20 class QAPISchemaCommand(QAPISchemaEntity): - meta =3D 'command' - def __init__(self, name, info, doc, ifcond, features, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig): @@ -733,6 +733,7 @@ def __init__(self, name, info, doc, ifcond, features, self.boxed =3D boxed self.allow_oob =3D allow_oob self.allow_preconfig =3D allow_preconfig + self._meta =3D 'command' =20 def check(self, schema): super().check(schema) @@ -779,14 +780,13 @@ def visit(self, visitor): =20 =20 class QAPISchemaEvent(QAPISchemaEntity): - meta =3D 'event' - def __init__(self, name, info, doc, ifcond, features, arg_type, boxed): super().__init__(name, info, doc, ifcond, features) assert not arg_type or isinstance(arg_type, str) self._arg_type_name =3D arg_type self.arg_type =3D None self.boxed =3D boxed + self._meta =3D 'event' =20 def check(self, schema): super().check(schema) --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600814833; cv=none; d=zohomail.com; s=zohoarc; b=UrlhVx9br8Kqqr5FJrV0dxhI/uAjtjaShZopxDLfVX6hezYJwVjCndTBVZQ4xA1/i+Szt8DDbAsBwPs3ryfq1MOg3qP0KZ38QWUnLzVp0ZU/b2lj/T7j2XD+HWOwcr+OZRINyEsjqEwB7F8Isiu1Fuja0q46BeuPtSy23knlo7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600814833; 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=PlNM83s6DVVzNRgOd3tBHRT+FdvTT/OuXY5mruJgZU8=; b=Id6v5PMjwgyfllE15wVB618Eblzflx8jvKFcKTVA21KmMNttxD6uoA8+2Mf8GOeCGMz8fw7Kw1jL9e2OJgQckIgTbymmGC29yl97CYRqGqe0PRpFV5jL6Lf5e5RhQWbLb46gNLgOwc6Lfzq093VBkjfCp6sk93Gph0G0M1/QWS4= 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 160081483378453.055385028496744; Tue, 22 Sep 2020 15:47:13 -0700 (PDT) Received: from localhost ([::1]:48062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr42-0003tW-Pd for importer@patchew.org; Tue, 22 Sep 2020 18:47:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2C-0001wj-Rc for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2B-0000KJ-82 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-501-lL9xakWLMR2VfU6EphOEoQ-1; Tue, 22 Sep 2020 18:45:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A20481CBEB; Tue, 22 Sep 2020 22:45:11 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B5D65C1A3; Tue, 22 Sep 2020 22:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814714; 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=PlNM83s6DVVzNRgOd3tBHRT+FdvTT/OuXY5mruJgZU8=; b=JTsCFAi1XSd9EUVpdOtipbsUEsP6aaQBFKHu2pdvaz2zXDAfvH+RksMTCX9zcqvPznrSTp ckiVPMfkJsUwez45d15WyHnSeTEI8X3NA9by/lgXlHPrdr+3iNUhJ1pPtDm/Rkvh9+IjXf +b1OSeq+UYUso96nI9vWMcKWU7keSD8= X-MC-Unique: lL9xakWLMR2VfU6EphOEoQ-1 From: John Snow To: Markus Armbruster Subject: [PATCH 03/25] qapi/schema.py: add assert in stub methods Date: Tue, 22 Sep 2020 18:44:39 -0400 Message-Id: <20200922224501.4087749-4-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Instead of pass (an implicit return none), use raise NotImplementedError to mark a function as abstract -- one that doesn't return. This allows us to correctly type the stub. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 0201b42095..a53631e660 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -176,8 +176,8 @@ def visit(self, visitor): class QAPISchemaType(QAPISchemaEntity): # Return the C type for common use. # For the types we commonly box, this is a pointer type. - def c_type(self): - pass + def c_type(self) -> str: + raise NotImplementedError() =20 # Return the C type to be used in a parameter list. def c_param_type(self): @@ -187,8 +187,8 @@ def c_param_type(self): def c_unboxed_type(self): return self.c_type() =20 - def json_type(self): - pass + def json_type(self) -> str: + raise NotImplementedError() =20 def alternate_qtype(self): json2qtype =3D { --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600814964; cv=none; d=zohomail.com; s=zohoarc; b=RAZzvyihAiPARDLBTRtv6dA5q1rYQwHZc4yZHe1PHkfgnDQqRnxSO1zgrwqzMJeVD62MVi2SPuJLv75oHpZMiu5xvwHSGN158XHOJHuL+HbLPN/zWzzdg+cbAdyK2w6UQFUyLX8/pSQlt7DSeGy5nue6tA+76pstDiRKKwiIC7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600814964; 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=3hwPPP7ajxXWgMYSvqQEb3O2rXxN2d7kmT45cRPWKTA=; b=QRDRDiAn82iw91C5TjYLAKsf4zzJKFAt9Dgk7EjZzT8vPcYU+EgqFFyCYcr1rpq24A1JSeZ0Ta8jb3hTjeXtN0IC8tu2n0MyldjGUzc9I+/A+9yZmn4+/Al2yF1JcH12+opARmzZwiYTTHICd06dPMU6VMddfahwNzS1fGuUZps= 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 1600814964699925.433421359495; Tue, 22 Sep 2020 15:49:24 -0700 (PDT) Received: from localhost ([::1]:56364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr6B-0007N1-Bz for importer@patchew.org; Tue, 22 Sep 2020 18:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2G-00021o-5j for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2E-0000Mk-8Z for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45: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-313-kvonn3BgPk6yGgNOGS0p3w-1; Tue, 22 Sep 2020 18:45:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C584425DD; Tue, 22 Sep 2020 22:45:12 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76BAD5C1A3; Tue, 22 Sep 2020 22:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814717; 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=3hwPPP7ajxXWgMYSvqQEb3O2rXxN2d7kmT45cRPWKTA=; b=Ffv2JlN6oyFwBfFNi4b/FPKQiU+M1cH+h0KeNkkeIeh5tM8nQjOIRoSNfiqxu7T38nr5Pi q/npSrKHtWRY5Ro5WTwfzP3MD+wAJ/lz2QUER9xUIR1b4sTJTWpxG1z2RnRKynX6xv+p9f YHitU9k6/MnBITVR6WCMsm4fXExxwsY= X-MC-Unique: kvonn3BgPk6yGgNOGS0p3w-1 From: John Snow To: Markus Armbruster Subject: [PATCH 04/25] qapi/schema.py: constrain QAPISchemaObjectType base type Date: Tue, 22 Sep 2020 18:44:40 -0400 Message-Id: <20200922224501.4087749-5-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" Re-order check slightly so we can provide a stronger guarantee on the typing of the base field. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a53631e660..3aa842be08 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -378,14 +378,14 @@ def check(self, schema): =20 seen =3D OrderedDict() if self._base_name: - self.base =3D schema.resolve_type(self._base_name, self.info, - "'base'") - if (not isinstance(self.base, QAPISchemaObjectType) - or self.base.variants): + base =3D schema.resolve_type(self._base_name, self.info, "'bas= e'") + if (not isinstance(base, QAPISchemaObjectType) + or base.variants): raise QAPISemError( self.info, "'base' requires a struct type, %s isn't" - % self.base.describe()) + % base.describe()) + self.base =3D base self.base.check(schema) self.base.check_clash(self.info, seen) for m in self.local_members: --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815312; cv=none; d=zohomail.com; s=zohoarc; b=Z5cETtAKiXu/yFtXXwr1RTRvCRJk+BfB0ZFtSiPyxMQSZafBggE8nf40XXeicujt0Zw+FM7JSMDs/REBirSVMaG0/eTWjO2mxuRkl7bEMraPdVa42rABIOjmAQeXbG6iS5ORVDIKrpJjHTo2LSq1z8x/4pxA01oA6qGgwMO/u3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815312; 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=aLnFKxgptgJYIplUPNbzeRzKKd+cN8uPYcwU0cQed3I=; b=fxc3ZRToa2V2M1J5U3GHPTnxIkug5rYcUlHjcSlTGm4Awk4S4JCWDKnM/Xt8xyBTAI5BLWEk0Qgti9mzUbYNlphaIz5GTlCkQJw7skMHgjrph9MDKND1DDm8t63E+orNCzNaEo/sabvL6U/U5gIXXa3py/gvMK6+mH86LtJZCuw= 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 1600815312129155.43710097877772; Tue, 22 Sep 2020 15:55:12 -0700 (PDT) Received: from localhost ([::1]:50130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrBm-0008AG-Pm for importer@patchew.org; Tue, 22 Sep 2020 18:55:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2I-00023q-2Z for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2E-0000N3-Dh for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:21 -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-374-9mJWSSsqNkOEQ65_p4PO-w-1; Tue, 22 Sep 2020 18:45:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 43F6981F00A; Tue, 22 Sep 2020 22:45:13 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76DA05C1A3; Tue, 22 Sep 2020 22:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814717; 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=aLnFKxgptgJYIplUPNbzeRzKKd+cN8uPYcwU0cQed3I=; b=GDdwg/SI4qVgZ8Gj6pemP5I+LsHbgXQfHCCWF2Q7reZb7xnMpFTpgfNF7pyddCUUX2wvPn WLq0XDTLdwEZZYPWbktr7ACsuqbI3eRgKPHtHF23ZjcipES0lTlLl+5GCu3jLStws9uEBU wjcHyW/jQ+JkeSRGrE2KaJZwsoDmoW8= X-MC-Unique: 9mJWSSsqNkOEQ65_p4PO-w-1 From: John Snow To: Markus Armbruster Subject: [PATCH 05/25] qapi/schema.py: constrain QAPISchemaObjectTypeMember arg_type type Date: Tue, 22 Sep 2020 18:44:41 -0400 Message-Id: <20200922224501.4087749-6-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" Re-order the check method slightly in order to provide stronger typing for the arg_type field. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3aa842be08..c9a62711c2 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -738,13 +738,14 @@ def __init__(self, name, info, doc, ifcond, features, def check(self, schema): super().check(schema) if self._arg_type_name: - self.arg_type =3D schema.resolve_type( + arg_type =3D schema.resolve_type( self._arg_type_name, self.info, "command's 'data'") - if not isinstance(self.arg_type, QAPISchemaObjectType): + if not isinstance(arg_type, QAPISchemaObjectType): raise QAPISemError( self.info, "command's 'data' cannot take %s" - % self.arg_type.describe()) + % arg_type.describe()) + self.arg_type =3D arg_type if self.arg_type.variants and not self.boxed: raise QAPISemError( self.info, --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815202; cv=none; d=zohomail.com; s=zohoarc; b=WluYNEJSR5SAu3fon80OMQAQlOd2ppJ6251t5rqSOPgpqyAn3hRr2imF3QpUQeHqow5LrHa49titU/cfVHowJ4WEcSUBZA5+MSEGvwvMBuIdvfYH+GHKKHGbW8X9gHtwJaGzmRxz+jCq3pwzR7YfBmombZ7BFhHB4iymd1MJXno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815202; 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=nZAEtLKopk829H7OKJ8rtnLJ/Xh1HLCsfdaUY3bhzkY=; b=bxWnXLM1tUhvv1nVCOyHDy4YBfNomKbRywsNzrozJTfh+k4WuTi+mWYyJH+RrbBYxbUSzHwhOdbGw9uph2oW23l4kGQRXk1vluSfx53Ncx50ZQRS/qWWiilUGtujVItUgIvnRljRglcYA3rnCi+kFKQwZhzbm63SiIf8hOObGak= 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 1600815202292937.2238489877046; Tue, 22 Sep 2020 15:53:22 -0700 (PDT) Received: from localhost ([::1]:41724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrA1-0004eZ-0Y for importer@patchew.org; Tue, 22 Sep 2020 18:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2G-00022y-Jr for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:20 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:38267 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2E-0000Mc-8v for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:20 -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-456-H1iVNuZ_OIylNndb7AhkkA-1; Tue, 22 Sep 2020 18:45:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 402751005E66; Tue, 22 Sep 2020 22:45:14 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E17F5C1A3; Tue, 22 Sep 2020 22:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814717; 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=nZAEtLKopk829H7OKJ8rtnLJ/Xh1HLCsfdaUY3bhzkY=; b=WISJy4peJ6hLVkwu0G228byFlHbs+TlcuA01nD55SWMm9qp+S4Ez0+jv0cSz9iLpon/mst zkmZYANx+/baRNfb6IHcymg9JaUB9dgA2Og+m8+KdyPlVFy9GtTbT67T283g37wIvtdEfC 3GAeqC8TzNA+nMXA4liNWFtN8WRYmAo= X-MC-Unique: H1iVNuZ_OIylNndb7AhkkA-1 From: John Snow To: Markus Armbruster Subject: [PATCH 06/25] qapi/schema.py: constrain QAPISchemaEvent arg_type type Date: Tue, 22 Sep 2020 18:44:42 -0400 Message-Id: <20200922224501.4087749-7-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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=205.139.110.61; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 17:00:46 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index c9a62711c2..aaf20f776b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -792,13 +792,14 @@ def __init__(self, name, info, doc, ifcond, features,= arg_type, boxed): def check(self, schema): super().check(schema) if self._arg_type_name: - self.arg_type =3D schema.resolve_type( + arg_type =3D schema.resolve_type( self._arg_type_name, self.info, "event's 'data'") - if not isinstance(self.arg_type, QAPISchemaObjectType): + if not isinstance(arg_type, QAPISchemaObjectType): raise QAPISemError( self.info, "event's 'data' cannot take %s" - % self.arg_type.describe()) + % arg_type.describe()) + self.arg_type =3D arg_type if self.arg_type.variants and not self.boxed: raise QAPISemError( self.info, --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600816019; cv=none; d=zohomail.com; s=zohoarc; b=SJnM4PPuKD1h9GMZNU5IGYzo4dKU2D3hybmhNyBmhdPYIeWLLD2VAR8RuiK/Nh3aaEMgulYWCoprzTioKQONitNkpMhKW/rtnaZwyX6uwKB1MhXUUv6TdyaMVwu7dueFeNUuyHGxMOLrNuokVBKHmxXsN9BAIyEWdJ+QkmOjXZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600816019; 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=4i0nXnx6nFKikPewz7URO7NseWYpQvmkJ8S26wzTqRc=; b=ZHts7D5xw412hrGfMn1p4Fa06Hl7Q3Wx7sLE84pwEQ8mycVUeM1qQA6ECwPn5x4LYy8ZAO0b0l4c7A9cFKg+rozrzMM7qBlINlrxFFpCF7eajMlomIk/P8FZ+bqdtOmFtJ89gPa9eq53zEEr9FPHelz4TY+MxM8fR4GP8A15e3Y= 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 160081601940290.10441883982867; Tue, 22 Sep 2020 16:06:59 -0700 (PDT) Received: from localhost ([::1]:34012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrNC-0000W4-6a for importer@patchew.org; Tue, 22 Sep 2020 19:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2L-000241-49 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2E-0000NE-MH for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-CJh2crTLO_GEAYFQ5ilhcA-1; Tue, 22 Sep 2020 18:45:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 385EB1074641; Tue, 22 Sep 2020 22:45:15 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A57D5C1A3; Tue, 22 Sep 2020 22:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814717; 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=4i0nXnx6nFKikPewz7URO7NseWYpQvmkJ8S26wzTqRc=; b=InkBcOeE4zWDZzW1zjJ0NPoMqGOsITqdzUv3dj7H0PxFyOnS1k0A4zo0atW8x8HNkqUVYw 9jRN5xq2YhtWpwYCOdliD2tU526YuFvz65+8MRsjFvawF6yxaxQfe4hgsuXgSzxltkYWGG pDe+30EG06V/M9qDAAt4AR/KM8VL7ME= X-MC-Unique: CJh2crTLO_GEAYFQ5ilhcA-1 From: John Snow To: Markus Armbruster Subject: [PATCH 07/25] qapi/schema.py: constrain tag_member type Date: Tue, 22 Sep 2020 18:44:43 -0400 Message-Id: <20200922224501.4087749-8-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index aaf20f776b..15ff441660 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -546,15 +546,18 @@ def set_defined_in(self, name): =20 def check(self, schema, seen): if not self.tag_member: # flat union - self.tag_member =3D seen.get(c_name(self._tag_name)) + tag_member =3D seen.get(c_name(self._tag_name)) base =3D "'base'" # Pointing to the base type when not implicit would be # nice, but we don't know it here - if not self.tag_member or self._tag_name !=3D self.tag_member.= name: + if not tag_member or self._tag_name !=3D tag_member.name: raise QAPISemError( self.info, "discriminator '%s' is not a member of %s" % (self._tag_name, base)) + + assert isinstance(tag_member, QAPISchemaObjectTypeMember) + self.tag_member =3D tag_member # Here we do: base_type =3D schema.lookup_type(self.tag_member.defined_in) assert base_type --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600816121; cv=none; d=zohomail.com; s=zohoarc; b=UMLyhfj9ssnCWzJPHLMf1w8+s34uyRyqR+0bkikW54WqhzCYqrLFQl9qRRqAZ8yTLMsmHhy8CqNowJs+G2b9ZIsULOKW/XxWrNm1DlwqQDH0d9Rk2+ECD22IA9J7+Pt6tifr6bP1PB+PZeOgGZ21ZpfHinwr62Q0jvJQbDwOYVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600816121; 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=m2wnSuF5Yn/tNOD4ZWZZRfLcSn4kOF5IO4Vklwawc9Q=; b=foURkWG3BipMd+2W8ac16mHYD4kq7/joMIukWcxGk0OAqB5lOjD59YAbf95zeI25SfL1w0Pi0uAoARZXtACBGkD2oZDNmiGHMAIEMPoPXLRmp16TTCiendjpiioPuKg4o0HwxruWJuC3r2kKU/H34eYfAWHTauR2SeqfE51i8II= 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 1600816121936248.02584093139455; Tue, 22 Sep 2020 16:08:41 -0700 (PDT) Received: from localhost ([::1]:39220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrOq-0002nV-Jr for importer@patchew.org; Tue, 22 Sep 2020 19:08:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2X-00029L-Mn for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2F-0000Nq-PI for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-292-MS1xf-0WPBOleLBo9njFpg-1; Tue, 22 Sep 2020 18:45:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 328801074643; Tue, 22 Sep 2020 22:45:16 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63ED55C1A3; Tue, 22 Sep 2020 22:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814718; 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=m2wnSuF5Yn/tNOD4ZWZZRfLcSn4kOF5IO4Vklwawc9Q=; b=dpfEoXGXweVC930pdCvtswjILO0lDv3ZE++GUY1F6B0gjG7x0ynvjINSYNNZQDwrEShlWK sliIKk3ANrSIQx6ACm5BNqPisMbr8uPMoDu1a0+hK7DQM5LwZTIhhh8ZeXNdmudWOkAKii PY6zHcNw4xfAhajDAhqva4BzJt0TAgk= X-MC-Unique: MS1xf-0WPBOleLBo9njFpg-1 From: John Snow To: Markus Armbruster Subject: [PATCH 08/25] qapi/schema.py: Allow alternate_type to assert Date: Tue, 22 Sep 2020 18:44:44 -0400 Message-Id: <20200922224501.4087749-9-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 is generally nicer to just let things fail, because it makes the static type hints less infected with Optional[T], where a future programmer using the library has to wonder what that means. Let errors be errors. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 15ff441660..a84d8549a4 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -199,7 +199,7 @@ def alternate_qtype(self): 'boolean': 'QTYPE_QBOOL', 'object': 'QTYPE_QDICT' } - return json2qtype.get(self.json_type()) + return json2qtype[self.json_type()] =20 def doc_type(self): if self.is_implicit(): @@ -480,8 +480,9 @@ def check(self, schema): types_seen =3D {} for v in self.variants.variants: v.check_clash(self.info, seen) - qtype =3D v.type.alternate_qtype() - if not qtype: + try: + qtype =3D v.type.alternate_qtype() + except KeyError: raise QAPISemError( self.info, "%s cannot use %s" --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815121; cv=none; d=zohomail.com; s=zohoarc; b=FXE5ltKq7FjFlzZWS6deBayePCKgpcd/E7rDldhW5C6UQ/IY2Op4v7iUrHONddIeDJWuTktvUdM/6ukJBDUyvFeQAR24w0gQKFdRQNk09iTmIwTDe0fdMQ2R0mfe2LJWSUsymeRGQW5Hpbb4JUjC++Xkbb01dIGOBrjZDw3uX4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815121; 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=Vg9UpVpOIFGZP/PFAC6mOMwuyzcjipA1odkHyeJaY84=; b=PPpiSa9chDlU+TRAWA7sWGJD/dtz22KVDCws85Y0qCzL//AR+OBUr7g7es3X3WNXZCbyAI7wd9R7bBhLHQG9XAN0BwUMWQZkqDXmsuSAGg8aBwW/omvx400cGmg8bdn8GipsU2f/oNbPfWHwvfhq5ahqtUNa/e/CDpIcy6t6a7w= 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 1600815121541851.927214290209; Tue, 22 Sep 2020 15:52:01 -0700 (PDT) Received: from localhost ([::1]:36548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr8h-0002Wp-UJ for importer@patchew.org; Tue, 22 Sep 2020 18:52:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2J-00023u-9t for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2G-0000OE-Si for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-29-6P_BKxHSPEK1Usp9Sr-9_Q-1; Tue, 22 Sep 2020 18:45:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3052B81CAFC; Tue, 22 Sep 2020 22:45:17 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FAA55C1A3; Tue, 22 Sep 2020 22:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814720; 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=Vg9UpVpOIFGZP/PFAC6mOMwuyzcjipA1odkHyeJaY84=; b=UrE3Y38rnIVBm5ET9KCkJAVf9y7x2IOHfkF33/KkiWj94t6hsI8N+crl5uMmdRVkUPggws mPuM+6lUz8tqhrdMlt9XQG0Rrx/reQonog9gwIskQyaOvosChcBVqsuPqF2gnRxqtIrXZY 2WxAfypUCkaECq4Y/e70g7HDxXunBIc= X-MC-Unique: 6P_BKxHSPEK1Usp9Sr-9_Q-1 From: John Snow To: Markus Armbruster Subject: [PATCH 09/25] qapi/schema.py: remove superfluous assert Date: Tue, 22 Sep 2020 18:44:45 -0400 Message-Id: <20200922224501.4087749-10-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We'll actually get a better error message by just letting the dictionary lookup fail. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a84d8549a4..b35f741c6f 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -892,7 +892,6 @@ def _make_module(self, fname): =20 def module_by_fname(self, fname): name =3D self._module_name(fname) - assert name in self._module_dict return self._module_dict[name] =20 def _def_include(self, expr, info, doc): --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815259; cv=none; d=zohomail.com; s=zohoarc; b=hdfewysSVgH1VUD4+wErL+33JhiUKKEaCnFclzqSsnblGYXFYxInV6nZEPhdHrfXJ3XU9eB4xspdpyA4M5SvvbQJ6Ovozp3xhdSjlBk6VK6kWn8UwSISj++ImIQTtstEH2cnHDusWt8wj74JE4wU69I4LWyof7ktzcqcsXOgQoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815259; 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=RGbEU/7xtBdqfDV616a4d85mdHqc/WPbCfrSzctqo9M=; b=NjSoz+7KBJfKxJT15oWUm1QqS68lieIlykNrSAdVKqMEyH9ZJjh4WVkrxPvQbFkiWwslCoCHnFQg3Zzr5Y4AZc4ajsJX6wgn4rehJOwODr8zGrrwQzO4TYiTM0B3FVfYCLseAO9eb/CpjABqKoOJ8x01GtiM72z25/3HrnpMGG0= 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 1600815259085954.297777897472; Tue, 22 Sep 2020 15:54:19 -0700 (PDT) Received: from localhost ([::1]:44948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrAv-00063A-M7 for importer@patchew.org; Tue, 22 Sep 2020 18:54:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2M-00024F-Ju for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44225) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2I-0000P9-1N for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:26 -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-225-its6LuBsP5-elTdm9CsvRw-1; Tue, 22 Sep 2020 18:45:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5CFF81005E64; Tue, 22 Sep 2020 22:45:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B49A5C1A3; Tue, 22 Sep 2020 22:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814721; 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=RGbEU/7xtBdqfDV616a4d85mdHqc/WPbCfrSzctqo9M=; b=PnaUFblZeWbtb522u/OUHY7JEjNVxq2G6DFnasHYVLo00gjavyPn44f1s33tPWYhsrMy1s 4j8lDRsAW4Rg/2zly4Jm50llArAlUQEV530m2cyxpSoFHHzwuX/L0qPYVOOrBQv+hHLtP3 WmQan3LPm3j49txGdaeba68CkbpOp4E= X-MC-Unique: its6LuBsP5-elTdm9CsvRw-1 From: John Snow To: Markus Armbruster Subject: [PATCH 10/25] qapi/schema.py: Add assertion to ifcond property Date: Tue, 22 Sep 2020 18:44:46 -0400 Message-Id: <20200922224501.4087749-11-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" ifcond's initialization allows a fairly confusing type, but we want to assert that after the QAPISchema is built, this always returns a List[str]. Add an assertion to allow us to say that. (Note: Technically, I only assert that it's a list -- but type hints that will be added later will make it clear that the only possible list we could have here is a list[str], and this assertion is sufficient to prove the point to mypy.) Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index b35f741c6f..62b1a7e890 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -88,7 +88,7 @@ def set_module(self, schema): =20 @property def ifcond(self): - assert self._checked + assert self._checked and isinstance(self._ifcond, list) return self._ifcond =20 def is_implicit(self): --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815498; cv=none; d=zohomail.com; s=zohoarc; b=IFvS60g5OIuSIBCUbQhkjoCN0VmYvc4a1p8SZ7+0Ggc0fH9ueDvl0m379O5UybKs1imgXd6L3IrXKBnwjomlwjx802HlGS0gXohzdNKsazoaWWCN7QWgZ6Df7Q7/ljIQ92neOqxdqzYXJoT26scPoSAzPRJYDQ5gCcBWHY8Re0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815498; 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=Vkvv1cb8+m3KMT4QTk8T1JEPJ7jJa4e0nDR3l/fNNhM=; b=kjDF6YBnWApVfd8CmnBOmARf6e9FFU1xGkboTI3t/KCtcI5mjQnF0VDxlEKafJH1aggQVNPpF4CP1dMK1OJhBED/IdHjerHciRMRdoP3e3Iz0Vo+xgsVxR0RVGe00odywF6zI9sEHzXb5xuI8S/orcbe8bJeN/XD7IXMbT56R0Q= 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 1600815498156659.3553107475931; Tue, 22 Sep 2020 15:58:18 -0700 (PDT) Received: from localhost ([::1]:33362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrEm-0004d8-L7 for importer@patchew.org; Tue, 22 Sep 2020 18:58:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2c-0002BU-4z for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:33335 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2K-0000PU-Pa for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-271-rCwE_BeKOkSZRPgTMbuQkw-1; Tue, 22 Sep 2020 18:45:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 928C2801AE8; Tue, 22 Sep 2020 22:45:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id A34385C1A3; Tue, 22 Sep 2020 22:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814722; 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=Vkvv1cb8+m3KMT4QTk8T1JEPJ7jJa4e0nDR3l/fNNhM=; b=ccRPPNzG/uUGV/4txfSKssOU5eAnXG2zEZliK9gvctzslFmZp+cDD3d9WhI5YRQkrFzlrZ Hm26HTzZqav7wNHgiB/THTzNHz9tm7Iy/NjIjLhCm9MtVSWXrb/A3qt/2JXIbQOq/FsN0o Jg9Wxn951MMAVdmA+E7bez6hde4ftJ4= X-MC-Unique: rCwE_BeKOkSZRPgTMbuQkw-1 From: John Snow To: Markus Armbruster Subject: [PATCH 11/25] qapi/schema.py: Constrain type of QAPISchemaObjectType members field Date: Tue, 22 Sep 2020 18:44:47 -0400 Message-Id: <20200922224501.4087749-12-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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=207.211.31.81; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 17:01:22 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" This must always be QAPISchemaObjectTypeMember, and we do check and enforce this -- but because the seen dict is invariant and check methods need to operate in terms of a more abstract type, we need to tell the type system to believe us. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 62b1a7e890..57343a1002 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -17,6 +17,7 @@ import os import re from collections import OrderedDict +from typing import cast, List =20 from .common import c_name, POINTER_SUFFIX from .error import QAPISourceError, QAPISemError @@ -391,7 +392,10 @@ def check(self, schema): for m in self.local_members: m.check(schema) m.check_clash(self.info, seen) - members =3D seen.values() + + # check_clash is abstract, but local_members is asserted to be + # Sequence[QAPISchemaObjectTypeMember]. Cast to the narrower type. + members =3D cast(List[QAPISchemaObjectTypeMember], list(seen.value= s())) =20 if self.variants: self.variants.check(schema, seen) --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815360; cv=none; d=zohomail.com; s=zohoarc; b=DkS/aX+spHzvh4vgXSRYzjNA8lUVZGO+3BNmBQexXTIatgn+lnBH7JmC5kGgu2rOa5UWt9WxV7m1LsgkRV++4Kwoin2x4YzDoXzIV3w3H/WhFyBnbcxzG11CeLYlfHLZsx2cIuCb+Pxtxw8x9yFBuNG1klzl8mcgKCW6u+Uh6vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815360; 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=OBijeGAKoDq7dT3e/GZlWqc9oTnLltAN10cidVcI3Ck=; b=Kb1zijokFGoeBjhyzkwNq/ruq3Hlkd+34Ney2V+mIRs35bh4N+dtP3Ka90YhW6UhMwXHFtdmLyOBJp258sBNbRzQkkb7Oan0J46KS59A/OMC4vc88U6Me5yBXrCcAiAYQrI0K+cue0P0bH5ccq1XtE3oRKFntMiA9/rQGnvdIF0= 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 1600815360870737.7433855320628; Tue, 22 Sep 2020 15:56:00 -0700 (PDT) Received: from localhost ([::1]:53228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrCZ-00015F-JV for importer@patchew.org; Tue, 22 Sep 2020 18:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2U-00027U-OC for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2K-0000Ph-Qd for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:30 -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-345-DOLV6BUYP2ugOshofI2UPQ-1; Tue, 22 Sep 2020 18:45:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E79D1005E64; Tue, 22 Sep 2020 22:45:20 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDFE15C1A3; Tue, 22 Sep 2020 22:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814723; 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=OBijeGAKoDq7dT3e/GZlWqc9oTnLltAN10cidVcI3Ck=; b=PbXaK48k0uteNSeueveTpFyecEy97qi4/KVOiqIbiwl4lPd+dAb2LY6yIMA+zEy/Gh77zQ VB8RovIoPEW/ssTsCZVXxCCqiaCEn9i/dKJt6UKOVQt1qvbbz1+EDxWSJUzwtUSkmxK0c6 /aiySaLn2n/Ipg7/DAaE0F0TeUb7INU= X-MC-Unique: DOLV6BUYP2ugOshofI2UPQ-1 From: John Snow To: Markus Armbruster Subject: [PATCH 12/25] qapi/schema.py: remove 'and' from non-bool rvalue expressions Date: Tue, 22 Sep 2020 18:44:48 -0400 Message-Id: <20200922224501.4087749-13-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" There's nothing inherently wrong with using 'and' in this manner, but the type returned is more loose than you might expect. Any value can be false-ish, so mypy assumes that the type of the expression must be the Union of both types, because a type can always be false-ish. To tighten the static analysis type, we have to use the slightly clunkier but more formally correct ternary. Fixes these errors: qapi/schema.py:103: error: Argument 1 to "module_by_fname" of "QAPISchema" = has incompatible type "Union[QAPISourceInfo, str]"; expected "Optional[str]" qapi/schema.py:380: error: Argument 3 to "resolve_type" of "QAPISchema" has incompatible type "Union[QAPISourceInfo, str]"; expected "Union[str, Callable[[Optional[QAPISourceInfo]], str], None]" Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 57343a1002..943f234ee2 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -81,7 +81,7 @@ def check_doc(self): =20 def _set_module(self, schema, info): assert self._checked - self._module =3D schema.module_by_fname(info and info.fname) + self._module =3D schema.module_by_fname(info.fname if info else No= ne) self._module.add_entity(self) =20 def set_module(self, schema): @@ -305,7 +305,7 @@ def check(self, schema): super().check(schema) self.element_type =3D schema.resolve_type( self._element_type_name, self.info, - self.info and self.info.defn_meta) + self.info.defn_meta if self.info else None) assert not isinstance(self.element_type, QAPISchemaArrayType) =20 def set_module(self, schema): --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815449; cv=none; d=zohomail.com; s=zohoarc; b=DVli0qoEOUjBHaTHj60BUITUgU5tWh/7WABHJDhkLZUJAUiBwm++++NKITnGrdJNXoEHjEn9kEI84OizwGN3ASnBgXNUbSe7cAwPmrAjJCHKRP6UJdL8ClKNYxvRVzwBfBUVNokXqQlLFsQR2VhHvHyMeLh4gOniZlj96pbx06Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815449; 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=uJOLSFLQS5Ql/KtJdcuLr156RfGDWaTWC6vpyFkF8ZM=; b=YZgHof6EUCekDUoGNsrpIhPqjaUhDIhUGxYx18WTEwhfh2tUtq3MFvga8d5AD2Y/hHf4Gfw2DbynrctXg1s2z1Iar8GR2tqxRskOa6mzQhK8DtPNFn6py8VhoQQCAaT1At/4RZLl4kX+EuIci5jfWaXLINB9CVnnGyH75dhSLok= 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 1600815449093155.16257141332892; Tue, 22 Sep 2020 15:57:29 -0700 (PDT) Received: from localhost ([::1]:58434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrDy-0003Iz-LD for importer@patchew.org; Tue, 22 Sep 2020 18:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2c-0002BV-5k for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2M-0000Po-AP for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:38 -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-301-RAJO-UEAP8uKrF6xm8E2-w-1; Tue, 22 Sep 2020 18:45:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D438C425CE; Tue, 22 Sep 2020 22:45:21 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7B865C1A3; Tue, 22 Sep 2020 22:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814724; 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=uJOLSFLQS5Ql/KtJdcuLr156RfGDWaTWC6vpyFkF8ZM=; b=Es/7wed6PjN2EDwiiDnyzh5wkCmYSgZWL6Gl8rTHLVgsMfnzvLvhQrBcZv6ouRgz6+5X2S wXs4KQhL7k3HxafQHT9CNk5C8pXk5w9/PeKit00ihrZN0TxNFG5ObgfvKYh9Fyg3ugcVEn GmZ5WRo15Sd6h6aEwM3GRUcekq7FuQQ= X-MC-Unique: RAJO-UEAP8uKrF6xm8E2-w-1 From: John Snow To: Markus Armbruster Subject: [PATCH 13/25] qapi/schema.py: Test type of self.ret_type instead of local temp Date: Tue, 22 Sep 2020 18:44:49 -0400 Message-Id: <20200922224501.4087749-14-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" This is obscure: If we test the type on a local copy instead of the stored state AFTER the assignment, mypy does not constrain the type of the copy. If we test on the stored state, it works out fine. Corrects this warning: qapi/schema.py:887: error: "QAPISchemaType" has no attribute "element_type" Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 943f234ee2..09c7ceab41 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -764,7 +764,7 @@ def check(self, schema): self._ret_type_name, self.info, "command's 'returns'") if self.name not in self.info.pragma.returns_whitelist: typ =3D self.ret_type - if isinstance(typ, QAPISchemaArrayType): + if isinstance(self.ret_type, QAPISchemaArrayType): typ =3D self.ret_type.element_type assert typ if not isinstance(typ, QAPISchemaObjectType): --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815363; cv=none; d=zohomail.com; s=zohoarc; b=HCOuz0zq14u13/Jij75gvL+sZjsFLKWoebEsmjHl97apSNYPk0QfJoBaxmODrBabmCfT6X3w5RL5WVF4GmbSLP7BrR8i5QfFg/72GHnM4AG6oky1kOGvFkGiSbEvZRiZ3S369oQVcQvlcUsWVVcc1RXNUEup/3Rfp2WPdEiosVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815363; 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=+E+mV59mJlkX4nFN4kcpjssEGCtAusD4bkmzsFbnN0A=; b=frXzEKoMWHzYbjOW/RtrsU1HffgKqtdq8LvIDFz3gSBGRKHXdCUTEUlfRilwj1y3WwDuR1ffTTIIjYd7DTOtL6RW05p2TG6uHAnlZX8035kX9S+1VeCAAt6t1nVQGS/57RD6lk+AgyDAVC/Nzg/du+U9an03heJHTNMCUL3XCiw= 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 1600815363944497.44785538754786; Tue, 22 Sep 2020 15:56:03 -0700 (PDT) Received: from localhost ([::1]:53486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrCc-0001C7-Jk for importer@patchew.org; Tue, 22 Sep 2020 18:56:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2g-0002EF-CI for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:47 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25604 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2P-0000Py-2E for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:45 -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-387-2ryE0ewlMaWVM44pIyienQ-1; Tue, 22 Sep 2020 18:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59AAF1005E64; Tue, 22 Sep 2020 22:45:23 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BF1B5C1A3; Tue, 22 Sep 2020 22:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814726; 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=+E+mV59mJlkX4nFN4kcpjssEGCtAusD4bkmzsFbnN0A=; b=HfvlOQ/miSVlI9R6sv7z7/pSAo73s0MteInNDlz3tpHpJIAOQEle5TeUfIW9TpTvsq3/e8 5Acoy3ft2bDOkBNmtqu8duNRfJDfz0K29yD/kfpE+Em1AB2cGMuq/LtbFzX64GVkwQGRNh fpTiw1QB1zpdbrh0R/Nr4kO6msu+AVQ= X-MC-Unique: 2ryE0ewlMaWVM44pIyienQ-1 From: John Snow To: Markus Armbruster Subject: [PATCH 14/25] qapi/schema.py: Assert variants of an object are also objects Date: Tue, 22 Sep 2020 18:44:50 -0400 Message-Id: <20200922224501.4087749-15-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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=207.211.31.81; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 17:01:22 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" The 'seen' dictionaries are invariant types and require the most abstracted type to maintain a consistent interface with other check_clash implementations. In this case, we happen to know (and require) that they will be object types, so add a runtime assertion to constrain that type. Corrects this warning: qapi/schema.py:718: error: Item "QAPISchemaType" of "Optional[QAPISchemaTyp= e]" has no attribute "check_clash" Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 09c7ceab41..b502eee9cb 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -620,6 +620,7 @@ def check_clash(self, info, seen): for v in self.variants: # Reset seen map for each variant, since qapi names from one # branch do not affect another branch + assert isinstance(v.type, QAPISchemaObjectType) v.type.check_clash(info, dict(seen)) =20 =20 --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815825; cv=none; d=zohomail.com; s=zohoarc; b=DPhxjR8we0pSkKyMQ5R+F5Dh8RVbJD0h/QD8PmYBxNWkclmRmXJJNGa7s/mG7o0A3kCUSR8s2L/MTMKdNXpUwdMGoeWnRjoDjUA1l97w/KQbesWkom/YgVsZt7/CVnn+TS8pjmu8OBH/ruidsQrFDe0et8I1O+n5TiLb4mzVeXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815825; 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=KIzYZQlKwhGoNOUNtlupdCebW6wEPKxJ96BgJJ3SLN8=; b=gSysx3w7BdGbjNuVUnURMeplXoLy9l89mLd+fSNthhJfocR+etN9UFxOXrGFVO8+RgOl7P9mgmOVlio9i9av7xl7A/OkMXlkFwu6jk22TX/2pQyVGADD7wvFeSXK5YOjl/UTGnlC216XjQSet6b7RDOD38KEDK7DQt3HQLCkoH8= 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 1600815825928424.413516036444; Tue, 22 Sep 2020 16:03:45 -0700 (PDT) Received: from localhost ([::1]:50050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrK4-0003aB-7h for importer@patchew.org; Tue, 22 Sep 2020 19:03:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2l-0002K7-Bf for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2f-0000Wl-R2 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-84-XrjDxhYZOyWkCn8IM7p4tQ-1; Tue, 22 Sep 2020 18:45:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD57F802B49; Tue, 22 Sep 2020 22:45:24 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EF6F5C1A3; Tue, 22 Sep 2020 22:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814738; 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=KIzYZQlKwhGoNOUNtlupdCebW6wEPKxJ96BgJJ3SLN8=; b=SQLlgoEtQbrCBvSp8UJftL0Xj6f7i4vGZtHcJuFqVid/3Ut5c6x96D5s8rsWLYK5jb4gq5 FTMiawARFW55wtKMaflRGkK1K+kTKOo0wXh/hiZffdTg0AJ8XrBlwW+JsuLgj+94jY54/v L/GhC2HWNh4MXK+8xilNY6u8QKudh/o= X-MC-Unique: XrjDxhYZOyWkCn8IM7p4tQ-1 From: John Snow To: Markus Armbruster Subject: [PATCH 15/25] qapi/schema.py: add type hint annotations Date: Tue, 22 Sep 2020 18:44:51 -0400 Message-Id: <20200922224501.4087749-16-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 519 ++++++++++++++++++++++++++++------------- 1 file changed, 361 insertions(+), 158 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index b502eee9cb..8907bec0b5 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -14,15 +14,27 @@ =20 # TODO catching name collisions in generated code would be nice =20 -import os -import re from collections import OrderedDict -from typing import cast, List +import re +import os +from typing import ( + Any, + Callable, + Dict, + List, + Optional, + Type, + TypeVar, + Union, + cast, + overload, +) =20 from .common import c_name, POINTER_SUFFIX from .error import QAPISourceError, QAPISemError from .expr import check_exprs -from .parser import QAPISchemaParser +from .parser import QAPIDoc, QAPISchemaParser, ParsedExpression +from .source import QAPISourceInfo =20 =20 class Visitable: @@ -32,13 +44,18 @@ def visit(self, visitor: 'QAPISchemaVisitor') -> None: =20 =20 class QAPISchemaEntity(Visitable): - def __init__(self, name: str, info, doc, ifcond=3DNone, features=3DNon= e): + def __init__(self, + name: str, + info: Optional[QAPISourceInfo], + doc: Optional[QAPIDoc], + ifcond: Optional[Union[List[str], 'QAPISchemaType']] =3D = None, + features: Optional[List['QAPISchemaFeature']] =3D None): assert name is None or isinstance(name, str) for f in features or []: assert isinstance(f, QAPISchemaFeature) f.set_defined_in(name) self.name =3D name - self._module =3D None + self._module: Optional[QAPISchemaModule] =3D None # For explicitly defined entities, info points to the (explicit) # definition. For builtins (and their arrays), info is None. # For implicitly defined entities, info points to a place that @@ -59,105 +76,151 @@ def meta(self) -> str: def meta(self, value: str) -> None: self._meta =3D value =20 - def c_name(self): + def c_name(self) -> str: return c_name(self.name) =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: assert not self._checked - seen =3D {} + seen: Dict[str, 'QAPISchemaMember'] =3D {} for f in self.features: f.check_clash(self.info, seen) self._checked =3D True =20 - def connect_doc(self, doc=3DNone): + def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: doc =3D doc or self.doc if doc: for f in self.features: doc.connect_feature(f) =20 - def check_doc(self): + def check_doc(self) -> None: if self.doc: self.doc.check() =20 - def _set_module(self, schema, info): + def _set_module(self, + schema: 'QAPISchema', + info: Optional[QAPISourceInfo]) -> None: assert self._checked self._module =3D schema.module_by_fname(info.fname if info else No= ne) self._module.add_entity(self) =20 - def set_module(self, schema): + def set_module(self, schema: 'QAPISchema') -> None: self._set_module(schema, self.info) =20 @property - def ifcond(self): + def ifcond(self) -> List[str]: assert self._checked and isinstance(self._ifcond, list) return self._ifcond =20 - def is_implicit(self): + def is_implicit(self) -> bool: return not self.info =20 - def visit(self, visitor): + def visit(self, visitor: 'QAPISchemaVisitor') -> None: assert self._checked =20 - def describe(self): + def describe(self) -> str: assert self.meta return "%s '%s'" % (self.meta, self.name) =20 =20 class QAPISchemaVisitor: - def visit_begin(self, schema): + def visit_begin(self, schema: 'QAPISchema') -> None: pass =20 - def visit_end(self): + def visit_end(self) -> None: pass =20 - def visit_module(self, name): + def visit_module(self, name: Optional[str]) -> None: pass =20 - def visit_needed(self, entity): + def visit_needed(self, entity: QAPISchemaEntity) -> bool: # Default to visiting everything return True =20 - def visit_include(self, name, info): + def visit_include(self, name: str, info: QAPISourceInfo) -> None: pass =20 - def visit_builtin_type(self, name, info, json_type): + def visit_builtin_type(self, name: str, + info: Optional[QAPISourceInfo], + json_type: str) -> None: pass =20 - def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): + def visit_enum_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List['QAPISchemaFeature'], + members: List['QAPISchemaEnumMember'], + prefix: Optional[str]) -> None: pass =20 - def visit_array_type(self, name, info, ifcond, element_type): + def visit_array_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + element_type: 'QAPISchemaType') -> None: pass =20 - def visit_object_type(self, name, info, ifcond, features, - base, members, variants): + def visit_object_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List['QAPISchemaFeature'], + base: Optional['QAPISchemaObjectType'], + members: List['QAPISchemaObjectTypeMember'], + variants: Optional['QAPISchemaVariants']) -> Non= e: pass =20 - def visit_object_type_flat(self, name, info, ifcond, features, - members, variants): + def visit_object_type_flat(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List['QAPISchemaFeature'], + members: List['QAPISchemaObjectTypeMember'], + variants: Optional['QAPISchemaVariants'], + ) -> None: pass =20 - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List['QAPISchemaFeature'], + variants: 'QAPISchemaVariants') -> None: pass =20 - def visit_command(self, name, info, ifcond, features, - arg_type, ret_type, gen, success_response, boxed, - allow_oob, allow_preconfig): + def visit_command(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List['QAPISchemaFeature'], + arg_type: 'QAPISchemaObjectType', + ret_type: Optional['QAPISchemaType'], + gen: bool, + success_response: bool, + boxed: bool, + allow_oob: bool, + allow_preconfig: bool) -> None: pass =20 - def visit_event(self, name, info, ifcond, features, arg_type, boxed): + def visit_event(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List['QAPISchemaFeature'], + arg_type: 'QAPISchemaObjectType', + boxed: bool) -> None: pass =20 =20 class QAPISchemaModule(Visitable): - def __init__(self, name): + def __init__(self, name: Optional[str]): self.name =3D name - self._entity_list =3D [] + self._entity_list: List[QAPISchemaEntity] =3D [] =20 - def add_entity(self, ent): + def add_entity(self, ent: QAPISchemaEntity) -> None: self._entity_list.append(ent) =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: visitor.visit_module(self.name) for entity in self._entity_list: if visitor.visit_needed(entity): @@ -165,11 +228,11 @@ def visit(self, visitor): =20 =20 class QAPISchemaInclude(QAPISchemaEntity): - def __init__(self, sub_module, info): + def __init__(self, sub_module: QAPISchemaModule, info: QAPISourceInfo): super().__init__(None, info, None) self._sub_module =3D sub_module =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_include(self._sub_module.name, self.info) =20 @@ -181,17 +244,17 @@ def c_type(self) -> str: raise NotImplementedError() =20 # Return the C type to be used in a parameter list. - def c_param_type(self): + def c_param_type(self) -> str: return self.c_type() =20 # Return the C type to be used where we suppress boxing. - def c_unboxed_type(self): + def c_unboxed_type(self) -> str: return self.c_type() =20 def json_type(self) -> str: raise NotImplementedError() =20 - def alternate_qtype(self): + def alternate_qtype(self) -> str: json2qtype =3D { 'null': 'QTYPE_QNULL', 'string': 'QTYPE_QSTRING', @@ -202,24 +265,24 @@ def alternate_qtype(self): } return json2qtype[self.json_type()] =20 - def doc_type(self): + def doc_type(self) -> Optional[str]: if self.is_implicit(): return None return self.name =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: QAPISchemaEntity.check(self, schema) if 'deprecated' in [f.name for f in self.features]: raise QAPISemError( self.info, "feature 'deprecated' is not supported for type= s") =20 - def describe(self): + def describe(self) -> str: assert self.meta return "%s type '%s'" % (self.meta, self.name) =20 =20 class QAPISchemaBuiltinType(QAPISchemaType): - def __init__(self, name, json_type, c_type): + def __init__(self, name: str, json_type: str, c_type: str): super().__init__(name, None, None) assert not c_type or isinstance(c_type, str) assert json_type in ('string', 'number', 'int', 'boolean', 'null', @@ -228,30 +291,37 @@ def __init__(self, name, json_type, c_type): self._c_type_name =3D c_type self._meta =3D 'built-in' =20 - def c_name(self): + def c_name(self) -> str: return self.name =20 - def c_type(self): + def c_type(self) -> str: return self._c_type_name =20 - def c_param_type(self): + def c_param_type(self) -> str: if self.name =3D=3D 'str': return 'const ' + self._c_type_name return self._c_type_name =20 - def json_type(self): + def json_type(self) -> str: return self._json_type_name =20 - def doc_type(self): + def doc_type(self) -> str: return self.json_type() =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_builtin_type(self.name, self.info, self.json_type()) =20 =20 class QAPISchemaEnumType(QAPISchemaType): - def __init__(self, name, info, doc, ifcond, features, members, prefix): + def __init__(self, + name: str, + info: Optional[QAPISourceInfo], + doc: Optional[QAPIDoc], + ifcond: Optional[List[str]], + features: Optional[List['QAPISchemaFeature']], + members: List['QAPISchemaEnumMember'], + prefix: Optional[str]): super().__init__(name, info, doc, ifcond, features) for m in members: assert isinstance(m, QAPISchemaEnumMember) @@ -261,32 +331,32 @@ def __init__(self, name, info, doc, ifcond, features,= members, prefix): self.prefix =3D prefix self._meta =3D 'enum' =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) - seen =3D {} + seen: Dict[str, 'QAPISchemaMember'] =3D {} for m in self.members: m.check_clash(self.info, seen) =20 - def connect_doc(self, doc=3DNone): + def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc for m in self.members: m.connect_doc(doc) =20 - def is_implicit(self): + def is_implicit(self) -> bool: # See QAPISchema._make_implicit_enum_type() and ._def_predefineds() return self.name.endswith('Kind') or self.name =3D=3D 'QType' =20 - def c_type(self): + def c_type(self) -> str: return c_name(self.name) =20 - def member_names(self): + def member_names(self) -> List[str]: return [m.name for m in self.members] =20 - def json_type(self): + def json_type(self) -> str: return 'string' =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_enum_type( self.name, self.info, self.ifcond, self.features, @@ -294,56 +364,65 @@ def visit(self, visitor): =20 =20 class QAPISchemaArrayType(QAPISchemaType): - def __init__(self, name, info, element_type): + def __init__(self, name: str, + info: Optional[QAPISourceInfo], + element_type: str): super().__init__(name, info, None) assert isinstance(element_type, str) self._element_type_name =3D element_type - self.element_type =3D None + self.element_type: Optional[QAPISchemaType] =3D None self._meta =3D 'array' =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) self.element_type =3D schema.resolve_type( self._element_type_name, self.info, self.info.defn_meta if self.info else None) assert not isinstance(self.element_type, QAPISchemaArrayType) =20 - def set_module(self, schema): + def set_module(self, schema: 'QAPISchema') -> None: self._set_module(schema, self.element_type.info) =20 @property - def ifcond(self): + def ifcond(self) -> List[str]: assert self._checked return self.element_type.ifcond =20 - def is_implicit(self): + def is_implicit(self) -> bool: return True =20 - def c_type(self): + def c_type(self) -> str: return c_name(self.name) + POINTER_SUFFIX =20 - def json_type(self): + def json_type(self) -> str: return 'array' =20 - def doc_type(self): + def doc_type(self) -> Optional[str]: elt_doc_type =3D self.element_type.doc_type() if not elt_doc_type: return None return 'array of ' + elt_doc_type =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_array_type(self.name, self.info, self.ifcond, self.element_type) =20 - def describe(self): + def describe(self) -> str: assert self.meta return "%s type ['%s']" % (self.meta, self._element_type_name) =20 =20 class QAPISchemaObjectType(QAPISchemaType): - def __init__(self, name, info, doc, ifcond, features, - base, local_members, variants): + def __init__(self, + name: str, + info: Optional[QAPISourceInfo], + doc: Optional[QAPIDoc], + ifcond: Optional['QAPISchemaType'], + features: Optional[List['QAPISchemaFeature']], + base: Optional[str], + local_members: List['QAPISchemaObjectTypeMember'], + variants: Optional['QAPISchemaVariants']): # struct has local_members, optional base, and no variants # flat union has base, variants, and no local_members # simple union has local_members, variants, and no base @@ -357,12 +436,12 @@ def __init__(self, name, info, doc, ifcond, features, assert isinstance(variants, QAPISchemaVariants) variants.set_defined_in(name) self._base_name =3D base - self.base =3D None + self.base: Optional[QAPISchemaObjectType] =3D None self.local_members =3D local_members self.variants =3D variants - self.members =3D None + self.members: Optional[List[QAPISchemaObjectTypeMember]] =3D None =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: # This calls another type T's .check() exactly when the C # struct emitted by gen_object() contains that T's C struct # (pointers don't count). @@ -377,7 +456,7 @@ def check(self, schema): super().check(schema) assert self._checked and self.members is None =20 - seen =3D OrderedDict() + seen: Dict[str, 'QAPISchemaMember'] =3D OrderedDict() if self._base_name: base =3D schema.resolve_type(self._base_name, self.info, "'bas= e'") if (not isinstance(base, QAPISchemaObjectType) @@ -406,13 +485,15 @@ def check(self, schema): # Check that the members of this type do not cause duplicate JSON memb= ers, # and update seen to track the members seen so far. Report any errors # on behalf of info, which is not necessarily self.info - def check_clash(self, info, seen): + def check_clash(self, + info: QAPISourceInfo, + seen: Dict[str, 'QAPISchemaMember']) -> None: assert self._checked assert not self.variants # not implemented for m in self.members: m.check_clash(info, seen) =20 - def connect_doc(self, doc=3DNone): + def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc if self.base and self.base.is_implicit(): @@ -421,7 +502,7 @@ def connect_doc(self, doc=3DNone): m.connect_doc(doc) =20 @property - def ifcond(self): + def ifcond(self) -> List[str]: assert self._checked if isinstance(self._ifcond, QAPISchemaType): # Simple union wrapper type inherits from wrapped type; @@ -429,30 +510,30 @@ def ifcond(self): return self._ifcond.ifcond return self._ifcond =20 - def is_implicit(self): + def is_implicit(self) -> bool: # See QAPISchema._make_implicit_object_type(), as well as # _def_predefineds() return self.name.startswith('q_') =20 - def is_empty(self): + def is_empty(self) -> bool: assert self.members is not None return not self.members and not self.variants =20 - def c_name(self): + def c_name(self) -> str: assert self.name !=3D 'q_empty' return super().c_name() =20 - def c_type(self): + def c_type(self) -> str: assert not self.is_implicit() return c_name(self.name) + POINTER_SUFFIX =20 - def c_unboxed_type(self): + def c_unboxed_type(self) -> str: return c_name(self.name) =20 - def json_type(self): + def json_type(self) -> str: return 'object' =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_object_type( self.name, self.info, self.ifcond, self.features, @@ -463,7 +544,13 @@ def visit(self, visitor): =20 =20 class QAPISchemaAlternateType(QAPISchemaType): - def __init__(self, name, info, doc, ifcond, features, variants): + def __init__(self, + name: str, + info: QAPISourceInfo, + doc: QAPIDoc, + ifcond: Optional[List[str]], + features: List['QAPISchemaFeature'], + variants: 'QAPISchemaVariants'): super().__init__(name, info, doc, ifcond, features) assert isinstance(variants, QAPISchemaVariants) assert variants.tag_member @@ -472,7 +559,7 @@ def __init__(self, name, info, doc, ifcond, features, v= ariants): self.variants =3D variants self._meta =3D 'alternate' =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) self.variants.tag_member.check(schema) # Not calling self.variants.check_clash(), because there's nothing @@ -480,8 +567,8 @@ def check(self, schema): self.variants.check(schema, {}) # Alternate branch names have no relation to the tag enum values; # so we have to check for potential name collisions ourselves. - seen =3D {} - types_seen =3D {} + seen: Dict[str, QAPISchemaMember] =3D {} + types_seen: Dict[str, str] =3D {} for v in self.variants.variants: v.check_clash(self.info, seen) try: @@ -511,26 +598,30 @@ def check(self, schema): % (v.describe(self.info), types_seen[qt])) types_seen[qt] =3D v.name =20 - def connect_doc(self, doc=3DNone): + def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc for v in self.variants.variants: v.connect_doc(doc) =20 - def c_type(self): + def c_type(self) -> str: return c_name(self.name) + POINTER_SUFFIX =20 - def json_type(self): + def json_type(self) -> str: return 'value' =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_alternate_type( self.name, self.info, self.ifcond, self.features, self.variant= s) =20 =20 class QAPISchemaVariants: - def __init__(self, tag_name, info, tag_member, variants): + def __init__(self, + tag_name: Optional[str], + info: QAPISourceInfo, + tag_member: Optional['QAPISchemaObjectTypeMember'], + variants: List['QAPISchemaVariant']): # Flat unions pass tag_name but not tag_member. # Simple unions and alternates pass tag_member but not tag_name. # After check(), tag_member is always set, and tag_name remains @@ -545,11 +636,13 @@ def __init__(self, tag_name, info, tag_member, varian= ts): self.tag_member =3D tag_member self.variants =3D variants =20 - def set_defined_in(self, name): + def set_defined_in(self, name: str) -> None: for v in self.variants: v.set_defined_in(name) =20 - def check(self, schema, seen): + def check(self, + schema: 'QAPISchema', + seen: Dict[str, 'QAPISchemaMember']) -> None: if not self.tag_member: # flat union tag_member =3D seen.get(c_name(self._tag_name)) base =3D "'base'" @@ -616,7 +709,9 @@ def check(self, schema, seen): % (v.describe(self.info), v.type.describe())) v.type.check(schema) =20 - def check_clash(self, info, seen): + def check_clash(self, + info: QAPISourceInfo, + seen: Dict[str, 'QAPISchemaMember']) -> None: for v in self.variants: # Reset seen map for each variant, since qapi names from one # branch do not affect another branch @@ -628,18 +723,22 @@ class QAPISchemaMember: """ Represents object members, enum members and features """ role =3D 'member' =20 - def __init__(self, name, info, ifcond=3DNone): + def __init__(self, name: str, + info: Optional[QAPISourceInfo], + ifcond: Optional[List[str]] =3D None): assert isinstance(name, str) self.name =3D name self.info =3D info self.ifcond =3D ifcond or [] - self.defined_in =3D None + self.defined_in: Optional[str] =3D None =20 - def set_defined_in(self, name): + def set_defined_in(self, name: str) -> None: assert not self.defined_in self.defined_in =3D name =20 - def check_clash(self, info, seen): + def check_clash(self, + info: Optional[QAPISourceInfo], + seen: Dict[str, 'QAPISchemaMember']) -> None: cname =3D c_name(self.name) if cname in seen: raise QAPISemError( @@ -648,11 +747,11 @@ def check_clash(self, info, seen): % (self.describe(info), seen[cname].describe(info))) seen[cname] =3D self =20 - def connect_doc(self, doc): + def connect_doc(self, doc: Optional[QAPIDoc]) -> None: if doc: doc.connect_member(self) =20 - def describe(self, info): + def describe(self, info: QAPISourceInfo) -> str: role =3D self.role defined_in =3D self.defined_in assert defined_in @@ -692,7 +791,13 @@ class QAPISchemaFeature(QAPISchemaMember): =20 =20 class QAPISchemaObjectTypeMember(QAPISchemaMember): - def __init__(self, name, info, typ, optional, ifcond=3DNone, features= =3DNone): + def __init__(self, + name: str, + info: QAPISourceInfo, + typ: str, + optional: bool, + ifcond: Optional[List[str]] =3D None, + features: Optional[List[QAPISchemaFeature]] =3D None): super().__init__(name, info, ifcond) assert isinstance(typ, str) assert isinstance(optional, bool) @@ -700,19 +805,19 @@ def __init__(self, name, info, typ, optional, ifcond= =3DNone, features=3DNone): assert isinstance(f, QAPISchemaFeature) f.set_defined_in(name) self._type_name =3D typ - self.type =3D None + self.type: Optional[QAPISchemaType] =3D None self.optional =3D optional self.features =3D features or [] =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: assert self.defined_in self.type =3D schema.resolve_type(self._type_name, self.info, self.describe) - seen =3D {} + seen: Dict[str, QAPISchemaMember] =3D {} for f in self.features: f.check_clash(self.info, seen) =20 - def connect_doc(self, doc): + def connect_doc(self, doc: Optional[QAPIDoc]) -> None: super().connect_doc(doc) if doc: for f in self.features: @@ -722,21 +827,35 @@ def connect_doc(self, doc): class QAPISchemaVariant(QAPISchemaObjectTypeMember): role =3D 'branch' =20 - def __init__(self, name, info, typ, ifcond=3DNone): + def __init__(self, + name: str, + info: QAPISourceInfo, + typ: str, + ifcond: Optional[List[str]] =3D None): super().__init__(name, info, typ, False, ifcond) =20 =20 class QAPISchemaCommand(QAPISchemaEntity): - def __init__(self, name, info, doc, ifcond, features, - arg_type, ret_type, - gen, success_response, boxed, allow_oob, allow_preconfig): + def __init__(self, + name: str, + info: QAPISourceInfo, + doc: QAPIDoc, + ifcond: Optional[List[str]], + features: List[QAPISchemaFeature], + arg_type: str, + ret_type: Optional[str], + gen: bool, + success_response: bool, + boxed: bool, + allow_oob: bool, + allow_preconfig: bool): super().__init__(name, info, doc, ifcond, features) assert not arg_type or isinstance(arg_type, str) assert not ret_type or isinstance(ret_type, str) self._arg_type_name =3D arg_type - self.arg_type =3D None + self.arg_type: Optional[QAPISchemaObjectType] =3D None self._ret_type_name =3D ret_type - self.ret_type =3D None + self.ret_type: Optional[QAPISchemaType] =3D None self.gen =3D gen self.success_response =3D success_response self.boxed =3D boxed @@ -744,7 +863,7 @@ def __init__(self, name, info, doc, ifcond, features, self.allow_preconfig =3D allow_preconfig self._meta =3D 'command' =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) if self._arg_type_name: arg_type =3D schema.resolve_type( @@ -774,14 +893,14 @@ def check(self, schema): "command's 'returns' cannot take %s" % self.ret_type.describe()) =20 - def connect_doc(self, doc=3DNone): + def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc if doc: if self.arg_type and self.arg_type.is_implicit(): self.arg_type.connect_doc(doc) =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_command( self.name, self.info, self.ifcond, self.features, @@ -790,15 +909,22 @@ def visit(self, visitor): =20 =20 class QAPISchemaEvent(QAPISchemaEntity): - def __init__(self, name, info, doc, ifcond, features, arg_type, boxed): + def __init__(self, + name: str, + info: QAPISourceInfo, + doc: QAPIDoc, + ifcond: Optional[List[str]], + features: List[QAPISchemaFeature], + arg_type: str, + boxed: bool): super().__init__(name, info, doc, ifcond, features) assert not arg_type or isinstance(arg_type, str) self._arg_type_name =3D arg_type - self.arg_type =3D None + self.arg_type: Optional[QAPISchemaObjectType] =3D None self.boxed =3D boxed self._meta =3D 'event' =20 - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) if self._arg_type_name: arg_type =3D schema.resolve_type( @@ -815,29 +941,32 @@ def check(self, schema): "event's 'data' can take %s only with 'boxed': true" % self.arg_type.describe()) =20 - def connect_doc(self, doc=3DNone): + def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc if doc: if self.arg_type and self.arg_type.is_implicit(): self.arg_type.connect_doc(doc) =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_event( self.name, self.info, self.ifcond, self.features, self.arg_type, self.boxed) =20 =20 +_EntityType =3D TypeVar('_EntityType', bound=3DQAPISchemaEntity) + + class QAPISchema(Visitable): - def __init__(self, fname): + def __init__(self, fname: str): self.fname =3D fname parser =3D QAPISchemaParser(fname) exprs =3D check_exprs(parser.exprs) self.docs =3D parser.docs - self._entity_list =3D [] - self._entity_dict =3D {} - self._module_dict =3D OrderedDict() + self._entity_list: List[QAPISchemaEntity] =3D [] + self._entity_dict: Dict[str, QAPISchemaEntity] =3D {} + self._module_dict: Dict[str, QAPISchemaModule] =3D OrderedDict() self._schema_dir =3D os.path.dirname(fname) self._make_module(None) # built-ins self._make_module(fname) @@ -847,7 +976,7 @@ def __init__(self, fname): self._def_exprs(exprs) self.check() =20 - def _def_entity(self, ent): + def _def_entity(self, ent: QAPISchemaEntity) -> None: # Only the predefined types are allowed to not have info assert ent.info or self._predefining self._entity_list.append(ent) @@ -866,16 +995,33 @@ def _def_entity(self, ent): ent.info, "%s is already defined" % other_ent.describe()) self._entity_dict[ent.name] =3D ent =20 - def lookup_entity(self, name, typ=3DNone): + @overload + def lookup_entity(self, name: str, + typ: None =3D None) -> Optional[QAPISchemaEntity]: .= .. + + @overload + def lookup_entity(self, name: str, + typ: Type[_EntityType]) -> Optional[_EntityType]: ... + + def lookup_entity(self, + name: str, + typ: Optional[Type[QAPISchemaEntity]] =3D None, + ) -> Optional[QAPISchemaEntity]: ent =3D self._entity_dict.get(name) if typ and not isinstance(ent, typ): return None return ent =20 - def lookup_type(self, name): + def lookup_type(self, name: str) -> QAPISchemaType: return self.lookup_entity(name, QAPISchemaType) =20 - def resolve_type(self, name, info, what): + def resolve_type(self, + name: str, + info: Optional[QAPISourceInfo], + what: Optional[ + Union[str, Callable[[Optional[QAPISourceInfo]], s= tr]] + ], + ) -> QAPISchemaType: typ =3D self.lookup_type(name) if not typ: if callable(what): @@ -884,27 +1030,33 @@ def resolve_type(self, name, info, what): info, "%s uses unknown type '%s'" % (what, name)) return typ =20 - def _module_name(self, fname): + def _module_name(self, fname: Optional[str]) -> Optional[str]: if fname is None: return None return os.path.relpath(fname, self._schema_dir) =20 - def _make_module(self, fname): + def _make_module(self, fname: Optional[str]) -> QAPISchemaModule: name =3D self._module_name(fname) if name not in self._module_dict: self._module_dict[name] =3D QAPISchemaModule(name) return self._module_dict[name] =20 - def module_by_fname(self, fname): + def module_by_fname(self, fname: Optional[str]) -> QAPISchemaModule: name =3D self._module_name(fname) return self._module_dict[name] =20 - def _def_include(self, expr, info, doc): + def _def_include(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: Optional[QAPIDoc]) -> None: include =3D expr['include'] assert doc is None self._def_entity(QAPISchemaInclude(self._make_module(include), inf= o)) =20 - def _def_builtin_type(self, name, json_type, c_type): + def _def_builtin_type(self, + name: str, + json_type: str, + c_type: str) -> None: self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type)) # Instantiating only the arrays that are actually used would # be nice, but we can't as long as their generated code @@ -912,7 +1064,7 @@ def _def_builtin_type(self, name, json_type, c_type): # schema. self._make_array_type(name, None) =20 - def _def_predefineds(self): + def _def_predefineds(self) -> None: for t in [('str', 'string', 'char' + POINTER_SUFFIX), ('number', 'number', 'double'), ('int', 'int', 'int64_t'), @@ -941,17 +1093,26 @@ def _def_predefineds(self): self._def_entity(QAPISchemaEnumType('QType', None, None, None, Non= e, qtype_values, 'QTYPE')) =20 - def _make_features(self, features, info): + def _make_features(self, + features: Optional[List[Dict[str, Any]]], + info: QAPISourceInfo) -> List[QAPISchemaFeature]: if features is None: return [] return [QAPISchemaFeature(f['name'], info, f.get('if')) for f in features] =20 - def _make_enum_members(self, values, info): + def _make_enum_members(self, + values: List[Dict[str, Any]], + info: Optional[QAPISourceInfo], + ) -> List[QAPISchemaEnumMember]: return [QAPISchemaEnumMember(v['name'], info, v.get('if')) for v in values] =20 - def _make_implicit_enum_type(self, name, info, ifcond, values): + def _make_implicit_enum_type(self, + name: str, + info: QAPISourceInfo, + ifcond: Optional[List[str]], + values: List[Dict[str, Any]]) -> str: # See also QAPISchemaObjectTypeMember.describe() name =3D name + 'Kind' # reserved by check_defn_name_str() self._def_entity(QAPISchemaEnumType( @@ -960,13 +1121,21 @@ def _make_implicit_enum_type(self, name, info, ifcon= d, values): None)) return name =20 - def _make_array_type(self, element_type, info): + def _make_array_type(self, + element_type: str, + info: QAPISourceInfo) -> str: name =3D element_type + 'List' # reserved by check_defn_name_st= r() if not self.lookup_type(name): self._def_entity(QAPISchemaArrayType(name, info, element_type)) return name =20 - def _make_implicit_object_type(self, name, info, ifcond, role, members= ): + def _make_implicit_object_type(self, + name: str, + info: QAPISourceInfo, + ifcond: Optional[QAPISchemaType], + role: str, + members: List[QAPISchemaObjectTypeMembe= r], + ) -> Optional[str]: if not members: return None # See also QAPISchemaObjectTypeMember.describe() @@ -990,7 +1159,10 @@ def _make_implicit_object_type(self, name, info, ifco= nd, role, members): name, info, None, ifcond, None, None, members, None)) return name =20 - def _def_enum_type(self, expr, info, doc): + def _def_enum_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name =3D expr['enum'] data =3D expr['data'] prefix =3D expr.get('prefix') @@ -1000,7 +1172,12 @@ def _def_enum_type(self, expr, info, doc): name, info, doc, ifcond, features, self._make_enum_members(data, info), prefix)) =20 - def _make_member(self, name, typ, ifcond, features, info): + def _make_member(self, + name: str, + typ: str, + ifcond: Optional[List[str]], + features: Optional[List[Dict[str, Any]]], + info: QAPISourceInfo) -> QAPISchemaObjectTypeMember: optional =3D False if name.startswith('*'): name =3D name[1:] @@ -1011,12 +1188,18 @@ def _make_member(self, name, typ, ifcond, features,= info): return QAPISchemaObjectTypeMember(name, info, typ, optional, ifcon= d, self._make_features(features, in= fo)) =20 - def _make_members(self, data, info): + def _make_members(self, + data: Dict[str, Dict[str, Any]], + info: QAPISourceInfo, + ) -> List[QAPISchemaObjectTypeMember]: return [self._make_member(key, value['type'], value.get('if'), value.get('features'), info) for (key, value) in data.items()] =20 - def _def_struct_type(self, expr, info, doc): + def _def_struct_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name =3D expr['struct'] base =3D expr.get('base') data =3D expr['data'] @@ -1027,10 +1210,18 @@ def _def_struct_type(self, expr, info, doc): self._make_members(data, info), None)) =20 - def _make_variant(self, case, typ, ifcond, info): + def _make_variant(self, + case: str, + typ: str, + ifcond: Optional[List[str]], + info: QAPISourceInfo) -> QAPISchemaVariant: return QAPISchemaVariant(case, info, typ, ifcond) =20 - def _make_simple_variant(self, case, typ, ifcond, info): + def _make_simple_variant(self, + case: str, + typ: str, + ifcond: Optional[List[str]], + info: QAPISourceInfo) -> QAPISchemaVariant: if isinstance(typ, list): assert len(typ) =3D=3D 1 typ =3D self._make_array_type(typ[0], info) @@ -1039,7 +1230,10 @@ def _make_simple_variant(self, case, typ, ifcond, in= fo): 'wrapper', [self._make_member('data', typ, None, None, info)]) return QAPISchemaVariant(case, info, typ, ifcond) =20 - def _def_union_type(self, expr, info, doc): + def _def_union_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name =3D expr['union'] data =3D expr['data'] base =3D expr.get('base') @@ -1070,7 +1264,10 @@ def _def_union_type(self, expr, info, doc): QAPISchemaVariants( tag_name, info, tag_member, variants)= )) =20 - def _def_alternate_type(self, expr, info, doc): + def _def_alternate_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name =3D expr['alternate'] data =3D expr['data'] ifcond =3D expr.get('if') @@ -1084,7 +1281,10 @@ def _def_alternate_type(self, expr, info, doc): QAPISchemaVariants( None, info, tag_member, variants))) =20 - def _def_command(self, expr, info, doc): + def _def_command(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name =3D expr['command'] data =3D expr.get('data') rets =3D expr.get('returns') @@ -1107,7 +1307,10 @@ def _def_command(self, expr, info, doc): gen, success_response, boxed, allow_oob, allow_preconf= ig)) =20 - def _def_event(self, expr, info, doc): + def _def_event(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name =3D expr['event'] data =3D expr.get('data') boxed =3D expr.get('boxed', False) @@ -1120,7 +1323,7 @@ def _def_event(self, expr, info, doc): self._def_entity(QAPISchemaEvent(name, info, doc, ifcond, features, data, boxed)) =20 - def _def_exprs(self, exprs): + def _def_exprs(self, exprs: List[ParsedExpression]) -> None: for expr_elem in exprs: expr =3D expr_elem.expr info =3D expr_elem.info @@ -1142,7 +1345,7 @@ def _def_exprs(self, exprs): else: assert False =20 - def check(self): + def check(self) -> None: for ent in self._entity_list: ent.check(self) ent.connect_doc() @@ -1150,7 +1353,7 @@ def check(self): for ent in self._entity_list: ent.set_module(self) =20 - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: visitor.visit_begin(self) for mod in self._module_dict.values(): mod.visit(visitor) --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815945; cv=none; d=zohomail.com; s=zohoarc; b=mBPtTR3AzgyWW5JiR4W5oPAuasBP6goZtl1mglIWn9PYOkJ/fqBwRJ+uRqIzOBc7CnbOxs8pSyfTWHYaFxtDNTpFHf/Tg2ny4/7vVLLAFMcf2dvpHxHX1+jDOa4mt+SANeQK8F8qXWm+EpRrSBCZxe5uXU/6Jda3LjefK3LbMDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815945; 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=XOqpg3pFvWoF123CI00+ozxTXNYjdH6pip68BuUZ19Y=; b=U+ss12L7Q+gjn2fJZF2C/uXgN9Drx01S77Mv9Cbks14HaccdlfVWnGgPtA5lIl5+34pkTPne1YeehEdKSoZ0Vo9NljfNmC9TOSg8/Sdn5z+lvTNgnt4PrGDqA86+fqWZ9ylYephwKzdVp6yD5T5z5ZW6bjVJpD+d3nmnx3sbVCg= 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 1600815945281722.0246711976386; Tue, 22 Sep 2020 16:05:45 -0700 (PDT) Received: from localhost ([::1]:58374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrM0-0007Ai-0g for importer@patchew.org; Tue, 22 Sep 2020 19:05:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2l-0002Kq-N2 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2i-0000Rs-Ty for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-47-AC5wSlo1MyGpxrrTGP1HGA-1; Tue, 22 Sep 2020 18:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CBB9801AE8; Tue, 22 Sep 2020 22:45:26 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16C955C1A3; Tue, 22 Sep 2020 22:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814731; 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=XOqpg3pFvWoF123CI00+ozxTXNYjdH6pip68BuUZ19Y=; b=AenWaAssqmIB0Zqu1ATP+wsw8tVdDRJhdrSAiSZd8YdSanYfCwQMlUSmQlb/PTF8Nyfn18 t/NbwJIhjde/+CgYQI03UAyG9dps5MDAbL2FYTTQxSqbECt9J8hZsnQp3ZipEGTA16yZlu 7UrQ8rT1pal+nqT9UaouT+pE2F3twmM= X-MC-Unique: AC5wSlo1MyGpxrrTGP1HGA-1 From: John Snow To: Markus Armbruster Subject: [PATCH 16/25] qapi/schema.py: enable checking Date: Tue, 22 Sep 2020 18:44:52 -0400 Message-Id: <20200922224501.4087749-17-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/mypy.ini | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 20ab509946..df60c18de1 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -1,10 +1,4 @@ [mypy] strict =3D True strict_optional =3D False -disallow_untyped_calls =3D False python_version =3D 3.6 - -[mypy-qapi.schema] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815770; cv=none; d=zohomail.com; s=zohoarc; b=dtaXkvA3KpdtByBo0in+7+WdjjcADW/OYodrslsK5rTJW52vl2N6778BEjyUiLctrm41LCNvOEOm4n1+vQTHXjdDqFf/v7XWqEISG6te51XaUCzkkPzty2eQD6nTJCZ7PaV9fByLVr9XRataSkJWPH/pZn8MThjKSKwF4HN9JFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815770; 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=232eQWeKYWfjYkVfsdM3w9PjzW/Nwek6bkxa9wq53J0=; b=T/CIIoVPEsZt07gkuXy8YE0kfRfoPf8OV9I6RWBUOMT9YJmel5+WN2hvEQ2coJZDfM4dVqi6nLXWBVnmLUPzMEJgfnD7Hs/U3FeYJt2iMjPV3PXEfaopbji01pEwpexc6lS8vqYekKFnUItoKraKYCi94GzcwzgMe3L1Fwm91eg= 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 1600815770847432.44024704425294; Tue, 22 Sep 2020 16:02:50 -0700 (PDT) Received: from localhost ([::1]:47100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrJB-0002KW-IZ for importer@patchew.org; Tue, 22 Sep 2020 19:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2o-0002TS-Vr for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2j-0000SL-Jj for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-jvJHcrs_MYOiZaX4MkIE7Q-1; Tue, 22 Sep 2020 18:45:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 128DB81CBE9; Tue, 22 Sep 2020 22:45:27 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 378A05C1A3; Tue, 22 Sep 2020 22:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814731; 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=232eQWeKYWfjYkVfsdM3w9PjzW/Nwek6bkxa9wq53J0=; b=Tm+GZu47cxqP6QkEeIKRhGSp4FYlYivc2w5Sg4Ia2vDvkXKQD0ez0rn/uppM7px0BBPWIq B9OsusCfG1m/+NYitN7wMGWbnW+C3ERnDLNEVhDgDyil0N87/9BiXLlQc3MZbgticKunw1 TUJ50D7K8yzEda7281VbKQ1rvVQzC0k= X-MC-Unique: jvJHcrs_MYOiZaX4MkIE7Q-1 From: John Snow To: Markus Armbruster Subject: [PATCH 17/25] qapi: Disable similarity checks in pylint entirely Date: Tue, 22 Sep 2020 18:44:53 -0400 Message-Id: <20200922224501.4087749-18-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" The pylint similarity checks cannot distinguish parameter lists from other code; with the QAPISchemaVisitor interface having long lists of parameters, these similarity checks fire off in a way that's difficult to disable in a targeted way without littering the code with pylint pragmas. There is a change request filed to be able to ignore parameter lists, see: https://github.com/PyCQA/pylint/issues/3619 Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index 5091a08f12..fb444e93bb 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -18,6 +18,7 @@ ignore-patterns=3Dschema.py, # --disable=3DW". disable=3Dfixme, missing-docstring, + similarities, # See https://github.com/PyCQA/pylint/issues/3619 too-many-arguments, too-many-branches, too-many-statements, --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815855; cv=none; d=zohomail.com; s=zohoarc; b=JwXyUMn/t19ri8FOFw+th8xd/iqN0JJ8uqYNhuNO9wpU3B0Eo7E5b/szfENn5ihEfkAlb+ffbVTUQrlYw0jOuNukEflU1CGAEVEn3ke2vNPDG148vle22IrI7rjHHqZ2qEGC5+XcIJjtfyEyGLpOJHQD6Au2MOYeD9Uvk4MxEHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815855; 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=xC9YApRVYdH1maLPFSf2iLjeB6pl0D1w4/NJEgJ7SRk=; b=Z4cPgH6v9XJD7TNCMlwAskg8/NbyLB3hP4LbXgJevM+VyGOb6yx1VUul65KX4Y1C1lRBmquCB6CXPO1SUfWvPRoW4zmL/f3+b/2dIDRUDw8nv4H2q3rPh56YZbCagfBHhCNc5XdLtMGmusV0XtfmeGNh7sJGkWdhZApxkt5ZFhI= 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 1600815855402662.9819095928024; Tue, 22 Sep 2020 16:04:15 -0700 (PDT) Received: from localhost ([::1]:52720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrKX-0004lB-VK for importer@patchew.org; Tue, 22 Sep 2020 19:04:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2m-0002NN-KH for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2i-0000SD-NW for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-dCXCEEm8PEelBIoBmKvJUg-1; Tue, 22 Sep 2020 18:45:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10EB1802B49; Tue, 22 Sep 2020 22:45:28 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FA3C5C1A3; Tue, 22 Sep 2020 22:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814731; 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=xC9YApRVYdH1maLPFSf2iLjeB6pl0D1w4/NJEgJ7SRk=; b=IyW1pJeRWGCv6nclyPm3DmQGicWKfczWMDCBE3toQgxb8mKOd4oyld2G44lfNd3Uuwfnak puBhRbIBOPPPoGM+taYQwFWdlcKopVa2jY7SQVX5fXBCZKpc81SiHTJpT/bfRxVt3E9+In SjLjIFJUZi7oexcGtHSOHxcNgNjqIWo= X-MC-Unique: dCXCEEm8PEelBIoBmKvJUg-1 From: John Snow To: Markus Armbruster Subject: [PATCH 18/25] qapi/schema.py: Add pylint warning suppressions Date: Tue, 22 Sep 2020 18:44:54 -0400 Message-Id: <20200922224501.4087749-19-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 8907bec0b5..61238c0686 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -39,6 +39,8 @@ =20 class Visitable: """Abstract duck that suggests a class is visitable.""" + # pylint: disable=3Dtoo-few-public-methods + def visit(self, visitor: 'QAPISchemaVisitor') -> None: raise NotImplementedError =20 @@ -133,6 +135,7 @@ def visit_module(self, name: Optional[str]) -> None: pass =20 def visit_needed(self, entity: QAPISchemaEntity) -> bool: + # pylint: disable=3Dunused-argument, no-self-use # Default to visiting everything return True =20 --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815634; cv=none; d=zohomail.com; s=zohoarc; b=RsVDARgOtk3CC684bGb6QCbxK4lEMGrqwSEmmYD4c0lQFdfzUJVfhPiQYU8P9KvKHVmU2mpWdCX45VszgogsbslgKm4cCn6YMGHPudept7OE3KM49a8UpHcCgrJRgNZiZLSW2ho81iB+nzppllRQztap6YRIDneL73KRDtqC8vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815634; 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=BnkRQDBe/lGMVQUX9scHUathhJcZdcy6Q+U6UzBr6QE=; b=EaUVPyxgONZs2nI7r6wDmV8LBncC2oz3OvPCvxa2Pk0hIfTUDHqENSrHAhgMp0MqPGJZzGASsJ9eIl+vFQeWskB3HudMbZIE077j7w9nNqRivI2coLnVg322HPgF1UnXDaHhnL47kExDqTY3/jd/QkEphht80qfIZsC/6haT43U= 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 1600815634555472.970780517487; Tue, 22 Sep 2020 16:00:34 -0700 (PDT) Received: from localhost ([::1]:41664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrGz-0008Ct-5J for importer@patchew.org; Tue, 22 Sep 2020 19:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2k-0002Ij-P8 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2g-0000TQ-3P for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-520--J-Tmn0JP-a9lFLJnOJ96Q-1; Tue, 22 Sep 2020 18:45:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D12881CAFC; Tue, 22 Sep 2020 22:45:29 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D6055C1A3; Tue, 22 Sep 2020 22:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814732; 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=BnkRQDBe/lGMVQUX9scHUathhJcZdcy6Q+U6UzBr6QE=; b=fJz56H3heg5yf19UgEZn+ZAz3rKNbejDFOIO7vxGE/EqhOc/PmTJreKlu35cOiiRbITFPn Vnc2rLrm6Ejy7+ftRxbmwFpHJPygpTeMPhwQimUfKWZAjpqYoEeAYmz+R+6zjNWgRuZlCq S1Jzmh1RGunQEHh8oaiyxcfv3unIkh0= X-MC-Unique: -J-Tmn0JP-a9lFLJnOJ96Q-1 From: John Snow To: Markus Armbruster Subject: [PATCH 19/25] qapi/schema.py: Convert several methods to classmethods Date: Tue, 22 Sep 2020 18:44:55 -0400 Message-Id: <20200922224501.4087749-20-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" If they don't use self and nothing that extends them needs self either, they can be classmethods. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 61238c0686..2d23ce04eb 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1096,7 +1096,8 @@ def _def_predefineds(self) -> None: self._def_entity(QAPISchemaEnumType('QType', None, None, None, Non= e, qtype_values, 'QTYPE')) =20 - def _make_features(self, + @classmethod + def _make_features(cls, features: Optional[List[Dict[str, Any]]], info: QAPISourceInfo) -> List[QAPISchemaFeature]: if features is None: @@ -1104,7 +1105,8 @@ def _make_features(self, return [QAPISchemaFeature(f['name'], info, f.get('if')) for f in features] =20 - def _make_enum_members(self, + @classmethod + def _make_enum_members(cls, values: List[Dict[str, Any]], info: Optional[QAPISourceInfo], ) -> List[QAPISchemaEnumMember]: @@ -1213,7 +1215,8 @@ def _def_struct_type(self, self._make_members(data, info), None)) =20 - def _make_variant(self, + @classmethod + def _make_variant(cls, case: str, typ: str, ifcond: Optional[List[str]], --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815585; cv=none; d=zohomail.com; s=zohoarc; b=f9sIbDa7eiu8H4hVpNG3bZndHWTqiALvh5bt9Zk+MX3tg0+ilZRzodn+eB6JHE/Zhqubxss39fZsDiNZPx9EIf4RTyqx52pwrC0tZPhDzvpwWKlEO37M+NOfCBiyDjHSeB35+iIfQB8WX92esw1/sg+kpJV/3rWWKe2YrjFo7ls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815585; 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=mCVr78vMIPrc4SLTY7s0f9VJQeTa3jvsqQX8yshaFD0=; b=eQ64w2vKYaXc9M/ixBMMOLkEScc2r9oucRGaGjHchnwaCY3N1DBxZclgKYW3peKFTWwA/hVi1lXrmVzvET+5E86Zu+ZGLCXZNu3ZG7a7mnHCv8e8p7GKVbntLPXsNwH8SJdgDJ/1JeHF1Vv9Sz2Nz9U5jyaJ5CA2cmBVqoZME4c= 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 1600815585849279.1613499737889; Tue, 22 Sep 2020 15:59:45 -0700 (PDT) Received: from localhost ([::1]:38850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrGC-0006x3-FC for importer@patchew.org; Tue, 22 Sep 2020 18:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2o-0002SD-I0 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2j-0000X5-F0 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-OWRrEI3IOXiAhRPr-Zt4_Q-1; Tue, 22 Sep 2020 18:45:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3B1F801AE9; Tue, 22 Sep 2020 22:45:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2C5C5C1A3; Tue, 22 Sep 2020 22:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814740; 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=mCVr78vMIPrc4SLTY7s0f9VJQeTa3jvsqQX8yshaFD0=; b=SxCwp2rAW/sisFQpN0inCxzPp3ukagpByUA+l/3Zl1ycK/NTg02rTBv09exhdNgHGDwaAo 29s6vHYJ2eb1L3fvuiBz0eToe5AjaMOPL6XLW5TIz5O7HMxZnuAoHDEiy908HCuWUAn3nJ tfxq68dGQH+2t208KmVhqZddvDkAf28= X-MC-Unique: OWRrEI3IOXiAhRPr-Zt4_Q-1 From: John Snow To: Markus Armbruster Subject: [PATCH 20/25] qapi/schema.py: Replace one-letter variable names Date: Tue, 22 Sep 2020 18:44:56 -0400 Message-Id: <20200922224501.4087749-21-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" I hope you like butter, because here comes the churn! Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 184 +++++++++++++++++++++-------------------- 1 file changed, 95 insertions(+), 89 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 2d23ce04eb..a0e047c735 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -53,9 +53,11 @@ def __init__(self, ifcond: Optional[Union[List[str], 'QAPISchemaType']] =3D = None, features: Optional[List['QAPISchemaFeature']] =3D None): assert name is None or isinstance(name, str) - for f in features or []: - assert isinstance(f, QAPISchemaFeature) - f.set_defined_in(name) + + for feature in features or []: + assert isinstance(feature, QAPISchemaFeature) + feature.set_defined_in(name) + self.name =3D name self._module: Optional[QAPISchemaModule] =3D None # For explicitly defined entities, info points to the (explicit) @@ -84,15 +86,15 @@ def c_name(self) -> str: def check(self, schema: 'QAPISchema') -> None: assert not self._checked seen: Dict[str, 'QAPISchemaMember'] =3D {} - for f in self.features: - f.check_clash(self.info, seen) + for feature in self.features: + feature.check_clash(self.info, seen) self._checked =3D True =20 def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: doc =3D doc or self.doc if doc: - for f in self.features: - doc.connect_feature(f) + for feature in self.features: + doc.connect_feature(feature) =20 def check_doc(self) -> None: if self.doc: @@ -326,9 +328,9 @@ def __init__(self, members: List['QAPISchemaEnumMember'], prefix: Optional[str]): super().__init__(name, info, doc, ifcond, features) - for m in members: - assert isinstance(m, QAPISchemaEnumMember) - m.set_defined_in(name) + for member in members: + assert isinstance(member, QAPISchemaEnumMember) + member.set_defined_in(name) assert prefix is None or isinstance(prefix, str) self.members =3D members self.prefix =3D prefix @@ -337,14 +339,14 @@ def __init__(self, def check(self, schema: 'QAPISchema') -> None: super().check(schema) seen: Dict[str, 'QAPISchemaMember'] =3D {} - for m in self.members: - m.check_clash(self.info, seen) + for member in self.members: + member.check_clash(self.info, seen) =20 def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc - for m in self.members: - m.connect_doc(doc) + for member in self.members: + member.connect_doc(doc) =20 def is_implicit(self) -> bool: # See QAPISchema._make_implicit_enum_type() and ._def_predefineds() @@ -432,9 +434,9 @@ def __init__(self, super().__init__(name, info, doc, ifcond, features) self._meta =3D 'union' if variants else 'struct' assert base is None or isinstance(base, str) - for m in local_members: - assert isinstance(m, QAPISchemaObjectTypeMember) - m.set_defined_in(name) + for member in local_members: + assert isinstance(member, QAPISchemaObjectTypeMember) + member.set_defined_in(name) if variants is not None: assert isinstance(variants, QAPISchemaVariants) variants.set_defined_in(name) @@ -471,9 +473,9 @@ def check(self, schema: 'QAPISchema') -> None: self.base =3D base self.base.check(schema) self.base.check_clash(self.info, seen) - for m in self.local_members: - m.check(schema) - m.check_clash(self.info, seen) + for member in self.local_members: + member.check(schema) + member.check_clash(self.info, seen) =20 # check_clash is abstract, but local_members is asserted to be # Sequence[QAPISchemaObjectTypeMember]. Cast to the narrower type. @@ -493,16 +495,16 @@ def check_clash(self, seen: Dict[str, 'QAPISchemaMember']) -> None: assert self._checked assert not self.variants # not implemented - for m in self.members: - m.check_clash(info, seen) + for member in self.members: + member.check_clash(info, seen) =20 def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc if self.base and self.base.is_implicit(): self.base.connect_doc(doc) - for m in self.local_members: - m.connect_doc(doc) + for member in self.local_members: + member.connect_doc(doc) =20 @property def ifcond(self) -> List[str]: @@ -572,40 +574,43 @@ def check(self, schema: 'QAPISchema') -> None: # so we have to check for potential name collisions ourselves. seen: Dict[str, QAPISchemaMember] =3D {} types_seen: Dict[str, str] =3D {} - for v in self.variants.variants: - v.check_clash(self.info, seen) + + for variant in self.variants.variants: + variant.check_clash(self.info, seen) + try: - qtype =3D v.type.alternate_qtype() + qtype =3D variant.type.alternate_qtype() except KeyError: - raise QAPISemError( - self.info, - "%s cannot use %s" - % (v.describe(self.info), v.type.describe())) + msg =3D "{} cannot use {}".format( + variant.describe(self.info), variant.type.describe()) + raise QAPISemError(self.info, msg) from None + conflicting =3D set([qtype]) if qtype =3D=3D 'QTYPE_QSTRING': - if isinstance(v.type, QAPISchemaEnumType): - for m in v.type.members: - if m.name in ['on', 'off']: + if isinstance(variant.type, QAPISchemaEnumType): + for member in variant.type.members: + if member.name in ['on', 'off']: conflicting.add('QTYPE_QBOOL') - if re.match(r'[-+0-9.]', m.name): + if re.match(r'[-+0-9.]', member.name): # lazy, could be tightened conflicting.add('QTYPE_QNUM') else: conflicting.add('QTYPE_QNUM') conflicting.add('QTYPE_QBOOL') - for qt in conflicting: - if qt in types_seen: - raise QAPISemError( - self.info, - "%s can't be distinguished from '%s'" - % (v.describe(self.info), types_seen[qt])) - types_seen[qt] =3D v.name + + for qtype in conflicting: + if qtype in types_seen: + msg =3D "{} can't be distinguished from '{}'".format( + variant.describe(self.info), types_seen[qtype]) + raise QAPISemError(self.info, msg) + + types_seen[qtype] =3D variant.name =20 def connect_doc(self, doc: Optional[QAPIDoc] =3D None) -> None: super().connect_doc(doc) doc =3D doc or self.doc - for v in self.variants.variants: - v.connect_doc(doc) + for variant in self.variants.variants: + variant.connect_doc(doc) =20 def c_type(self) -> str: return c_name(self.name) + POINTER_SUFFIX @@ -632,16 +637,16 @@ def __init__(self, assert bool(tag_member) !=3D bool(tag_name) assert (isinstance(tag_name, str) or isinstance(tag_member, QAPISchemaObjectTypeMember)) - for v in variants: - assert isinstance(v, QAPISchemaVariant) + for variant in variants: + assert isinstance(variant, QAPISchemaVariant) self._tag_name =3D tag_name self.info =3D info self.tag_member =3D tag_member self.variants =3D variants =20 def set_defined_in(self, name: str) -> None: - for v in self.variants: - v.set_defined_in(name) + for variant in self.variants: + variant.set_defined_in(name) =20 def check(self, schema: 'QAPISchema', @@ -686,40 +691,41 @@ def check(self, if self._tag_name: # flat union # branches that are not explicitly covered get an empty type cases =3D {v.name for v in self.variants} - for m in self.tag_member.type.members: - if m.name not in cases: - v =3D QAPISchemaVariant(m.name, self.info, - 'q_empty', m.ifcond) - v.set_defined_in(self.tag_member.defined_in) - self.variants.append(v) + for member in self.tag_member.type.members: + if member.name not in cases: + variant =3D QAPISchemaVariant(member.name, self.info, + 'q_empty', member.ifcond) + variant.set_defined_in(self.tag_member.defined_in) + self.variants.append(variant) if not self.variants: raise QAPISemError(self.info, "union has no branches") - for v in self.variants: - v.check(schema) + for variant in self.variants: + variant.check(schema) # Union names must match enum values; alternate names are # checked separately. Use 'seen' to tell the two apart. if seen: - if v.name not in self.tag_member.type.member_names(): + if variant.name not in self.tag_member.type.member_names(): raise QAPISemError( self.info, "branch '%s' is not a value of %s" - % (v.name, self.tag_member.type.describe())) - if (not isinstance(v.type, QAPISchemaObjectType) - or v.type.variants): + % (variant.name, self.tag_member.type.describe())) + if (not isinstance(variant.type, QAPISchemaObjectType) + or variant.type.variants): raise QAPISemError( self.info, - "%s cannot use %s" - % (v.describe(self.info), v.type.describe())) - v.type.check(schema) + "%s cannot use %s" % ( + variant.describe(self.info), + variant.type.describe())) + variant.type.check(schema) =20 def check_clash(self, info: QAPISourceInfo, seen: Dict[str, 'QAPISchemaMember']) -> None: - for v in self.variants: + for variant in self.variants: # Reset seen map for each variant, since qapi names from one # branch do not affect another branch - assert isinstance(v.type, QAPISchemaObjectType) - v.type.check_clash(info, dict(seen)) + assert isinstance(variant.type, QAPISchemaObjectType) + variant.type.check_clash(info, dict(seen)) =20 =20 class QAPISchemaMember: @@ -804,9 +810,9 @@ def __init__(self, super().__init__(name, info, ifcond) assert isinstance(typ, str) assert isinstance(optional, bool) - for f in features or []: - assert isinstance(f, QAPISchemaFeature) - f.set_defined_in(name) + for feature in features or []: + assert isinstance(feature, QAPISchemaFeature) + feature.set_defined_in(name) self._type_name =3D typ self.type: Optional[QAPISchemaType] =3D None self.optional =3D optional @@ -817,14 +823,14 @@ def check(self, schema: 'QAPISchema') -> None: self.type =3D schema.resolve_type(self._type_name, self.info, self.describe) seen: Dict[str, QAPISchemaMember] =3D {} - for f in self.features: - f.check_clash(self.info, seen) + for feature in self.features: + feature.check_clash(self.info, seen) =20 def connect_doc(self, doc: Optional[QAPIDoc]) -> None: super().connect_doc(doc) if doc: - for f in self.features: - doc.connect_feature(f) + for feature in self.features: + doc.connect_feature(feature) =20 =20 class QAPISchemaVariant(QAPISchemaObjectTypeMember): @@ -1068,22 +1074,22 @@ def _def_builtin_type(self, self._make_array_type(name, None) =20 def _def_predefineds(self) -> None: - for t in [('str', 'string', 'char' + POINTER_SUFFIX), - ('number', 'number', 'double'), - ('int', 'int', 'int64_t'), - ('int8', 'int', 'int8_t'), - ('int16', 'int', 'int16_t'), - ('int32', 'int', 'int32_t'), - ('int64', 'int', 'int64_t'), - ('uint8', 'int', 'uint8_t'), - ('uint16', 'int', 'uint16_t'), - ('uint32', 'int', 'uint32_t'), - ('uint64', 'int', 'uint64_t'), - ('size', 'int', 'uint64_t'), - ('bool', 'boolean', 'bool'), - ('any', 'value', 'QObject' + POINTER_SUFFIX), - ('null', 'null', 'QNull' + POINTER_SUFFIX)]: - self._def_builtin_type(*t) + for args in (('str', 'string', 'char' + POINTER_SUFFIX), + ('number', 'number', 'double'), + ('int', 'int', 'int64_t'), + ('int8', 'int', 'int8_t'), + ('int16', 'int', 'int16_t'), + ('int32', 'int', 'int32_t'), + ('int64', 'int', 'int64_t'), + ('uint8', 'int', 'uint8_t'), + ('uint16', 'int', 'uint16_t'), + ('uint32', 'int', 'uint32_t'), + ('uint64', 'int', 'uint64_t'), + ('size', 'int', 'uint64_t'), + ('bool', 'boolean', 'bool'), + ('any', 'value', 'QObject' + POINTER_SUFFIX), + ('null', 'null', 'QNull' + POINTER_SUFFIX)): + self._def_builtin_type(*args) self.the_empty_object_type =3D QAPISchemaObjectType( 'q_empty', None, None, None, None, None, [], None) self._def_entity(self.the_empty_object_type) --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815499; cv=none; d=zohomail.com; s=zohoarc; b=GtXFxtqpt9cF7hVt7l03XIGrYqpgoMGROS32okNjhT3BSo3H+/IoydmxIF0ZIQ9TLR1y8lYIYfC04bUXhVhfcb4PjTdyWvyczWIl0c4ayQ1srdo9Xa8Yen3dH+PQ6CNbdA52Px/u34AFNylI8HCXia/JXQkSGQAyOb4sJcEvJac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815499; 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=Cohb1cEnh9mW0nABzu7a1jDE4scr/fqNYNgm1Qm484s=; b=hZtwcXY4QCl6LMXBZGuxQ0UreHAC3x99vVcKUPdqAh0NwQZy+7bw/mteb3G35gbxaz0E1onUZY9E7yPb9tat9gj7qUltjZxr0GuHSsvyCh8R6DPbs57uAd/YF92OANRlzXFsbjOCy7ZbpoihZ+/dBlmWgk7Hh6568iMd/Xalq3E= 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 1600815499713548.1612771960014; Tue, 22 Sep 2020 15:58:19 -0700 (PDT) Received: from localhost ([::1]:33528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrEo-0004j5-9D for importer@patchew.org; Tue, 22 Sep 2020 18:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2j-0002Ga-S3 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2d-0000Ut-W9 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-556-RfqDWe25Nfu5m2TJF2pIIA-1; Tue, 22 Sep 2020 18:45:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9ADA7801AE8; Tue, 22 Sep 2020 22:45:31 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF7D65C1A3; Tue, 22 Sep 2020 22:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814734; 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=Cohb1cEnh9mW0nABzu7a1jDE4scr/fqNYNgm1Qm484s=; b=D1MVOgOmKivkU2koC+E5Sk/zqz4WhRH16Kk2S7LRV+u7GX5NWW7UcusKV6/mnft53yucbC RzhhWsFOJY+CgEwIyRanAGdw8L+yD9et7Wolv8NjtnDOoPyVlvF8ZXEqFHZ/a2z1HtJuxy D+zP+rsBTQ07vQJzocxQC/TDo/HsJo8= X-MC-Unique: RfqDWe25Nfu5m2TJF2pIIA-1 From: John Snow To: Markus Armbruster Subject: [PATCH 21/25] qapi/schema.py: disable pylint line limit Date: Tue, 22 Sep 2020 18:44:57 -0400 Message-Id: <20200922224501.4087749-22-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It's a big file, but there's really nothing in here that doesn't belong in here -- and I don't think it's large enough to justify the one-module-per-class approach. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a0e047c735..271befea1c 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -12,6 +12,8 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 +# pylint: disable=3Dtoo-many-lines =C2=AF\_(=E3=83=84)_/=C2=AF + # TODO catching name collisions in generated code would be nice =20 from collections import OrderedDict --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600816176; cv=none; d=zohomail.com; s=zohoarc; b=iWX3Tb4B0EhTj/hn9AxwzILbyXhsNdpvv7uHvLREwUbPwRxGWZ66FMm/GflNlXSS5ePdvnJJRyX58tTaLduge6u8I0o9lkzsUK8xrPUXJ9bJ1QZIpASbRQ4kpctbm5wLxO+ODs9qIxnoHrnmZPxeDMPtcp2NlD7ACFwLJxjW3Uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600816176; 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=xW55YR5VhfeQzQ2FSeIIvnQ6gI5BA6OfDkWrI/yzKHw=; b=CywfzCWUNPohXjbceQBGz6u+Vf1e0E6Xlvyj/yaFmB5ObpH98qr8a86Ea1RXJIRC2gQvLHAFHD7g727P0yEABfew7qEZjw0k2yRAZbAX41Q+nfJF2vkqFsHUWQLSMyCwxyjl99Mo1CCwVP7knguiORWUyC3qL3coHEedhs918jM= 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 160081617679983.88169685681908; Tue, 22 Sep 2020 16:09:36 -0700 (PDT) Received: from localhost ([::1]:41156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrPj-0003cI-Ee for importer@patchew.org; Tue, 22 Sep 2020 19:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2n-0002Pi-Kn for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2j-0000VA-GD for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-586-WyrSCoCWOAa1HQSJtI2lDA-1; Tue, 22 Sep 2020 18:45:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF3051005E64; Tue, 22 Sep 2020 22:45:32 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C80815C1A3; Tue, 22 Sep 2020 22:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814735; 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=xW55YR5VhfeQzQ2FSeIIvnQ6gI5BA6OfDkWrI/yzKHw=; b=M1hgNnL0WoRrJpgPloRTu5Whe9QCxUJ9weNTvUiMofay1cAkCawdudH2gf6TW4a4P5cXTM rGNTg6h9g/dTV79Ksr4/M9S+jygDTsBVI2g72rbZS5EvBSAJ1QzDryBCsfyMddoed/YmR3 1tVypOMZxDK27j+J+Z07I8/W1XJDV30= X-MC-Unique: WyrSCoCWOAa1HQSJtI2lDA-1 From: John Snow To: Markus Armbruster Subject: [PATCH 22/25] qapi/schema.py: Ignore unused argument for check() Date: Tue, 22 Sep 2020 18:44:58 -0400 Message-Id: <20200922224501.4087749-23-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" This is an interface with a default implementation. Pylint doesn't have enough context to be aware of this. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 271befea1c..6ecbc2aa6b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -86,6 +86,7 @@ def c_name(self) -> str: return c_name(self.name) =20 def check(self, schema: 'QAPISchema') -> None: + # pylint: disable=3Dunused-argument assert not self._checked seen: Dict[str, 'QAPISchemaMember'] =3D {} for feature in self.features: --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600815638; cv=none; d=zohomail.com; s=zohoarc; b=JUUGa/qvGsr/9SFgj6qnnesPN5LlUDTnh5CFuRadLrB3eLSfwrMSL/xEm1AvC16tsYyfZH6GBsw+2SvIKz9bkeHtFExjGvG8JPo9zPajg9g1NqN9h8qkbS90tkfSDWRYtd3mj8iKdDeLt5vMYPi+aykme4aVSgXaw3H/0qXfDqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815638; 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=K+Jnzfz4yI2IUY1m1/NoSL9Uk+vNkxKYtLiabQy15Ic=; b=W6iDoZLnMzan4yii/xuzRUn6zZVcJRRL0WOYyJBdCUKv7gl1uq7WAcSNrXTuCVuaUjSNQxu8BHaF0FmTcSS/kRtb2NdiMPS+boGyPBePCgLC55VDy58xLOdCv6jFEbOaUcnM2IWhXi9Q8yyfLbJPR2KmCe8x83qte8BYZhY/k8I= 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 16008156380201001.2454463241926; Tue, 22 Sep 2020 16:00:38 -0700 (PDT) Received: from localhost ([::1]:41868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrH1-0008I1-Uj for importer@patchew.org; Tue, 22 Sep 2020 19:00:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2k-0002HZ-8K for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2i-0000Wt-B9 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-33-MbLuDRHLNhSsRDc--bSdmg-1; Tue, 22 Sep 2020 18:45:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10E611005E66; Tue, 22 Sep 2020 22:45:34 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07ACF5C1A3; Tue, 22 Sep 2020 22:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814738; 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=K+Jnzfz4yI2IUY1m1/NoSL9Uk+vNkxKYtLiabQy15Ic=; b=ZmDGkcHB9Ag69aDxAG3xq0VZ1JHlujRoTtRr9BwHYLAv6zwbw3yHorda4zkrtK2CmHZ4E1 iNqBuCgjI+GUp6ZQfuOrdIHknCW005mHrswWNQAS8atAEfGAMdKB1oXLocKQLgWb2RtH1O 4NxCG7DaDiZHt6XCpM0BJFOzpsvpkYM= X-MC-Unique: MbLuDRHLNhSsRDc--bSdmg-1 From: John Snow To: Markus Armbruster Subject: [PATCH 23/25] qapi/schema.py: enable pylint checks Date: Tue, 22 Sep 2020 18:44:59 -0400 Message-Id: <20200922224501.4087749-24-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:47:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/pylintrc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index fb444e93bb..539e5f65a0 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -1,10 +1,5 @@ [MASTER] =20 -# Add files or directories matching the regex patterns to the ignore list. -# The regex matches against base names, not paths. -ignore-patterns=3Dschema.py, - - [MESSAGES CONTROL] =20 # Disable the message, report, category or checker with the given id(s). Y= ou --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600816256; cv=none; d=zohomail.com; s=zohoarc; b=YygIFMp8FDshgq/sC+fPRszQWgHJVzarYyJMFQZbxvSERJjpi82dLPmXV7cQCotDTYdWdXnwoynPd424rBj0a57EeHQ1288DR0sI/TRsoMl2UaXt2tCF7VZQgKryhzeRv1EgczZxzx8vhC1m0Bdfr1ahbWoABpbVBuMxZ6lIAYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600816256; 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=TwMRv6UsLnWab9ol/6LyGADZOnqiP4elsl9NHdIBn7Q=; b=KsCT9L7NQ7JuP2600pkMwkKkBsjOQl6Kj49dumsoS2b0Y+/E9IMMEGMB9eEw/OQ0zg17bPQLkvwV5HEA7aTuSsN8ZkIJWYSNobtDawjmObEZvWI5oCbMDXAEuT8EaHxPZOztLAAPIAXsXaDQ4uyLLEHpxb+WYvlU7pQtH9B62+E= 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 16008162566561006.4470232668926; Tue, 22 Sep 2020 16:10:56 -0700 (PDT) Received: from localhost ([::1]:45324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrR0-0005MV-Cg for importer@patchew.org; Tue, 22 Sep 2020 19:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2o-0002Qx-3I for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2j-0000Wf-Iv for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18: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-136-MZnOQA9PNtKdhSQ2b5JJNQ-1; Tue, 22 Sep 2020 18:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CFF0186DD27; Tue, 22 Sep 2020 22:45:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BF425C1A3; Tue, 22 Sep 2020 22:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814737; 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=TwMRv6UsLnWab9ol/6LyGADZOnqiP4elsl9NHdIBn7Q=; b=dUdXw3G7gHZ0bhdj5BIR9sI9NkbNDL5xB41iVRP4s/ccvYVl0uw1VQIkWDFqwn6HwrUDu6 tfuJ9W27KqfDZtDvpzGW8xIBqnN8Mgm/JUNm4YUlV3V1Ni78QDOPwC5dZbXCCGw7/8OUFQ GwcOzSxHqvhWTEt+Hi8OionyQwd/lnk= X-MC-Unique: MZnOQA9PNtKdhSQ2b5JJNQ-1 From: John Snow To: Markus Armbruster Subject: [PATCH 24/25] qapi/schema.py: Add module docstring Date: Tue, 22 Sep 2020 18:45:00 -0400 Message-Id: <20200922224501.4087749-25-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 02:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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" Add some microdocumentation that gives a nice file-level overview of this 1300+ line file. Signed-off-by: John Snow based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 6ecbc2aa6b..baafe3babf 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1,7 +1,37 @@ # -*- coding: utf-8 -*- -# -# QAPI schema internal representation -# +""" +QAPI Schema internal representation. + +The `QAPISchema` represents the fully realized QAPI schema. It builds a +listing of `QAPISchemaEntity` objects that are each associated with a +`QAPISchemaModule`. + +`QAPISchemaMember` represents a single member of a collection of +members, see the subclasses thereof for users. `QAPISchemaVariants` is a +simple collection of `QAPISchemaVariant`. + +The `QAPISchemaVisitor` can be extended and passed to QAPISchema.visit +to iterate over a schema and perform code generation tasks. + +The Python class hierarchy at a glance: + +`QAPISchemaEntity` + `QAPISchemaInclude` + `QAPISchemaCommand` + `QAPISchemaEvent` + `QAPISchemaType` + `QAPISchemaBuiltinType` + `QAPISchemaEnumType` + `QAPISchemaArrayType` + `QAPISchemaObjectType` + `QAPISchemaAlternateType` + +`QAPISchemaMember` + `QAPISchemaEnumMember` + `QAPISchemaFeature` + `QAPISchemaObjectTypeMember` + `QAPISchemaVariant` +""" # Copyright (c) 2015-2019 Red Hat Inc. # # Authors: --=20 2.26.2 From nobody Sun May 5 13:42:56 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=1600816072; cv=none; d=zohomail.com; s=zohoarc; b=JAax6VJKizdMqMhBcBTdw9Sgr7u7H8l5YgjC0hv10B4POC3x8PcVQoaKYaluGWNMcKNkDt66TQ2zi4NZyRipRnRFl+Fq1S8v6ZhPZMSR+igefXRHInZ2ALhF7U0G7v5tORgCycg8/8Yc6vHzauFAYxJ0vSJU9SRL3Pf6UV64izw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600816072; 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=XrUgTRA8QMzgLVL135EN0gXPBOcBUr7kDEoIxyID/C0=; b=XPa8+umglP9PaQhJINUN0b/5roZz/TKUevcrmM56q1Tm1+H436h7atqh0IYNiDjZI7nIVxbokWEz3GAGcokvbQfJ0FCoQXxZ+XV2FqwGXvef0QiVkIxUiPAKH8k+UnSrA2Z17JgbildDhw7lQ5h2RdVb6Jl/cr12MPm0TXG/kG4= 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 1600816072296383.96790480952234; Tue, 22 Sep 2020 16:07:52 -0700 (PDT) Received: from localhost ([::1]:36904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrO3-0001nF-2v for importer@patchew.org; Tue, 22 Sep 2020 19:07:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKr2n-0002ON-18 for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:53 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:25216 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kKr2j-0000Wn-IJ for qemu-devel@nongnu.org; Tue, 22 Sep 2020 18:45:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-A7XYGYkIPGuaRV0mWF7LSw-1; Tue, 22 Sep 2020 18:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07300801AEA; Tue, 22 Sep 2020 22:45:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38B105C1A3; Tue, 22 Sep 2020 22:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600814738; 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=XrUgTRA8QMzgLVL135EN0gXPBOcBUr7kDEoIxyID/C0=; b=dDuo6DsPgG6FygEGjCLwjxE6pjsjcc7yODY2F0gRVlAzjYbUXF06m3QLZJeg7pyC/NxO4J +qAFbo2xjKfw6eblmDPRkyZGxM5uPzJQLC1JXJugTVYm+Sv5szRVG1Bxv5PNp7CHSeR+OL 00C5VSyc8neDLETxWEgA6cvxwW+6Vjg= X-MC-Unique: A7XYGYkIPGuaRV0mWF7LSw-1 From: John Snow To: Markus Armbruster Subject: [PATCH 25/25] qapi/schema.py: Use python3 style super() Date: Tue, 22 Sep 2020 18:45:01 -0400 Message-Id: <20200922224501.4087749-26-jsnow@redhat.com> In-Reply-To: <20200922224501.4087749-1-jsnow@redhat.com> References: <20200922224501.4087749-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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=205.139.110.61; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 17:00:46 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.455, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_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: Michael Roth , qemu-devel@nongnu.org, John Snow , Eduardo Habkost , Cleber Rosa 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 based-on: <20200922223525.4085762-1-jsnow@redhat.com> --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index baafe3babf..6b47ca26e0 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -309,7 +309,7 @@ def doc_type(self) -> Optional[str]: return self.name =20 def check(self, schema: 'QAPISchema') -> None: - QAPISchemaEntity.check(self, schema) + super().check(schema) if 'deprecated' in [f.name for f in self.features]: raise QAPISemError( self.info, "feature 'deprecated' is not supported for type= s") --=20 2.26.2