<commit_before>from django import forms
from django.core.exceptions import ValidationError


class ListOfDictField(forms.Field):

    def validate_to_python(self, value):
        """
        Validate and clean data.
        """
        super(ListOfDictField, self).validate(value)
        if value == None:
            return []
        if not isinstance(value, (list, tuple)):
            raise ValidationError('Must be a list or tuple')
        cleaned = []
        for index, dct in enumerate(value):
            if not isinstance(dct, dict):
                raise ValidationError('Item {0}: Must be a list of dicts, got {1}'.format(index, type(value)))
            form = self.Form(dct)<commit_msg>devilry_subjectadmin...ListOfDictField: Better error messages.<commit_after>from django import forms
from django.core.exceptions import ValidationError


class ListOfDictField(forms.Field):

    def validate_to_python(self, value):
        """
        Validate and clean data.
        """
        super(ListOfDictField, self).validate(value)
        if value == None:
            return []
        if not isinstance(value, (list, tuple)):
            raise ValidationError('Must be a list or tuple, got {0}'.format(type(value).__name__))
        cleaned = []
        for index, dct in enumerate(value):
            if not isinstance(dct, dict):
                raise ValidationError('Item {0}: Must be a list of dicts, got {1}'.format(index, type(value)))
            form = self.Form(dct)
{'fraction_non_alphanumeric': 0.10731052984574112, 'fraction_numerical': 0.00335345405767941, 'mean_word_length': 2.5023474178403755, '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': '6645667', 'n_tokens_mistral': 410, 'n_tokens_neox': 398, 'n_words': 122}