diff mbox series

[04/14] qapi/doc.py: assert correct types in member_func callbacks

Message ID 20200922211802.4083666-5-jsnow@redhat.com
State New
Headers show
Series qapi: static typing conversion, pt3 | expand

Commit Message

John Snow Sept. 22, 2020, 9:17 p.m. UTC
These each take a specific subtype; assert that they got that correct
subtype.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/doc.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Eduardo Habkost Sept. 23, 2020, 8:46 p.m. UTC | #1
On Tue, Sep 22, 2020 at 05:17:52PM -0400, John Snow wrote:
> These each take a specific subtype; assert that they got that correct

> subtype.

> 

> Signed-off-by: John Snow <jsnow@redhat.com>


Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>


-- 
Eduardo
diff mbox series

Patch

diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index c645876b24..62b8f34707 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -8,7 +8,11 @@ 
 from typing import Optional
 
 from .gen import QAPIGenDoc
-from .schema import QAPISchemaVisitor, QAPISchemaObjectTypeMember
+from .schema import (
+    QAPISchemaEnumMember,
+    QAPISchemaObjectTypeMember,
+    QAPISchemaVisitor,
+)
 
 MSG_FMT = """
 @deftypefn {type} {{}} {name}
@@ -136,12 +140,14 @@  def texi_if(ifcond, prefix='\n', suffix='\n'):
 
 def texi_enum_value(value, desc, suffix):
     """Format a table of members item for an enumeration value"""
+    assert isinstance(value, QAPISchemaEnumMember)
     return '@item @code{%s}\n%s%s' % (
         value.name, desc, texi_if(value.ifcond, prefix='@*'))
 
 
 def texi_member(member, desc, suffix):
     """Format a table of members item for an object type member"""
+    assert isinstance(member, QAPISchemaObjectTypeMember)
     typ = member.type.doc_type()
     membertype = ': ' + typ if typ else ''
     return '@item @code{%s%s}%s%s\n%s%s' % (