diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-21 00:24:15 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-21 00:25:11 +0900 |
commit | be8e2be47b405723e39ff46e473829bcc8d17cb9 (patch) | |
tree | 00e122bd69e09a5809e3ecc494ebe431f2e6b1da /sphinx/pycode/parser.py | |
parent | 679002c483958a041772bd2a1f1014bb9dada9a8 (diff) | |
download | sphinx-git-be8e2be47b405723e39ff46e473829bcc8d17cb9.tar.gz |
Fix #4914: autodoc: Parsing error when using dataclasses without default values
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 |