From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D5DC6C6FD18 for ; Tue, 25 Apr 2023 12:33:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prHqp-0003mG-H8; Tue, 25 Apr 2023 08:32:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prHqh-0003ld-91 for qemu-devel@nongnu.org; Tue, 25 Apr 2023 08:32:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prHqd-0006Jc-LH for qemu-devel@nongnu.org; Tue, 25 Apr 2023 08:32:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682425961; h=from:from:reply-to: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=T6guICRAkNLAupPJFtMXfoR19gxizcfPEJPdIbECQYs=; b=NC+crDjDVnRbMSrjSIWzQUOzSmBbdhywkxeDZcE0vQqPQQPBq2G6oLluoYGWLoBJ8s9lib CriJYfnPdwiVy50usdRF5hIvPg549BQPV05zvwffLY/ku/+4dlQAf0UrsGUZQUq9hBWhRQ UJdyY7pkXIkNy0bDRdSLWVNpKBywkFk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-HSB4UV-zP8WQKzxOD0IRfw-1; Tue, 25 Apr 2023 08:32:38 -0400 X-MC-Unique: HSB4UV-zP8WQKzxOD0IRfw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94B7485A5B1; Tue, 25 Apr 2023 12:32:34 +0000 (UTC) Received: from redhat.com (unknown [10.42.28.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CD5340C2064; Tue, 25 Apr 2023 12:32:32 +0000 (UTC) Date: Tue, 25 Apr 2023 13:32:29 +0100 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Markus Armbruster Cc: qemu-devel@nongnu.org, Het Gala , Eric Blake , Michael Roth Subject: Re: [PATCH v3 2/3] qapi: improve specificity of type/member descriptions Message-ID: References: <20230420102619.348173-1-berrange@redhat.com> <20230420102619.348173-3-berrange@redhat.com> <87a5yxa4sy.fsf@pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87a5yxa4sy.fsf@pond.sub.org> User-Agent: Mutt/2.2.9 (2022-11-12) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Mon, Apr 24, 2023 at 01:38:21PM +0200, Markus Armbruster wrote: > Daniel P. Berrangé writes: > > > When describing member types always include the context of the > > containing type. Although this is often redundant, in some cases > > it will help to reduce ambiguity. > > This is no longer true. It was in v2. Suggest: > > Error messages describe object members, enumeration values, features, > and variants like ROLE 'NAME', where ROLE is "member", "value", > "feature", or "branch", respectively. When the member is defined in > another type, e.g. inherited from a base type, we add "of type > 'TYPE'". Example: test case struct-base-clash-deep reports a member > of type 'Sub' clashing with a member of its base type 'Base' as > > struct-base-clash-deep.json: In struct 'Sub': > struct-base-clash-deep.json:10: member 'name' collides with member 'name' of type 'Base' > > Members of implicitly defined types need special treatment. We don't > want to add "of type 'TYPE'" for them, because their named are made up > and mean nothing to the user. Instead, we describe members of an > implicitly defined base type as "base member 'NAME'", and command and > event parameters as "parameter 'NAME'". Example: test case > union-bad-base reports member of a variant's type clashing with a > member of its implicitly defined base type as > > union-bad-base.json: In union 'TestUnion': > union-bad-base.json:8: member 'string' of type 'TestTypeA' collides with base member 'string' > > The next commit will permit unions as variant types. "base member > 'NAME' would then be ambigious: is it the union's base, or is it the > union's variant's base? One of its test cases would report a clash > between two such bases as "base member 'type' collides with base > member 'type'". Confusing. > > Refine the special treatment: add "of TYPE" even for implicitly > defined types, but massage TYPE and ROLE so they make sense for the > user. > > > Signed-off-by: Daniel P. Berrangé > > --- > > scripts/qapi/schema.py | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py > > index 207e4d71f3..da04b97ded 100644 > > --- a/scripts/qapi/schema.py > > +++ b/scripts/qapi/schema.py > > @@ -697,6 +697,7 @@ def connect_doc(self, doc): > > > > def describe(self, info): > > role = self.role > > + meta = 'type' > > defined_in = self.defined_in > > assert defined_in > > > > @@ -708,13 +709,17 @@ def describe(self, info): > > # Implicit type created for a command's dict 'data' > > assert role == 'member' > > role = 'parameter' > > + meta = 'command' > > + defined_in = defined_in[:-4] > > elif defined_in.endswith('-base'): > > # Implicit type created for a union's dict 'base' > > role = 'base ' + role > > + defined_in = defined_in[:-5] > > else: > > assert False > > - elif defined_in != info.defn_name: > > - return "%s '%s' of type '%s'" % (role, self.name, defined_in) > > + > > + if defined_in != info.defn_name: > > + return "%s '%s' of %s '%s'" % (role, self.name, meta, defined_in) > > return "%s '%s'" % (role, self.name) > > Since I rewrote both the patch and the commit message, would you like me > to take the blame and claim authorship? Yes, I should have credited you as the author here since it was just taking your proposed code. The suggested commit message looks fine too With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|