[PATCH 13/14] qapi/doc.py: Assert type of object variant

John Snow posted 14 patches 5 years, 4 months ago
There is a newer version of this series
[PATCH 13/14] qapi/doc.py: Assert type of object variant
Posted by John Snow 5 years, 4 months ago
Objects may have variants, but those variants must themselves be
objects. This is difficult to express with our current type system and
hierarchy, so instead pepper in an assertion.

Note: These assertions don't appear to be useful yet because schema.py
is not yet typed. Once it is, these assertions will matter.

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

diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index b96d9046d3..3de592e220 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -206,6 +206,7 @@ def texi_members(doc: QAPIDoc,
     if base:
         items += '@item The members of @code{%s}\n' % base.doc_type()
     for variant in variants.variants if variants else ():
+        assert isinstance(variant.type, QAPISchemaObjectType)
         when = ' when @code{%s} is @t{"%s"}%s' % (
             variants.tag_member.name, variant.name,
             texi_if(variant.ifcond, " (", ")"))
-- 
2.26.2


Re: [PATCH 13/14] qapi/doc.py: Assert type of object variant
Posted by Eduardo Habkost 5 years, 4 months ago
On Tue, Sep 22, 2020 at 05:18:01PM -0400, John Snow wrote:
> Objects may have variants, but those variants must themselves be
> objects. This is difficult to express with our current type system and
> hierarchy, so instead pepper in an assertion.
> 
> Note: These assertions don't appear to be useful yet because schema.py
> is not yet typed. Once it is, these assertions will matter.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

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

-- 
Eduardo