[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/14] qapi/doc.py: Assert tag member is Enum type
From: |
John Snow |
Subject: |
[PATCH 12/14] qapi/doc.py: Assert tag member is Enum type |
Date: |
Tue, 22 Sep 2020 17:18:00 -0400 |
The type system can't quite express this constraint natively: members
can envelop any type -- but tag_members may only ever envelop an
enumerated type.
For now, shrug and add 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 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 2914e93b1c..b96d9046d3 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -13,6 +13,7 @@
QAPISchema,
QAPISchemaEntity,
QAPISchemaEnumMember,
+ QAPISchemaEnumType,
QAPISchemaFeature,
QAPISchemaMember,
QAPISchemaObjectType,
@@ -193,6 +194,7 @@ def texi_members(doc: QAPIDoc,
desc = texi_format(section.text)
elif variants and variants.tag_member == section.member:
assert isinstance(section.member, QAPISchemaObjectTypeMember)
+ assert isinstance(section.member.type, QAPISchemaEnumType)
if not section.member.type.doc_type():
values = section.member.type.member_names()
members_text = ', '.join(['@t{"%s"}' % v for v in values])
--
2.26.2
- [PATCH 01/14] qapi/doc.py: stash long temporary locals in named locals, (continued)
- [PATCH 01/14] qapi/doc.py: stash long temporary locals in named locals, John Snow, 2020/09/22
- [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 <=
- [PATCH 13/14] qapi/doc.py: Assert type of object variant, John Snow, 2020/09/22
- [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