<commit_before>from wtforms import StringField, widgets
from wtforms.fields.core import UnboundField
from flask.ext.babel import lazy_gettext as _


# This should be something a bot would want to fill in
FIELD_NAME = "comment"


class HoneypotWidget(widgets.Input):
    def __call__(self, field, **kwargs):
        kwargs.setdefault("value", "")
        kwargs.setdefault("id", FIELD_NAME)

        return widgets.HTMLString(
            "<input {params} />".format(params=widgets.html_params(name=field.name, **kwargs))
        )


class HoneypotField(StringField):
    widget = HoneypotWidget()

    def pre_validate(self, form):
        if self.data:
            raise ValueError(self.gettext(u"This field must be left empty"))


class Honeypot(object):
    def __init__(self, *args, **kwargs):

        unbound = UnboundField(HoneypotField, _(u"Leave this field empty"))
        self._unbound_fields.append((FIELD_NAME, unbound))

        super(Honeypot, self).__init__(*args, **kwargs)<commit_msg>Changed formatting as per Black Playground<commit_after>from wtforms import StringField, widgets
from wtforms.fields.core import UnboundField
from flask.ext.babel import lazy_gettext as _


# This should be something a bot would want to fill in
FIELD_NAME = "comment"


class HoneypotWidget(widgets.Input):
    def __call__(self, field, **kwargs):
        kwargs.setdefault("value", "")
        kwargs.setdefault("id", FIELD_NAME)

        return widgets.HTMLString(
            "<input {params}>".format(
                params=widgets.html_params(name=field.name, **kwargs)
            )
        )


class HoneypotField(StringField):
    widget = HoneypotWidget()

    def pre_validate(self, form):
        if self.data:
            raise ValueError(self.gettext(u"This field must be left empty"))


class Honeypot(object):
    def __init__(self, *args, **kwargs):

        unbound = UnboundField(HoneypotField, _(u"Leave this field empty"))
        self._unbound_fields.append((FIELD_NAME, unbound))

        super(Honeypot, self).__init__(*args, **kwargs)
{'fraction_non_alphanumeric': 0.1101407083939835, 'fraction_numerical': 0.0, 'mean_word_length': 3.463203463203463, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1653811', 'n_tokens_mistral': 639, 'n_tokens_neox': 587, 'n_words': 154}