[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/14] qapi/doc.py: assert correct types in member_func callbacks
From: |
John Snow |
Subject: |
[PATCH 04/14] qapi/doc.py: assert correct types in member_func callbacks |
Date: |
Tue, 22 Sep 2020 17:17:52 -0400 |
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(-)
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' % (
--
2.26.2
- [PATCH 10/14] qapi/gen.py: Add __bool__ dunder method to QAPIGen, (continued)
- [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, 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 <=
- [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
- [PATCH 09/14] qapi/doc.py: Remove one-letter variables, John Snow, 2020/09/22
- [PATCH 08/14] qapi/doc.py: Add generic texi_member callback, John Snow, 2020/09/22
- Re: [PATCH 00/14] qapi: static typing conversion, pt3, John Snow, 2020/09/30