Преглед изворни кода

qapi/parser: Assert lexer value is a string

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>
Message-Id: <20210519183951.3946870-6-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
John Snow пре 4 година
родитељ
комит
7c610ce6a9
1 измењених фајлова са 1 додато и 0 уклоњено
  1. 1 0
      scripts/qapi/parser.py

+ 1 - 0
scripts/qapi/parser.py

@@ -304,6 +304,7 @@ def get_doc(self, info):
         cur_doc = QAPIDoc(self, info)
         cur_doc = QAPIDoc(self, info)
         self.accept(False)
         self.accept(False)
         while self.tok == '#':
         while self.tok == '#':
+            assert isinstance(self.val, str)
             if self.val.startswith('##'):
             if self.val.startswith('##'):
                 # End of doc comment
                 # End of doc comment
                 if self.val != '##':
                 if self.val != '##':