def __new__(mcs, name, bases, attrs):
    """
        Validate state group definition
        """
    if bases != (object,):
        if 'states' in attrs and 'exclude_states' in attrs:
            raise Exception('Use either states or exclude_states but not both')
        elif 'states' not in attrs and 'exclude_states' not in attrs:
            raise Exception(
                'Please specify states or exclude_states to this state group')
        if 'exclude_states' in attrs and not isinstance(attrs[
            'exclude_states'], (list, set)):
            raise Exception(
                'Please give a list (or set) of states to this state group')
        elif 'states' in attrs and not isinstance(attrs['states'], (list, set)
            ):
            raise Exception(
                'Please give a list (or set) of states to this state group')
    return type.__new__(mcs, name, bases, attrs)
