def __new__(mcs, name, bases, body):
        """
        Validate the switch_to_action_map when the class is created, instead of doing it every time the class
        is instantiated. This identifies problems earlier (on import) and improves performance by not performing this
        validation every time the action is called.
        """
        cls = super(_SwitchedActionMetaClass, mcs).__new__(mcs, name, bases, body)

        # noinspection PyUnresolvedReferences
        if bases[0] is not object and (
            not cls.switch_to_action_map or
            not hasattr(cls.switch_to_action_map, '__iter__') or
            _len(cls.switch_to_action_map) < 2 or
            any(
                True for i in cls.switch_to_action_map
                if not hasattr(i, '__getitem__') or _len(i) != 2 or not is_switch(i[0]) or not callable(i[1])
            )
        ):
            raise ValueError(
                'Class attribute switch_to_action_map must be an iterable of at least two indexable items, each '
                'with exactly two indexes, where the first element is a switch and the second element is an action '
                '(callable).'
            )

        return cls
def __new__ ( mcs , name , bases , body ) : cls = super ( _SwitchedActionMetaClass , mcs ) . __new__ ( mcs , name , bases , body ) if bases [ 0 ] is not object and ( not cls . switch_to_action_map or not hasattr ( cls . switch_to_action_map , '__iter__' ) or _len ( cls . switch_to_action_map ) < 2 or any ( True for i in cls . switch_to_action_map if not hasattr ( i , '__getitem__' ) or _len ( i ) != 2 or not is_switch ( i [ 0 ] ) or not callable ( i [ 1 ] ) ) ) : raise ValueError ( 'Class attribute switch_to_action_map must be an iterable of at least two indexable items, each ' 'with exactly two indexes, where the first element is a switch and the second element is an action ' '(callable).' ) return cls
Validate the switch_to_action_map when the class is created, instead of doing it every time the class
        is instantiated. This identifies problems earlier (on import) and improves performance by not performing this
        validation every time the action is called.