diff options
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r-- | sphinx/pycode/parser.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py index 4ec1a844d..1f803e950 100644 --- a/sphinx/pycode/parser.py +++ b/sphinx/pycode/parser.py @@ -311,10 +311,12 @@ class VariableCommentPicker(ast.NodeVisitor): return # this assignment is not new definition! # record annotation - annotation = getattr(node, 'annotation', None) - if annotation: + if hasattr(node, 'annotation') and node.annotation: # type: ignore for varname in varnames: - self.add_variable_annotation(varname, annotation) + self.add_variable_annotation(varname, node.annotation) # type: ignore + elif hasattr(node, 'type_comment') and node.type_comment: + for varname in varnames: + self.add_variable_annotation(varname, node.type_comment) # type: ignore # check comments after assignment parser = AfterCommentParser([current_line[node.col_offset:]] + |