[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/22] qapi/parser: Assert lexer value is a string
From: |
John Snow |
Subject: |
[PATCH 05/22] qapi/parser: Assert lexer value is a string |
Date: |
Wed, 21 Apr 2021 23:07:03 -0400 |
The type checker can't narrow the type of the token value to string,
because it's only loosely correlated with the return token.
We know that a token of '#' should always have a "str" value.
Add an assertion.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/parser.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index f519518075e..c75434e75a5 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -303,6 +303,7 @@ def get_doc(self, info):
cur_doc = QAPIDoc(self, info)
self.accept(False)
while self.tok == '#':
+ assert isinstance(self.val, str), "Expected str value"
if self.val.startswith('##'):
# End of doc comment
if self.val != '##':
--
2.30.2
- Re: [PATCH 01/22] qapi/parser: Don't try to handle file errors, (continued)
[PATCH 04/22] qapi/parser: factor parsing routine into method, John Snow, 2021/04/21
[PATCH 08/22] qapi/parser: Use @staticmethod where appropriate, John Snow, 2021/04/21
[PATCH 06/22] qapi/parser: assert get_expr returns object in outer loop, John Snow, 2021/04/21
[PATCH 09/22] qapi: add match_nofail helper, John Snow, 2021/04/21
[PATCH 05/22] qapi/parser: Assert lexer value is a string,
John Snow <=
[PATCH 07/22] qapi/parser: assert object keys are strings, John Snow, 2021/04/21
[PATCH 12/22] qapi/parser: add type hint annotations, John Snow, 2021/04/21