[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/15] qapi/parser: Assert lexer value is a string
From: |
John Snow |
Subject: |
[PATCH v3 05/15] qapi/parser: Assert lexer value is a string |
Date: |
Wed, 19 May 2021 14:39:41 -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 d620706fffb..0bc852eda72 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -304,6 +304,7 @@ def get_doc(self, info):
cur_doc = QAPIDoc(self, info)
self.accept(False)
while self.tok == '#':
+ assert isinstance(self.val, str)
if self.val.startswith('##'):
# End of doc comment
if self.val != '##':
--
2.30.2
- [PATCH v3 00/15] qapi: static typing conversion, pt5a, John Snow, 2021/05/19
- [PATCH v3 05/15] qapi/parser: Assert lexer value is a string,
John Snow <=
- [PATCH v3 01/15] qapi/parser: Don't try to handle file errors, John Snow, 2021/05/19
- [PATCH v3 07/15] qapi/parser: assert object keys are strings, John Snow, 2021/05/19
- [PATCH v3 15/15] qapi/parser: add docstrings, John Snow, 2021/05/19
- [PATCH v3 02/15] qapi: Add test for nonexistent schema file, John Snow, 2021/05/19
- [PATCH v3 04/15] qapi/parser: factor parsing routine into method, John Snow, 2021/05/19
- [PATCH v3 03/15] qapi/source: Remove line number from QAPISourceInfo initializer, John Snow, 2021/05/19
- [PATCH v3 11/15] qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard, John Snow, 2021/05/19
- [PATCH v3 10/15] qapi/parser: Fix token membership tests when token can be None, John Snow, 2021/05/19
- [PATCH v3 14/15] qapi/parser: allow 'ch' variable name, John Snow, 2021/05/19