def check_list_type(objects, allowed_type, name, allow_none=True):
if objects is None:<EOL><INDENT>if not allow_none:<EOL><INDENT>raise TypeError('<STR_LIT>' % name)<EOL><DEDENT>return objects<EOL><DEDENT>if not isinstance(objects, (tuple, list)):<EOL><INDENT>raise TypeError('<STR_LIT>' % name)<EOL><DEDENT>if not all(isinstance(i, allowed_type) for i in objects):<EOL><INDENT>type_list = sorted(list(set(type(obj) for obj in objects)))<EOL>raise TypeError('<STR_LIT>' %<EOL>(name, allowed_type.__name__, type_list))<EOL><DEDENT>return objects<EOL>
Verify that objects in list are of the allowed type or raise TypeError.

    Args:
      objects: The list of objects to check.
      allowed_type: The allowed type of items in 'settings'.
      name: Name of the list of objects, added to the exception.
      allow_none: If set, None is also allowed.

    Raises:
      TypeError: if object is not of the allowed type.

    Returns:
      The list of objects, for convenient use in assignment.