Better implementation of checking function I have a checking function that checks the correct type for a class Check_Annotation, I was wondering if there is a better way to implement this, my current code right now is:

def _check_list_or_tuple (self, param, annot, value, check_history): 
    assert isinstance(value, type(annot)), "AssertionError: 'x' failed annotation check(wrong type): value = {}, was type {} ...should be type {}".format(value, type_as_str(value), type_as_str(annot))
    if len(annot) == 1 and type(annot[0]) != list and type(annot[0])!= tuple and inspect.isfunction(annot[0]) == False:
        for x in value : 
            check_history = ''
            check_history += str(annot[0])
            assert type(x) == annot[0], "AssertionError: 'x' failed annotation check(wrong type): value = {}, was type {} ...should be type {} \nlist[{}] check: {}".format(x, type_as_str(x), annot[0], annot.index(annot[0])+1, check_history)
    elif type(annot[0]) == list or type(annot[0]) == tuple or inspect.isfunction(annot[0]) == True:
        for i in range(len(value)):
            self.check(param, annot[0], value[i])
    elif len(annot) &gt; 1:
        check_history = ''
        check_history += str(annot[0])
        assert type (value[0]) == annot[0], "AssertionError: 'x' failed annotation check(wrong type): value = {}, was type {} ...should be type {} \nlist[{}] check: {}".format(value[0], type_as_str(value[0]), annot[0], annot.index(annot[0])+1, check_history)
        check_history = ''
        check_history += str(annot)
        assert len(annot) == len(value), "AssertionError: 'x' failed annotation check(wrong number of elements): value = {} \nannotation had {} elements[{}]".format(value, len(annot), check_history)
        for x in value[1:]:
            check_history = ''
            check_history += str(annot[1])                 
            assert type(x) == annot[1], "AssertionError: 'x' failed annotation check(wrong type): value = {}, was type {} ...should be type {} \nlist[{}] check: {}".format(x, type_as_str(x), annot[1], annot.index(annot[1])+1, check_history)


To me it is a bit rough on implementation and repetitive code. Does anyone have an idea of a shorter way to go about doing this?
I don't have time to check all of this, but here are some ideas ...
 - place long strings in parenthesis and break them up into multiple lines
 - if those strings are used more than once, use variables for them
 - break out the for loops as a separate function

type_error_msg = ("AssertionError: 'x' failed annotation check(wrong type):"
                  " value = {}, was type {} ...should be type {}")
list_error_msg = ("AssertionError: 'x' failed annotation check(wrong type):"
        " value = {}, was type {} ...should be type {} \nlist[{}] check: {}")
elem_number_error_msg = ("AssertionError: 'x' failed annotation check(wrong "
         "number of elements): value = {} \nannotation had {} elements[{}]")

def _check_values(value, annot, index):
    for x in value:
        check_history = ''
        check_history += str(annot1)
        assert type(x) == annot, self.list_error_msg.format(x, 
             type_as_str(x), annot, index,  check_history)

def _check_list_or_tuple (self, param, annot, value, check_history): 
    assert isinstance(value, type(annot)), self.type_error_msg.format(value, 
                                     type_as_str(value), type_as_str(annot))
    if (len(annot) == 1 and type(annot[0]) != list and 
        type(annot[0])!= tuple and inspect.isfunction(annot[0]) == False):
        self._check_values(value, annot[0], 1)
    elif (type(annot[0]) == list or type(annot[0]) == tuple or 
          inspect.isfunction(annot[0]) == True):
        for i in range(len(value)):
            self.check(param, annot[0], value[i])
    elif len(annot) &gt; 1:
        check_history = ''
        check_history += str(annot[0])
        assert type (value[0]) == annot[0], self.list_error_msg.format(
            value[0], type_as_str(value[0]), annot[0], 
            annot.index(annot[0])+1, check_history)
        check_history = ''
        check_history += str(annot)
        assert len(annot) == len(value), self.elem_number_error_msg.format(
                                        value, len(annot), check_history)
        self._check_values(value[1:], annot[1], 2)