<commit_before>__author__ = 'asuiu'

from typing import Type


class ValidateError(ValueError):
    def __init__(self, args):
        ValueError.__init__(self, args)


def validate(expr, msg="Invalid argument", exc: Type[Exception] = ValidateError):
    """
    If the expression val does not evaluate to True, then raise a ValidationError with msg
    """
    if not expr:
        raise exc(msg)

class PydanticValidated:
    @classmethod
    def __get_validators__(cls):
        yield cls._pydantic_validator

    @classmethod
    def _pydantic_validator(cls, v):
        if not isinstance(v, cls):
            raise TypeError(f'{repr(v)} is of type {type(v)} but is expected to be of {cls}')
        return v<commit_msg>Fix incompatibility with Py3.6<commit_after>__author__ = 'asuiu'

from typing import Type


class ValidateError(ValueError):
    def __init__(self, args):
        ValueError.__init__(self, args)


def validate(expr, msg="Invalid argument", exc: 'Type[Exception]' = ValidateError):
    """
    If the expression val does not evaluate to True, then raise a ValidationError with msg
    """
    if not expr:
        raise exc(msg)

class PydanticValidated:
    @classmethod
    def __get_validators__(cls):
        yield cls._pydantic_validator

    @classmethod
    def _pydantic_validator(cls, v):
        if not isinstance(v, cls):
            raise TypeError(f'{repr(v)} is of type {type(v)} but is expected to be of {cls}')
        return v
{'fraction_non_alphanumeric': 0.09488054607508532, 'fraction_numerical': 0.0013651877133105802, 'mean_word_length': 3.2492753623188406, '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': '3596293', 'n_tokens_mistral': 443, 'n_tokens_neox': 447, 'n_words': 142}