<commit_before>from __future__ import absolute_import, print_function, unicode_literals

import math
from .interpreter import ExpressionError
from .shared import string, fromNow

builtins = {}


def builtin(name, variadic=None, argument_tests=None, minArgs=None):
    def wrap(fn):
        def bad():
            raise ExpressionError('invalid arguments to {}'.format(name))
        if variadic:
            def invoke(args):
                if minArgs:
                    if len(args) < minArgs:
                        bad()
                for arg in args:
                    if not variadic(arg):
                        bad()
                return fn(*args)

        elif argument_tests:<commit_msg>better error message when passing too few args to a builtin<commit_after>from __future__ import absolute_import, print_function, unicode_literals

import math
from .interpreter import ExpressionError
from .shared import string, fromNow

builtins = {}


def builtin(name, variadic=None, argument_tests=None, minArgs=None):
    def wrap(fn):
        def bad(reason=None):
            raise ExpressionError((reason or 'invalid arguments to {}').format(name))
        if variadic:
            def invoke(args):
                if minArgs:
                    if len(args) < minArgs:
                        bad("too few arguments to {}")
                for arg in args:
                    if not variadic(arg):
                        bad()
                return fn(*args)

        elif argument_tests:
{'fraction_non_alphanumeric': 0.07891246684350132, 'fraction_numerical': 0.0, 'mean_word_length': 1.8963531669865643, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1021555', 'n_tokens_mistral': 394, 'n_tokens_neox': 368, 'n_words': 122}