File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed
Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -600,9 +600,9 @@ def get_func_docstring(node):
600600 node (astroid.nodes.FunctionDef): The node to get a docstring
601601 for.
602602 """
603- doc = node .doc
603+ doc = node .doc_node . value if node . doc_node else ""
604604
605- if doc is None and isinstance (node .parent , astroid .nodes .ClassDef ):
605+ if not doc and isinstance (node .parent , astroid .nodes .ClassDef ):
606606 for base in node .parent .ancestors ():
607607 if node .name in ("__init__" , "__new__" ) and base .qname () in (
608608 "__builtins__.object" ,
@@ -614,11 +614,11 @@ def get_func_docstring(node):
614614 if (
615615 isinstance (child , node .__class__ )
616616 and child .name == node .name
617- and child .doc is not None
617+ and child .doc_node is not None
618618 ):
619- return child .doc
619+ return child .doc_node . value
620620
621- return doc or ""
621+ return doc
622622
623623
624624def get_class_docstring (node ):
@@ -627,17 +627,17 @@ def get_class_docstring(node):
627627 Args:
628628 node (astroid.nodes.ClassDef): The node to get a docstring for.
629629 """
630- doc = node .doc
630+ doc = node .doc_node . value if node . doc_node else ""
631631
632- if doc is None :
632+ if not doc :
633633 for base in node .ancestors ():
634634 if base .qname () in (
635635 "__builtins__.object" ,
636636 "builtins.object" ,
637637 "builtins.type" ,
638638 ):
639639 continue
640- if base .doc is not None :
641- return base .doc
640+ if base .doc_node is not None :
641+ return base .doc_node . value
642642
643- return doc or ""
643+ return doc
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ def parse_module(self, node):
237237 "type" : type_ ,
238238 "name" : node .name ,
239239 "full_name" : node .name ,
240- "doc" : _prepare_docstring (node .doc or "" ),
240+ "doc" : _prepare_docstring (node .doc_node . value if node . doc_node else "" ),
241241 "children" : [],
242242 "file_path" : path ,
243243 "encoding" : node .file_encoding ,
Original file line number Diff line number Diff line change 1+ Replace usage of deprecated astroid.NodeNG.doc
You can’t perform that action at this time.
0 commit comments