diff mbox series

[01/19] qapi/schema: fix QAPISchemaEntity.__repr__()

Message ID 20231116014350.653792-2-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series qapi: statically type schema.py | expand

Commit Message

John Snow Nov. 16, 2023, 1:43 a.m. UTC
This needs parentheses to work how you want it to:

>>> "%s-%s-%s" % 'a', 'b', 'c'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string

>>> "%s-%s-%s" % ('a', 'b', 'c')
'a-b-c'

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/schema.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Nov. 16, 2023, 7:01 a.m. UTC | #1
On 16/11/23 02:43, John Snow wrote:
> This needs parentheses to work how you want it to:
> 
>>>> "%s-%s-%s" % 'a', 'b', 'c'
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> TypeError: not enough arguments for format string
> 
>>>> "%s-%s-%s" % ('a', 'b', 'c')
> 'a-b-c'
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>   scripts/qapi/schema.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> index d739e558e9e..c79747b2a15 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
> @@ -76,7 +76,7 @@ def __init__(self, name: str, info, doc, ifcond=None, features=None):
>       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)
> +        return "<%s:%s at 0x%x>" % (type(self).__name__, self.name, id(self))

This is commit 6d133eef98 ("qapi: Fix QAPISchemaEntity.__repr__()").
diff mbox series

Patch

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index d739e558e9e..c79747b2a15 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -76,7 +76,7 @@  def __init__(self, name: str, info, doc, ifcond=None, features=None):
     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)
+        return "<%s:%s at 0x%x>" % (type(self).__name__, self.name, id(self))
 
     def c_name(self):
         return c_name(self.name)