diff options
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r-- | sphinx/pycode/parser.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py index deba48b1c..5c4291d3d 100644 --- a/sphinx/pycode/parser.py +++ b/sphinx/pycode/parser.py @@ -224,12 +224,13 @@ class AfterCommentParser(TokenProcessor): def parse(self): # type: () -> None """Parse the code and obtain comment after assignment.""" - # skip lvalue (until '=' operator) - while self.fetch_token() != [OP, '=']: + # skip lvalue (or whole of AnnAssign) + while not self.fetch_token().match([OP, '='], NEWLINE, COMMENT): assert self.current - # skip rvalue - self.fetch_rvalue() + # skip rvalue (if exists) + if self.current == [OP, '=']: + self.fetch_rvalue() if self.current == COMMENT: self.comment = self.current.value |