Пример #1
0
    def __extract_docstring(self, node: cst.FunctionDef) -> str:
        """
        Extracts & post-processes the docstring from the provided function node.
        If a docstring is not present, an empty string is returned.

        :node: Function node
        :return: Docstring as string
        """
        # Get docstring from Function node
        docstring = node.get_docstring()

        # Return empty string if docstring undefined
        return docstring if docstring is not None else ""
Пример #2
0
 def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]:
     self.stack.append(node.name.value)
     docstring = node.get_docstring(clean=False)
     self.annotations[tuple(self.stack)] = (node.params, node.returns, None,
                                            docstring)
     return False  # pyi files don't support inner functions, return False to stop the traversal.