From patchwork Tue Sep 22 22:44:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 009E2C2D0E2 for ; Tue, 22 Sep 2020 22:59:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8CEC2221EB for ; Tue, 22 Sep 2020 22:59:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ROqTwWxh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CEC2221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrFo-0006lZ-OF for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:59:20 -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 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= 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 X-MC-Unique: ov5rF7CUNMqcuA5kdQrP3g-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 -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] = None def __init__(self, name: str, info, doc, ifcond=None, features=None): @@ -136,7 +142,7 @@ def visit_event(self, name, info, ifcond, features, arg_type, boxed): pass -class QAPISchemaModule: +class QAPISchemaModule(Visitable): def __init__(self, name): self.name = name self._entity_list = [] @@ -812,7 +818,7 @@ def visit(self, visitor): self.arg_type, self.boxed) -class QAPISchema: +class QAPISchema(Visitable): def __init__(self, fname): self.fname = fname parser = QAPISchemaParser(fname) From patchwork Tue Sep 22 22:44:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04B6AC2D0E2 for ; Tue, 22 Sep 2020 23:04:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D4A8221EB for ; Tue, 22 Sep 2020 23:04:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KOXVY82k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D4A8221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrKz-0005Xx-JN for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:04:41 -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 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= 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 X-MC-Unique: xVehLaCBMpepa1M_ndME-A-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 from .common import c_name, POINTER_SUFFIX from .error import QAPISourceError, QAPISemError @@ -32,8 +31,6 @@ def visit(self, visitor: 'QAPISchemaVisitor') -> None: class QAPISchemaEntity(Visitable): - meta: Optional[str] = None - def __init__(self, name: str, info, doc, ifcond=None, features=None): 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=None, features=None): self._ifcond = ifcond or [] self.features = features or [] self._checked = False + self._meta = '' + + @property + def meta(self) -> str: + return self._meta + + @meta.setter + def meta(self, value: str) -> None: + self._meta = value def c_name(self): return c_name(self.name) @@ -212,8 +218,6 @@ def describe(self): class QAPISchemaBuiltinType(QAPISchemaType): - meta = '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 = json_type self._c_type_name = c_type + self._meta = 'built-in' def c_name(self): return self.name @@ -245,8 +250,6 @@ def visit(self, visitor): class QAPISchemaEnumType(QAPISchemaType): - meta = '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, members, prefix): assert prefix is None or isinstance(prefix, str) self.members = members self.prefix = prefix + self._meta = 'enum' def check(self, schema): super().check(schema) @@ -289,13 +293,12 @@ def visit(self, visitor): class QAPISchemaArrayType(QAPISchemaType): - meta = 'array' - def __init__(self, name, info, element_type): super().__init__(name, info, None) assert isinstance(element_type, str) self._element_type_name = element_type self.element_type = None + self._meta = 'array' 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 = 'union' if variants else 'struct' + self._meta = '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): class QAPISchemaAlternateType(QAPISchemaType): - meta = '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, variants): variants.set_defined_in(name) variants.tag_member.set_defined_in(self.name) self.variants = variants + self._meta = 'alternate' def check(self, schema): super().check(schema) @@ -716,8 +718,6 @@ def __init__(self, name, info, typ, ifcond=None): class QAPISchemaCommand(QAPISchemaEntity): - meta = '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 = boxed self.allow_oob = allow_oob self.allow_preconfig = allow_preconfig + self._meta = 'command' def check(self, schema): super().check(schema) @@ -779,14 +780,13 @@ def visit(self, visitor): class QAPISchemaEvent(QAPISchemaEntity): - meta = '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 = arg_type self.arg_type = None self.boxed = boxed + self._meta = 'event' def check(self, schema): super().check(schema) From patchwork Tue Sep 22 22:44:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 273006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3209C2D0E2 for ; Tue, 22 Sep 2020 22:47:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8751D20757 for ; Tue, 22 Sep 2020 22:47:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JTsCFAi1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8751D20757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr3t-0003tW-LA for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:47:01 -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 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= 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 X-MC-Unique: lL9xakWLMR2VfU6EphOEoQ-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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() # 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() - def json_type(self): - pass + def json_type(self) -> str: + raise NotImplementedError() def alternate_qtype(self): json2qtype = { From patchwork Tue Sep 22 22:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 273004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D92DC2D0E2 for ; Tue, 22 Sep 2020 22:49:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CD112076E for ; Tue, 22 Sep 2020 22:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ffv2JlN6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CD112076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr67-0007N1-6x for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:49:19 -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 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= 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 X-MC-Unique: kvonn3BgPk6yGgNOGS0p3w-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Re-order check slightly so we can provide a stronger guarantee on the typing of the base field. Signed-off-by: John Snow --- 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): seen = OrderedDict() if self._base_name: - self.base = schema.resolve_type(self._base_name, self.info, - "'base'") - if (not isinstance(self.base, QAPISchemaObjectType) - or self.base.variants): + base = schema.resolve_type(self._base_name, self.info, "'base'") + 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 = base self.base.check(schema) self.base.check_clash(self.info, seen) for m in self.local_members: From patchwork Tue Sep 22 22:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B55D8C4727D for ; Tue, 22 Sep 2020 22:55:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D97A221EB for ; Tue, 22 Sep 2020 22:55:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GDdwg/SI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D97A221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrBi-0008AG-7h for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:55:06 -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 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= 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 X-MC-Unique: 9mJWSSsqNkOEQ65_p4PO-w-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Re-order the check method slightly in order to provide stronger typing for the arg_type field. Signed-off-by: John Snow --- 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 = schema.resolve_type( + arg_type = 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 = arg_type if self.arg_type.variants and not self.boxed: raise QAPISemError( self.info, From patchwork Tue Sep 22 22:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2070C4727E for ; Tue, 22 Sep 2020 22:53:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DFC120BED for ; Tue, 22 Sep 2020 22:53:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WISJy4pe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DFC120BED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr9n-0004eZ-8B for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:53:07 -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 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= 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 X-MC-Unique: H1iVNuZ_OIylNndb7AhkkA-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- 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 = schema.resolve_type( + arg_type = 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 = arg_type if self.arg_type.variants and not self.boxed: raise QAPISemError( self.info, From patchwork Tue Sep 22 22:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B05A3C4727D for ; Tue, 22 Sep 2020 23:06:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45275221EF for ; Tue, 22 Sep 2020 23:06:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="InkBcOeE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45275221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrN8-0000W4-De for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:06:54 -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 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= 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 X-MC-Unique: CJh2crTLO_GEAYFQ5ilhcA-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- 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): def check(self, schema, seen): if not self.tag_member: # flat union - self.tag_member = seen.get(c_name(self._tag_name)) + tag_member = seen.get(c_name(self._tag_name)) base = "'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 != self.tag_member.name: + if not tag_member or self._tag_name != 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 = tag_member # Here we do: base_type = schema.lookup_type(self.tag_member.defined_in) assert base_type From patchwork Tue Sep 22 22:44:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304666 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8567C2D0E2 for ; Tue, 22 Sep 2020 23:08:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BCE1221EF for ; Tue, 22 Sep 2020 23:08:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dpfEoXGX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BCE1221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrOn-0002nV-Im for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:08:37 -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 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= 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 X-MC-Unique: MS1xf-0WPBOleLBo9njFpg-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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()] def doc_type(self): if self.is_implicit(): @@ -480,8 +480,9 @@ def check(self, schema): types_seen = {} for v in self.variants.variants: v.check_clash(self.info, seen) - qtype = v.type.alternate_qtype() - if not qtype: + try: + qtype = v.type.alternate_qtype() + except KeyError: raise QAPISemError( self.info, "%s cannot use %s" From patchwork Tue Sep 22 22:44:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 273002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22F13C2D0E2 for ; Tue, 22 Sep 2020 22:51:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC9FF20BED for ; Tue, 22 Sep 2020 22:51:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UrE3Y38r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC9FF20BED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKr8d-0002Wp-N9 for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:51:55 -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 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= 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 X-MC-Unique: 6P_BKxHSPEK1Usp9Sr-9_Q-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We'll actually get a better error message by just letting the dictionary lookup fail. Signed-off-by: John Snow --- 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): def module_by_fname(self, fname): name = self._module_name(fname) - assert name in self._module_dict return self._module_dict[name] def _def_include(self, expr, info, doc): From patchwork Tue Sep 22 22:44:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 273000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61B04C4727E for ; Tue, 22 Sep 2020 22:54:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EAAB221EB for ; Tue, 22 Sep 2020 22:54:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PnaUFblZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EAAB221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrAs-00063A-04 for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:54:14 -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 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= 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 X-MC-Unique: its6LuBsP5-elTdm9CsvRw-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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): @property def ifcond(self): - assert self._checked + assert self._checked and isinstance(self._ifcond, list) return self._ifcond def is_implicit(self): From patchwork Tue Sep 22 22:44:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B54EEC2D0E2 for ; Tue, 22 Sep 2020 22:57:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54F3F221EB for ; Tue, 22 Sep 2020 22:57:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ccRPPNzG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54F3F221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrES-0004d8-Cm for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:57:56 -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 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= 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 X-MC-Unique: rCwE_BeKOkSZRPgTMbuQkw-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 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 = seen.values() + + # check_clash is abstract, but local_members is asserted to be + # Sequence[QAPISchemaObjectTypeMember]. Cast to the narrower type. + members = cast(List[QAPISchemaObjectTypeMember], list(seen.values())) if self.variants: self.variants.check(schema, seen) From patchwork Tue Sep 22 22:44:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3AB1C2D0E2 for ; Tue, 22 Sep 2020 22:55:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FC7020BED for ; Tue, 22 Sep 2020 22:55:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PbXaK48k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FC7020BED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrCV-00015F-GE for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:55:55 -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 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= 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 X-MC-Unique: DOLV6BUYP2ugOshofI2UPQ-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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): def _set_module(self, schema, info): assert self._checked - self._module = schema.module_by_fname(info and info.fname) + self._module = schema.module_by_fname(info.fname if info else None) self._module.add_entity(self) def set_module(self, schema): @@ -305,7 +305,7 @@ def check(self, schema): super().check(schema) self.element_type = 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) def set_module(self, schema): From patchwork Tue Sep 22 22:44:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E21C7C2D0E2 for ; Tue, 22 Sep 2020 22:57:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A3DF221EB for ; Tue, 22 Sep 2020 22:57:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Es/7wed6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A3DF221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrDu-0003Iz-Fq for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:57:22 -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 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= 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 X-MC-Unique: RAJO-UEAP8uKrF6xm8E2-w-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 = self.ret_type - if isinstance(typ, QAPISchemaArrayType): + if isinstance(self.ret_type, QAPISchemaArrayType): typ = self.ret_type.element_type assert typ if not isinstance(typ, QAPISchemaObjectType): From patchwork Tue Sep 22 22:44:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1429AC2D0E2 for ; Tue, 22 Sep 2020 22:56:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0FA620BED for ; Tue, 22 Sep 2020 22:55:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HfvlOQ/m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0FA620BED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrCY-0001C7-Ni for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:55:58 -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 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= 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 X-MC-Unique: 2ryE0ewlMaWVM44pIyienQ-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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[QAPISchemaType]" has no attribute "check_clash" Signed-off-by: John Snow --- 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)) From patchwork Tue Sep 22 22:44:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F09CCC2D0E2 for ; Tue, 22 Sep 2020 23:03:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 578AE221EB for ; Tue, 22 Sep 2020 23:03:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SQLlgoEt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 578AE221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrJn-0003aB-CU for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:03:27 -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 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= 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 X-MC-Unique: XrjDxhYZOyWkCn8IM7p4tQ-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow --- 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 @@ # TODO catching name collisions in generated code would be nice -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, +) 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 class Visitable: @@ -32,13 +44,18 @@ def visit(self, visitor: 'QAPISchemaVisitor') -> None: class QAPISchemaEntity(Visitable): - def __init__(self, name: str, info, doc, ifcond=None, features=None): + def __init__(self, + name: str, + info: Optional[QAPISourceInfo], + doc: Optional[QAPIDoc], + ifcond: Optional[Union[List[str], 'QAPISchemaType']] = None, + features: Optional[List['QAPISchemaFeature']] = 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 = name - self._module = None + self._module: Optional[QAPISchemaModule] = 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 = value - def c_name(self): + def c_name(self) -> str: return c_name(self.name) - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: assert not self._checked - seen = {} + seen: Dict[str, 'QAPISchemaMember'] = {} for f in self.features: f.check_clash(self.info, seen) self._checked = True - def connect_doc(self, doc=None): + def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: doc = doc or self.doc if doc: for f in self.features: doc.connect_feature(f) - def check_doc(self): + def check_doc(self) -> None: if self.doc: self.doc.check() - def _set_module(self, schema, info): + def _set_module(self, + schema: 'QAPISchema', + info: Optional[QAPISourceInfo]) -> None: assert self._checked self._module = schema.module_by_fname(info.fname if info else None) self._module.add_entity(self) - def set_module(self, schema): + def set_module(self, schema: 'QAPISchema') -> None: self._set_module(schema, self.info) @property - def ifcond(self): + def ifcond(self) -> List[str]: assert self._checked and isinstance(self._ifcond, list) return self._ifcond - def is_implicit(self): + def is_implicit(self) -> bool: return not self.info - def visit(self, visitor): + def visit(self, visitor: 'QAPISchemaVisitor') -> None: assert self._checked - def describe(self): + def describe(self) -> str: assert self.meta return "%s '%s'" % (self.meta, self.name) class QAPISchemaVisitor: - def visit_begin(self, schema): + def visit_begin(self, schema: 'QAPISchema') -> None: pass - def visit_end(self): + def visit_end(self) -> None: pass - def visit_module(self, name): + def visit_module(self, name: Optional[str]) -> None: pass - def visit_needed(self, entity): + def visit_needed(self, entity: QAPISchemaEntity) -> bool: # Default to visiting everything return True - def visit_include(self, name, info): + def visit_include(self, name: str, info: QAPISourceInfo) -> None: pass - def visit_builtin_type(self, name, info, json_type): + def visit_builtin_type(self, name: str, + info: Optional[QAPISourceInfo], + json_type: str) -> None: pass - def visit_enum_type(self, name, info, ifcond, features, members, prefix): + def visit_enum_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List['QAPISchemaFeature'], + members: List['QAPISchemaEnumMember'], + prefix: Optional[str]) -> None: pass - 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 - 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']) -> None: pass - 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 - 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 - 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 - 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 class QAPISchemaModule(Visitable): - def __init__(self, name): + def __init__(self, name: Optional[str]): self.name = name - self._entity_list = [] + self._entity_list: List[QAPISchemaEntity] = [] - def add_entity(self, ent): + def add_entity(self, ent: QAPISchemaEntity) -> None: self._entity_list.append(ent) - 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): 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 = sub_module - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_include(self._sub_module.name, self.info) @@ -181,17 +244,17 @@ def c_type(self) -> str: raise NotImplementedError() # 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() # 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() def json_type(self) -> str: raise NotImplementedError() - def alternate_qtype(self): + def alternate_qtype(self) -> str: json2qtype = { 'null': 'QTYPE_QNULL', 'string': 'QTYPE_QSTRING', @@ -202,24 +265,24 @@ def alternate_qtype(self): } return json2qtype[self.json_type()] - def doc_type(self): + def doc_type(self) -> Optional[str]: if self.is_implicit(): return None return self.name - 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 types") - def describe(self): + def describe(self) -> str: assert self.meta return "%s type '%s'" % (self.meta, self.name) 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 = c_type self._meta = 'built-in' - def c_name(self): + def c_name(self) -> str: return self.name - def c_type(self): + def c_type(self) -> str: return self._c_type_name - def c_param_type(self): + def c_param_type(self) -> str: if self.name == 'str': return 'const ' + self._c_type_name return self._c_type_name - def json_type(self): + def json_type(self) -> str: return self._json_type_name - def doc_type(self): + def doc_type(self) -> str: return self.json_type() - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: super().visit(visitor) visitor.visit_builtin_type(self.name, self.info, self.json_type()) 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 = prefix self._meta = 'enum' - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) - seen = {} + seen: Dict[str, 'QAPISchemaMember'] = {} for m in self.members: m.check_clash(self.info, seen) - def connect_doc(self, doc=None): + def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc for m in self.members: m.connect_doc(doc) - 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 == 'QType' - def c_type(self): + def c_type(self) -> str: return c_name(self.name) - def member_names(self): + def member_names(self) -> List[str]: return [m.name for m in self.members] - def json_type(self): + def json_type(self) -> str: return 'string' - 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): 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 = element_type - self.element_type = None + self.element_type: Optional[QAPISchemaType] = None self._meta = 'array' - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) self.element_type = 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) - def set_module(self, schema): + def set_module(self, schema: 'QAPISchema') -> None: self._set_module(schema, self.element_type.info) @property - def ifcond(self): + def ifcond(self) -> List[str]: assert self._checked return self.element_type.ifcond - def is_implicit(self): + def is_implicit(self) -> bool: return True - def c_type(self): + def c_type(self) -> str: return c_name(self.name) + POINTER_SUFFIX - def json_type(self): + def json_type(self) -> str: return 'array' - def doc_type(self): + def doc_type(self) -> Optional[str]: elt_doc_type = self.element_type.doc_type() if not elt_doc_type: return None return 'array of ' + elt_doc_type - 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) - def describe(self): + def describe(self) -> str: assert self.meta return "%s type ['%s']" % (self.meta, self._element_type_name) 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 = base - self.base = None + self.base: Optional[QAPISchemaObjectType] = None self.local_members = local_members self.variants = variants - self.members = None + self.members: Optional[List[QAPISchemaObjectTypeMember]] = None - 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 - seen = OrderedDict() + seen: Dict[str, 'QAPISchemaMember'] = OrderedDict() if self._base_name: base = schema.resolve_type(self._base_name, self.info, "'base'") 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 members, # 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) - def connect_doc(self, doc=None): + def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc if self.base and self.base.is_implicit(): @@ -421,7 +502,7 @@ def connect_doc(self, doc=None): m.connect_doc(doc) @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 - 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_') - def is_empty(self): + def is_empty(self) -> bool: assert self.members is not None return not self.members and not self.variants - def c_name(self): + def c_name(self) -> str: assert self.name != 'q_empty' return super().c_name() - def c_type(self): + def c_type(self) -> str: assert not self.is_implicit() return c_name(self.name) + POINTER_SUFFIX - def c_unboxed_type(self): + def c_unboxed_type(self) -> str: return c_name(self.name) - def json_type(self): + def json_type(self) -> str: return 'object' - 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): 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, variants): self.variants = variants self._meta = 'alternate' - 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 = {} - types_seen = {} + seen: Dict[str, QAPISchemaMember] = {} + types_seen: Dict[str, str] = {} 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] = v.name - def connect_doc(self, doc=None): + def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc for v in self.variants.variants: v.connect_doc(doc) - def c_type(self): + def c_type(self) -> str: return c_name(self.name) + POINTER_SUFFIX - def json_type(self): + def json_type(self) -> str: return 'value' - 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.variants) 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, variants): self.tag_member = tag_member self.variants = variants - def set_defined_in(self, name): + def set_defined_in(self, name: str) -> None: for v in self.variants: v.set_defined_in(name) - def check(self, schema, seen): + def check(self, + schema: 'QAPISchema', + seen: Dict[str, 'QAPISchemaMember']) -> None: if not self.tag_member: # flat union tag_member = seen.get(c_name(self._tag_name)) base = "'base'" @@ -616,7 +709,9 @@ def check(self, schema, seen): % (v.describe(self.info), v.type.describe())) v.type.check(schema) - 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 = 'member' - def __init__(self, name, info, ifcond=None): + def __init__(self, name: str, + info: Optional[QAPISourceInfo], + ifcond: Optional[List[str]] = None): assert isinstance(name, str) self.name = name self.info = info self.ifcond = ifcond or [] - self.defined_in = None + self.defined_in: Optional[str] = None - def set_defined_in(self, name): + def set_defined_in(self, name: str) -> None: assert not self.defined_in self.defined_in = name - def check_clash(self, info, seen): + def check_clash(self, + info: Optional[QAPISourceInfo], + seen: Dict[str, 'QAPISchemaMember']) -> None: cname = 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] = self - def connect_doc(self, doc): + def connect_doc(self, doc: Optional[QAPIDoc]) -> None: if doc: doc.connect_member(self) - def describe(self, info): + def describe(self, info: QAPISourceInfo) -> str: role = self.role defined_in = self.defined_in assert defined_in @@ -692,7 +791,13 @@ class QAPISchemaFeature(QAPISchemaMember): class QAPISchemaObjectTypeMember(QAPISchemaMember): - def __init__(self, name, info, typ, optional, ifcond=None, features=None): + def __init__(self, + name: str, + info: QAPISourceInfo, + typ: str, + optional: bool, + ifcond: Optional[List[str]] = None, + features: Optional[List[QAPISchemaFeature]] = 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=None, features=None): assert isinstance(f, QAPISchemaFeature) f.set_defined_in(name) self._type_name = typ - self.type = None + self.type: Optional[QAPISchemaType] = None self.optional = optional self.features = features or [] - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: assert self.defined_in self.type = schema.resolve_type(self._type_name, self.info, self.describe) - seen = {} + seen: Dict[str, QAPISchemaMember] = {} for f in self.features: f.check_clash(self.info, seen) - 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 = 'branch' - def __init__(self, name, info, typ, ifcond=None): + def __init__(self, + name: str, + info: QAPISourceInfo, + typ: str, + ifcond: Optional[List[str]] = None): super().__init__(name, info, typ, False, ifcond) 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 = arg_type - self.arg_type = None + self.arg_type: Optional[QAPISchemaObjectType] = None self._ret_type_name = ret_type - self.ret_type = None + self.ret_type: Optional[QAPISchemaType] = None self.gen = gen self.success_response = success_response self.boxed = boxed @@ -744,7 +863,7 @@ def __init__(self, name, info, doc, ifcond, features, self.allow_preconfig = allow_preconfig self._meta = 'command' - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) if self._arg_type_name: arg_type = schema.resolve_type( @@ -774,14 +893,14 @@ def check(self, schema): "command's 'returns' cannot take %s" % self.ret_type.describe()) - def connect_doc(self, doc=None): + def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc if doc: if self.arg_type and self.arg_type.is_implicit(): self.arg_type.connect_doc(doc) - 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): 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 = arg_type - self.arg_type = None + self.arg_type: Optional[QAPISchemaObjectType] = None self.boxed = boxed self._meta = 'event' - def check(self, schema): + def check(self, schema: 'QAPISchema') -> None: super().check(schema) if self._arg_type_name: arg_type = 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()) - def connect_doc(self, doc=None): + def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc if doc: if self.arg_type and self.arg_type.is_implicit(): self.arg_type.connect_doc(doc) - 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) +_EntityType = TypeVar('_EntityType', bound=QAPISchemaEntity) + + class QAPISchema(Visitable): - def __init__(self, fname): + def __init__(self, fname: str): self.fname = fname parser = QAPISchemaParser(fname) exprs = check_exprs(parser.exprs) self.docs = parser.docs - self._entity_list = [] - self._entity_dict = {} - self._module_dict = OrderedDict() + self._entity_list: List[QAPISchemaEntity] = [] + self._entity_dict: Dict[str, QAPISchemaEntity] = {} + self._module_dict: Dict[str, QAPISchemaModule] = OrderedDict() self._schema_dir = 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() - 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] = ent - def lookup_entity(self, name, typ=None): + @overload + def lookup_entity(self, name: str, + typ: None = 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]] = None, + ) -> Optional[QAPISchemaEntity]: ent = self._entity_dict.get(name) if typ and not isinstance(ent, typ): return None return ent - def lookup_type(self, name): + def lookup_type(self, name: str) -> QAPISchemaType: return self.lookup_entity(name, QAPISchemaType) - def resolve_type(self, name, info, what): + def resolve_type(self, + name: str, + info: Optional[QAPISourceInfo], + what: Optional[ + Union[str, Callable[[Optional[QAPISourceInfo]], str]] + ], + ) -> QAPISchemaType: typ = 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 - 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) - def _make_module(self, fname): + def _make_module(self, fname: Optional[str]) -> QAPISchemaModule: name = self._module_name(fname) if name not in self._module_dict: self._module_dict[name] = QAPISchemaModule(name) return self._module_dict[name] - def module_by_fname(self, fname): + def module_by_fname(self, fname: Optional[str]) -> QAPISchemaModule: name = self._module_name(fname) return self._module_dict[name] - def _def_include(self, expr, info, doc): + def _def_include(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: Optional[QAPIDoc]) -> None: include = expr['include'] assert doc is None self._def_entity(QAPISchemaInclude(self._make_module(include), info)) - 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) - 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, None, qtype_values, 'QTYPE')) - 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] - 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] - 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 = name + 'Kind' # reserved by check_defn_name_str() self._def_entity(QAPISchemaEnumType( @@ -960,13 +1121,21 @@ def _make_implicit_enum_type(self, name, info, ifcond, values): None)) return name - def _make_array_type(self, element_type, info): + def _make_array_type(self, + element_type: str, + info: QAPISourceInfo) -> str: name = element_type + 'List' # reserved by check_defn_name_str() if not self.lookup_type(name): self._def_entity(QAPISchemaArrayType(name, info, element_type)) return name - 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[QAPISchemaObjectTypeMember], + ) -> Optional[str]: if not members: return None # See also QAPISchemaObjectTypeMember.describe() @@ -990,7 +1159,10 @@ def _make_implicit_object_type(self, name, info, ifcond, role, members): name, info, None, ifcond, None, None, members, None)) return name - def _def_enum_type(self, expr, info, doc): + def _def_enum_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name = expr['enum'] data = expr['data'] prefix = 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)) - 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 = False if name.startswith('*'): name = name[1:] @@ -1011,12 +1188,18 @@ def _make_member(self, name, typ, ifcond, features, info): return QAPISchemaObjectTypeMember(name, info, typ, optional, ifcond, self._make_features(features, info)) - 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()] - def _def_struct_type(self, expr, info, doc): + def _def_struct_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name = expr['struct'] base = expr.get('base') data = expr['data'] @@ -1027,10 +1210,18 @@ def _def_struct_type(self, expr, info, doc): self._make_members(data, info), None)) - 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) - 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) == 1 typ = self._make_array_type(typ[0], info) @@ -1039,7 +1230,10 @@ def _make_simple_variant(self, case, typ, ifcond, info): 'wrapper', [self._make_member('data', typ, None, None, info)]) return QAPISchemaVariant(case, info, typ, ifcond) - def _def_union_type(self, expr, info, doc): + def _def_union_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name = expr['union'] data = expr['data'] base = expr.get('base') @@ -1070,7 +1264,10 @@ def _def_union_type(self, expr, info, doc): QAPISchemaVariants( tag_name, info, tag_member, variants))) - def _def_alternate_type(self, expr, info, doc): + def _def_alternate_type(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name = expr['alternate'] data = expr['data'] ifcond = expr.get('if') @@ -1084,7 +1281,10 @@ def _def_alternate_type(self, expr, info, doc): QAPISchemaVariants( None, info, tag_member, variants))) - def _def_command(self, expr, info, doc): + def _def_command(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name = expr['command'] data = expr.get('data') rets = expr.get('returns') @@ -1107,7 +1307,10 @@ def _def_command(self, expr, info, doc): gen, success_response, boxed, allow_oob, allow_preconfig)) - def _def_event(self, expr, info, doc): + def _def_event(self, + expr: Dict[str, Any], + info: QAPISourceInfo, + doc: QAPIDoc) -> None: name = expr['event'] data = expr.get('data') boxed = 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)) - def _def_exprs(self, exprs): + def _def_exprs(self, exprs: List[ParsedExpression]) -> None: for expr_elem in exprs: expr = expr_elem.expr info = expr_elem.info @@ -1142,7 +1345,7 @@ def _def_exprs(self, exprs): else: assert False - 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) - def visit(self, visitor): + def visit(self, visitor: QAPISchemaVisitor) -> None: visitor.visit_begin(self) for mod in self._module_dict.values(): mod.visit(visitor) From patchwork Tue Sep 22 22:44:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65B7DC4727D for ; Tue, 22 Sep 2020 23:05:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0721F207C3 for ; Tue, 22 Sep 2020 23:05:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AenWaAss" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0721F207C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrLv-0007Ai-Oq for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:05:39 -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 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= 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 X-MC-Unique: AC5wSlo1MyGpxrrTGP1HGA-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- 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 = True strict_optional = False -disallow_untyped_calls = False python_version = 3.6 - -[mypy-qapi.schema] -disallow_untyped_defs = False -disallow_incomplete_defs = False -check_untyped_defs = False From patchwork Tue Sep 22 22:44:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46B50C2D0E2 for ; Tue, 22 Sep 2020 23:02:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC33F221EB for ; Tue, 22 Sep 2020 23:02:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Tm+GZu47" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC33F221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrJ7-0002KW-P5 for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:02:45 -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 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= 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 X-MC-Unique: jvJHcrs_MYOiZaX4MkIE7Q-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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=schema.py, # --disable=W". disable=fixme, missing-docstring, + similarities, # See https://github.com/PyCQA/pylint/issues/3619 too-many-arguments, too-many-branches, too-many-statements, From patchwork Tue Sep 22 22:44:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BEE5C2D0E2 for ; Tue, 22 Sep 2020 23:04:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9ECB221EB for ; Tue, 22 Sep 2020 23:04:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IyW1pJeR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9ECB221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrKT-0004lB-Qq for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:04:09 -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 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= 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 X-MC-Unique: dCXCEEm8PEelBIoBmKvJUg-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- 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 @@ class Visitable: """Abstract duck that suggests a class is visitable.""" + # pylint: disable=too-few-public-methods + def visit(self, visitor: 'QAPISchemaVisitor') -> None: raise NotImplementedError @@ -133,6 +135,7 @@ def visit_module(self, name: Optional[str]) -> None: pass def visit_needed(self, entity: QAPISchemaEntity) -> bool: + # pylint: disable=unused-argument, no-self-use # Default to visiting everything return True From patchwork Tue Sep 22 22:44:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 304672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C712C2D0E2 for ; Tue, 22 Sep 2020 23:00:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6ECB5221EB for ; Tue, 22 Sep 2020 23:00:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fJz56H3h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ECB5221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrGq-0008Ct-Fn for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:00:24 -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 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= 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 X-MC-Unique: -J-Tmn0JP-a9lFLJnOJ96Q-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If they don't use self and nothing that extends them needs self either, they can be classmethods. Signed-off-by: John Snow --- 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, None, qtype_values, 'QTYPE')) - 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] - 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)) - def _make_variant(self, + @classmethod + def _make_variant(cls, case: str, typ: str, ifcond: Optional[List[str]], From patchwork Tue Sep 22 22:44:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 663E8C2D0E2 for ; Tue, 22 Sep 2020 22:59:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CBBEC221EB for ; Tue, 22 Sep 2020 22:59:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SxCwp2rA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBBEC221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrG6-0006x3-P7 for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:59:38 -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 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= 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 X-MC-Unique: OWRrEI3IOXiAhRPr-Zt4_Q-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" I hope you like butter, because here comes the churn! Signed-off-by: John Snow --- 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']] = None, features: Optional[List['QAPISchemaFeature']] = 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 = name self._module: Optional[QAPISchemaModule] = 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'] = {} - for f in self.features: - f.check_clash(self.info, seen) + for feature in self.features: + feature.check_clash(self.info, seen) self._checked = True def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: doc = doc or self.doc if doc: - for f in self.features: - doc.connect_feature(f) + for feature in self.features: + doc.connect_feature(feature) 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 = members self.prefix = prefix @@ -337,14 +339,14 @@ def __init__(self, def check(self, schema: 'QAPISchema') -> None: super().check(schema) seen: Dict[str, 'QAPISchemaMember'] = {} - for m in self.members: - m.check_clash(self.info, seen) + for member in self.members: + member.check_clash(self.info, seen) def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc - for m in self.members: - m.connect_doc(doc) + for member in self.members: + member.connect_doc(doc) 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 = '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 = 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) # 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) def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = 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) @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] = {} types_seen: Dict[str, str] = {} - 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 = v.type.alternate_qtype() + qtype = variant.type.alternate_qtype() except KeyError: - raise QAPISemError( - self.info, - "%s cannot use %s" - % (v.describe(self.info), v.type.describe())) + msg = "{} cannot use {}".format( + variant.describe(self.info), variant.type.describe()) + raise QAPISemError(self.info, msg) from None + conflicting = set([qtype]) if qtype == '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] = v.name + + for qtype in conflicting: + if qtype in types_seen: + msg = "{} can't be distinguished from '{}'".format( + variant.describe(self.info), types_seen[qtype]) + raise QAPISemError(self.info, msg) + + types_seen[qtype] = variant.name def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None: super().connect_doc(doc) doc = doc or self.doc - for v in self.variants.variants: - v.connect_doc(doc) + for variant in self.variants.variants: + variant.connect_doc(doc) def c_type(self) -> str: return c_name(self.name) + POINTER_SUFFIX @@ -632,16 +637,16 @@ def __init__(self, assert bool(tag_member) != 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 = tag_name self.info = info self.tag_member = tag_member self.variants = variants 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) 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 = {v.name for v in self.variants} - for m in self.tag_member.type.members: - if m.name not in cases: - v = 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 = 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) 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)) 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 = typ self.type: Optional[QAPISchemaType] = None self.optional = optional @@ -817,14 +823,14 @@ def check(self, schema: 'QAPISchema') -> None: self.type = schema.resolve_type(self._type_name, self.info, self.describe) seen: Dict[str, QAPISchemaMember] = {} - for f in self.features: - f.check_clash(self.info, seen) + for feature in self.features: + feature.check_clash(self.info, seen) 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) class QAPISchemaVariant(QAPISchemaObjectTypeMember): @@ -1068,22 +1074,22 @@ def _def_builtin_type(self, self._make_array_type(name, None) 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 = QAPISchemaObjectType( 'q_empty', None, None, None, None, None, [], None) self._def_entity(self.the_empty_object_type) From patchwork Tue Sep 22 22:44:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272996 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1548AC2D0E2 for ; Tue, 22 Sep 2020 22:58:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CC19221EB for ; Tue, 22 Sep 2020 22:58:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D1MVOgOm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CC19221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrEa-0004j5-Ng for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 18:58:04 -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 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= 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 X-MC-Unique: RfqDWe25Nfu5m2TJF2pIIA-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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. +# pylint: disable=too-many-lines ¯\_(ツ)_/¯ + # TODO catching name collisions in generated code would be nice from collections import OrderedDict From patchwork Tue Sep 22 22:44:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FEFC2D0E2 for ; Tue, 22 Sep 2020 23:09:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E274221EF for ; Tue, 22 Sep 2020 23:09:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M1hgNnL0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E274221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrPg-0003cI-CN for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:09:32 -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 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= 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 X-MC-Unique: WyrSCoCWOAa1HQSJtI2lDA-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This is an interface with a default implementation. Pylint doesn't have enough context to be aware of this. Signed-off-by: John Snow --- 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) def check(self, schema: 'QAPISchema') -> None: + # pylint: disable=unused-argument assert not self._checked seen: Dict[str, 'QAPISchemaMember'] = {} for feature in self.features: From patchwork Tue Sep 22 22:44:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00D09C2D0E2 for ; Tue, 22 Sep 2020 23:00:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65861221EB for ; Tue, 22 Sep 2020 23:00:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZmDGkcHB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65861221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrGt-0008I1-DZ for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:00:27 -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 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= 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 X-MC-Unique: MbLuDRHLNhSsRDc--bSdmg-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- 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] -# Add files or directories matching the regex patterns to the ignore list. -# The regex matches against base names, not paths. -ignore-patterns=schema.py, - - [MESSAGES CONTROL] # Disable the message, report, category or checker with the given id(s). You From patchwork Tue Sep 22 22:45:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36A84C2D0E2 for ; Tue, 22 Sep 2020 23:10:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0B6C221EF for ; Tue, 22 Sep 2020 23:10:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dUdXw3G7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0B6C221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrQx-0005MV-QH for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:10:51 -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 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= 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 X-MC-Unique: MZnOQA9PNtKdhSQ2b5JJNQ-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add some microdocumentation that gives a nice file-level overview of this 1300+ line file. Signed-off-by: John Snow --- 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: From patchwork Tue Sep 22 22:45:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 272990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC522C2D0E2 for ; Tue, 22 Sep 2020 23:07:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36EC9221EF for ; Tue, 22 Sep 2020 23:07:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dDuo6DsP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36EC9221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKrO0-0001nF-2I for qemu-devel@archiver.kernel.org; Tue, 22 Sep 2020 19:07:48 -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 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= 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 X-MC-Unique: A7XYGYkIPGuaRV0mWF7LSw-1 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- 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 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 types")