<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def type(self, value):
 """ Sets the type of the message. :type value: Types :param value: the type :raise AttributeError: if value is not a valid type """

        if value not in list(defines.Types.values()):
            raise AttributeError
        self._type = value