def METHOD_NAME(line, cursor, namespace, *, private=True):
    """This method is invoked when the user asks auto-completion,
    e.g. when Ctrl+Space is clicked.
    :arg line: incomplete text line
    :type line: str
    :arg cursor: current character position
    :type cursor: int
    :arg namespace: namespace
    :type namespace: dict
    :arg private: whether private variables should be listed
    :type private: bool
    :returns:
        current expanded line, updated cursor position and scrollback
    :rtype: str, int, str
    >>> expand('os.path.isdir(', 14, {'os': os})[-1]
    'isdir(s)\\nReturn true if the pathname refers to an existing directory.'
    >>> expand('abs(', 4, {})[-1]
    'abs(number) -> number\\nReturn the absolute value of the argument.'
    """
    if line[:cursor].strip().endswith('('):
        from . import complete_calltip
        matches, word, scrollback = complete_calltip.complete(
            line, cursor, namespace)
        prefix = os.path.commonprefix(matches)[len(word):]
        no_calltip = False
    else:
        matches, word = complete(line, cursor, namespace, private)
        prefix = os.path.commonprefix(matches)[len(word):]
        if len(matches) == 1:
            scrollback = ''
        else:
            # causes blender bug #27495 since string keys may contain '.'
            # scrollback = '  '.join([m.split('.')[-1] for m in matches])
            # add white space to align with the cursor
            white_space = "    " + (" " * (cursor + len(prefix)))
            word_prefix = word + prefix
            scrollback = '\n'.join(
                [white_space + m[len(word_prefix):]
                 if (word_prefix and m.startswith(word_prefix))
                 else
                 white_space + m.rsplit('.', 1)[-1]
                 for m in matches])
        no_calltip = True
    if prefix:
        line = line[:cursor] + prefix + line[cursor:]
        cursor += len(prefix.encode('utf-8'))
        if no_calltip and prefix.endswith('('):
            return METHOD_NAME(line, cursor, namespace, private=private)
    return line, cursor, scrollback