Пример #1
0
    def _iterate_returning_values(
        self,
        node: AnyFunctionDef,
        returning_type,  # mypy is not ok with this type declaration
        violation: _ReturningViolations,
    ):
        return_nodes, has_values = keywords.returning_nodes(
            node, returning_type,
        )

        for return_node in return_nodes:
            if not return_node.value and has_values:
                self.add_violation(violation(return_node))
Пример #2
0
    def _iterate_returning_values(
        self,
        node: AnyFunctionDef,
        returning_type: Union[Type[ast.Return], Type[ast.Yield]],
        violation: _ReturningViolations,
    ):
        return_nodes, has_values = keywords.returning_nodes(
            node,
            returning_type,
        )
        is_all_none = (has_values and all(
            (isinstance(ret_node.value, ast.NameConstant)
             and ret_node.value.value is None) for ret_node in return_nodes))
        if is_all_none:
            self.add_violation(violation(node))

        for return_node in return_nodes:
            if not return_node.value and has_values:
                self.add_violation(violation(return_node))