<commit_before>import json


class Message:
    def __init__(self, sender, receiver=None, message_type=None, content=None):
        self.message = {
            'sender': sender,
            'receiver': receiver,
            'type': message_type,
            'content': content
        }

    def __str__(self):
        return json.dumps(self.message)

    def __repr__(self):
        return "Message: %s" % self

    @classmethod
    def from_json(self, json_dict):
        # TODO: missing attributes parsing
        return Message(json_dict['sender'], json_dict.get('receiver'), json_dict.get('type'), json_dict.get('content'))

    @classmethod
    def from_string(self, json_str):
        return Message.from_json(json.loads(json_str))

    @property
    def sender(self):
        return self.message['sender']

    @property
    def receiver(self):
        return self.message['receiver']

    @property
    def type(self):
        return self.message['type']

    @property
    def content(self):
        return self.message['content']


class MessengerMeta(type):
    def __new__(cls, clsname, supercls, attr_dict):
        clsobj = super().__new__(cls, clsname, supercls, attr_dict)
        if 'basic_messages' not in attr_dict:
            raise AttributeError("basic_messages attribute must be defined")
        for name in attr_dict['basic_messages']:
            fullname, body = MessengerMeta.get_method(name)
            setattr(clsobj, fullname, body)
        return clsobj

    @staticmethod
    def get_method(name):
        def method(self, receiver=None, content=None):<commit_msg>Add setter to sender attribute of Message<commit_after>import json


class Message:
    def __init__(self, sender, receiver=None, message_type=None, content=None):
        self.message = {
            'sender': sender,
            'receiver': receiver,
            'type': message_type,
            'content': content
        }

    def __str__(self):
        return json.dumps(self.message)

    def __repr__(self):
        return "Message: %s" % self

    @classmethod
    def from_json(self, json_dict):
        # TODO: missing attributes parsing
        return Message(json_dict['sender'], json_dict.get('receiver'), json_dict.get('type'), json_dict.get('content'))

    @classmethod
    def from_string(self, json_str):
        return Message.from_json(json.loads(json_str))

    @property
    def sender(self):
        return self.message['sender']

    @sender.setter
    def sender(self, value):
        self.message['sender'] = value

    @property
    def receiver(self):
        return self.message['receiver']

    @property
    def type(self):
        return self.message['type']

    @property
    def content(self):
        return self.message['content']


class MessengerMeta(type):
    def __new__(cls, clsname, supercls, attr_dict):
        clsobj = super().__new__(cls, clsname, supercls, attr_dict)
        if 'basic_messages' not in attr_dict:
            raise AttributeError("basic_messages attribute must be defined")
        for name in attr_dict['basic_messages']:
            fullname, body = MessengerMeta.get_method(name)
            setattr(clsobj, fullname, body)
        return clsobj

    @staticmethod
    def get_method(name):
        def method(self, receiver=None, content=None):
{'fraction_non_alphanumeric': 0.1097708082026538, 'fraction_numerical': 0.0, 'mean_word_length': 2.7395715896279595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3995615', 'n_tokens_mistral': 963, 'n_tokens_neox': 943, 'n_words': 231}