Example #1
0
    def visit_return(self, node):
        if not utils.returns_something(node):
            return

        func_node = node.frame()
        if not isinstance(func_node, astroid.FunctionDef):
            return

        doc = utils.docstringify(
            func_node.doc, self.config.default_docstring_type,
        )
        if not doc.is_valid() and self.config.accept_no_return_doc:
            return

        is_property = checker_utils.decorated_with_property(func_node)

        if not (doc.has_returns() or
                (doc.has_property_returns() and is_property)):
            self.add_message(
                'missing-return-doc',
                node=func_node
            )

        if func_node.returns:
            return

        if not (doc.has_rtype() or
                (doc.has_property_type() and is_property)):
            self.add_message(
                'missing-return-type-doc',
                node=func_node
            )
Example #2
0
    def visit_return(self, node):
        if not utils.returns_something(node):
            return

        func_node = node.frame()
        if not isinstance(
                func_node,
                astroid.FunctionDef) or self._skip_func_docstring(func_node):
            return

        doc = utils.docstringify(func_node.doc,
                                 self.config.default_docstring_type)
        if not doc.is_valid() and self.config.accept_no_return_doc:
            return

        is_property = checker_utils.decorated_with_property(func_node)

        if not (doc.has_returns() or
                (doc.has_property_returns() and is_property)):
            self.add_message("missing-return-doc", node=func_node)

        if func_node.returns:
            return

        if not (doc.has_rtype() or (doc.has_property_type() and is_property)):
            self.add_message("missing-return-type-doc", node=func_node)
Example #3
0
 def check_functiondef_returns(self, node, node_doc):
     return_nodes = node.nodes_of_class(astroid.Return)
     if (node_doc.has_returns() and
             not any(utils.returns_something(ret_node) for ret_node in return_nodes)):
         self.add_message(
             'redundant-returns-doc',
             node=node)
Example #4
0
    def check_functiondef_returns(self, node, node_doc):
        if not node_doc.supports_yields and node.is_generator():
            return

        return_nodes = node.nodes_of_class(astroid.Return)
        if ((node_doc.has_returns() or node_doc.has_rtype()) and not any(
                utils.returns_something(ret_node)
                for ret_node in return_nodes)):
            self.add_message('redundant-returns-doc', node=node)
Example #5
0
    def check_functiondef_returns(self, node, node_doc):
        if (not node_doc.supports_yields and node.is_generator()) or node.is_abstract():
            return

        return_nodes = node.nodes_of_class(astroid.Return)
        if (node_doc.has_returns() or node_doc.has_rtype()) and not any(
            utils.returns_something(ret_node) for ret_node in return_nodes
        ):
            self.add_message("redundant-returns-doc", node=node)
Example #6
0
    def check_functiondef_returns(self, node: nodes.FunctionDef,
                                  node_doc: Docstring) -> None:
        if (not node_doc.supports_yields
                and node.is_generator()) or node.is_abstract():
            return

        return_nodes = node.nodes_of_class(astroid.Return)
        if (node_doc.has_returns() or node_doc.has_rtype()) and not any(
                utils.returns_something(ret_node)
                for ret_node in return_nodes):
            self.add_message("redundant-returns-doc", node=node)
Example #7
0
    def visit_return(self, node):
        if not utils.returns_something(node):
            return

        func_node = node.frame()
        if not isinstance(func_node, astroid.FunctionDef):
            return

        doc = utils.docstringify(func_node.doc)
        if not doc.is_valid() and self.config.accept_no_return_doc:
            return

        if not doc.has_returns():
            self.add_message('missing-returns-doc', node=func_node)
Example #8
0
    def visit_return(self, node):
        if not utils.returns_something(node):
            return

        func_node = node.frame()
        if not isinstance(func_node, astroid.FunctionDef):
            return

        doc = utils.docstringify(func_node.doc)
        if not doc.is_valid() and self.config.accept_no_return_doc:
            return

        if not doc.has_returns():
            self.add_message(
                'missing-returns-doc',
                node=func_node
            )