'Handle left and right parenthesis depending on editor config.'

def handle_parentheses(self, text):

    position = self.get_position('cursor')
    rest = self.get_text('cursor', 'eol').rstrip()
    valid = ((not rest) or (rest[0] in (',', ')', ']', '}')))
    if (self.close_parentheses_enabled and valid):
        self.insert_text('()')
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.PreviousCharacter)
        self.setTextCursor(cursor)
    else:
        self.insert_text(text)
    if (self.is_python_like() and self.get_text('sol', 'cursor') and self.calltips):
        self.sig_show_object_info.emit(position)
