All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-devel@nongnu.org, "Michael Roth" <michael.roth@amd.com>
Subject: Re: [PATCH v3] qapi: provide a friendly string representation of QAPI classes
Date: Thu, 19 Oct 2023 07:22:20 +0200	[thread overview]
Message-ID: <87il73mbjn.fsf@pond.sub.org> (raw)
In-Reply-To: <f12e8129-a77d-e8ee-2a25-b31b5729a0f5@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Wed, 18 Oct 2023 15:20:10 +0200")

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 18/10/23 15:02, Daniel P. Berrangé wrote:
>> On Wed, Oct 18, 2023 at 02:37:45PM +0200, Markus Armbruster wrote:
>>> Daniel P. Berrangé <berrange@redhat.com> writes:
>>>
>>>> If printing a QAPI schema object for debugging we get the classname and
>>>> a hex value for the instance:
>>>>
>>>>    <qapi.schema.QAPISchemaEnumType object at 0x7f0ab4c2dad0>
>>>>    <qapi.schema.QAPISchemaObjectType object at 0x7f0ab4c2dd90>
>>>>    <qapi.schema.QAPISchemaArrayType object at 0x7f0ab4c2df90>
>>>>
>>>> With this change we instead get the classname and the human friendly
>>>> name of the QAPI type instance:
>>>>
>>>>    <QAPISchemaEnumType:CpuS390State at 0x7f0ab4c2dad0>
>>>>    <QAPISchemaObjectType:CpuInfoS390 at 0x7f0ab4c2dd90>
>>>>    <QAPISchemaArrayType:CpuInfoFastList at 0x7f0ab4c2df90>
>>>>
>>>> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>>>> ---
>
>
>>> Mind if I swap things?  Like so:
>>>
>>>      def __repr__(self):
>>>          if self.name is None:
>>>              return "<%s at 0x%x>" % (type(self).__name__, id(self))
>>>          else:
>>>              return "<%s:%s at 0x%x>" % (type(self).__name__,
>>>                                          self.name, id(self))
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Actually, I'd like to make this

    def __repr__(self):
        if self.name is None:
            return "<%s at 0x%x>" % (type(self).__name__, id(self))
        return "<%s:%s at 0x%x>" % type(self).__name__, self.name, id(self)

to avoid pylint's refactoring checker message

    +scripts/qapi/schema.py:77:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)

Queued.  Thanks!



      reply	other threads:[~2023-10-19  5:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 12:05 [PATCH v3] qapi: provide a friendly string representation of QAPI classes Daniel P. Berrangé
2023-10-18 12:37 ` Markus Armbruster
2023-10-18 13:02   ` Daniel P. Berrangé
2023-10-18 13:20     ` Philippe Mathieu-Daudé
2023-10-19  5:22       ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il73mbjn.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.