John Snow <js...@redhat.com> writes: > 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 <js...@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..ba17f1357ad 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) # comment token MUST have str > val
What does the comment add to the assertion? Isn't it all obvious? Just wondering; if you genuinely think it isn't, I'm not going to argue. Except about the long line, which you could easily avoid: assert isinstance(self.val, str) # comment value MUST be str > if self.val.startswith('##'): > # End of doc comment > if self.val != '##':