pylint/checkers/variables.py
def leave_functiondef(self, node):
        """leave function: check function's locals are consumed"""
        if node.type_comment_returns:
            self._store_type_annotation_node(node.type_comment_returns)
        if node.type_comment_args:
            for argument_annotation in node.type_comment_args:
                self._store_type_annotation_node(argument_annotation)

        not_consumed = self._to_consume.pop().to_consume
        if not (
            self.linter.is_message_enabled("unused-variable")
            or self.linter.is_message_enabled("possibly-unused-variable")
            or self.linter.is_message_enabled("unused-argument")
        ):
            return

        # Don't check arguments of function which are only raising an exception.
        if utils.is_error(node):
            return

        # Don't check arguments of abstract methods or within an interface.
        is_method = node.is_method()
        if is_method and node.is_abstract():
            return

        global_names = _flattened_scope_names(node.nodes_of_class(astroid.Global))
        nonlocal_names = _flattened_scope_names(node.nodes_of_class(astroid.Nonlocal))
        for name, stmts in not_consumed.items():
            self._check_is_unused(name, node, stmts[0], global_names, nonlocal_names)
def leave_functiondef(self, node):
        """leave function: check function's locals are consumed"""
        if node.type_comment_returns:
            self._store_type_annotation_node(node.type_comment_returns)
        if node.type_comment_args:
            for argument_annotation in node.type_comment_args:
                self._store_type_annotation_node(argument_annotation)

        not_consumed = self._to_consume.pop().to_consume
        if not (
            self.linter.is_message_enabled("unused-variable")
            or self.linter.is_message_enabled("possibly-unused-variable")
            or self.linter.is_message_enabled("unused-argument")
        ):
            return

        # Don't check arguments of function which are only raising an exception.
        if utils.is_error(node):
            return

        # Don't check arguments of abstract methods or within an interface.
        is_method = node.is_method()
        if is_method and node.is_abstract():
            return

        global_names = _flattened_scope_names(node.nodes_of_class(astroid.Global))
        nonlocal_names = _flattened_scope_names(node.nodes_of_class(astroid.Nonlocal))
        for name, stmts in not_consumed.items():
            self._check_is_unused(name, node, stmts[0], global_names, nonlocal_names)
leave function: check function's locals are consumed