[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/14] qapi/doc.py: Assert type of object variant
From: |
John Snow |
Subject: |
[PATCH 13/14] qapi/doc.py: Assert type of object variant |
Date: |
Tue, 22 Sep 2020 17:18:01 -0400 |
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
- [PATCH 02/14] qapi/doc.py: avoid unnecessary keyword arguments, (continued)
- [PATCH 02/14] qapi/doc.py: avoid unnecessary keyword arguments, John Snow, 2020/09/22
- [PATCH 03/14] qapi/doc.py: Add assertion on section.member, John Snow, 2020/09/22
- [PATCH 07/14] qapi/doc.py: enable mypy checks, John Snow, 2020/09/22
- [PATCH 10/14] qapi/gen.py: Add __bool__ dunder method to QAPIGen, John Snow, 2020/09/22
- [PATCH 12/14] qapi/doc.py: Assert tag member is Enum type, John Snow, 2020/09/22
- [PATCH 13/14] qapi/doc.py: Assert type of object variant,
John Snow <=
- [PATCH 11/14] qapi/doc.py: Don't use private attributes of QAPIGen property, John Snow, 2020/09/22
- [PATCH 14/14] qapi/doc.py: enable pylint checks, John Snow, 2020/09/22
- [PATCH 04/14] qapi/doc.py: assert correct types in member_func callbacks, John Snow, 2020/09/22
- [PATCH 05/14] qapi/doc.py: Assert no suffix given for enum members, John Snow, 2020/09/22
- [PATCH 06/14] qapi/doc.py: Add type hint annotations, John Snow, 2020/09/22