def add_class_attrs(self, widget=None):
    if (widget is None):
        widget = self.widget
    classes = widget.attrs.get('class', '')
    if ((ReadOnlyPasswordHashWidget is not None) and isinstance(widget, ReadOnlyPasswordHashWidget)):
        classes = add_css_class(classes, 'form-control-static', prepend=True)
    elif (not isinstance(widget, self.WIDGETS_NO_FORM_CONTROL)):
        classes = add_css_class(classes, 'form-control', prepend=True)
        classes = add_css_class(classes, self.get_size_class())
    elif isinstance(widget, CheckboxInput):
        classes = add_css_class(classes, 'form-check-input', prepend=True)
    elif isinstance(widget, FileInput):
        classes = add_css_class(classes, 'form-control-file', prepend=True)
    if self.field.errors:
        if self.error_css_class:
            classes = add_css_class(classes, self.error_css_class)
    elif self.field.form.is_bound:
        classes = add_css_class(classes, self.success_css_class)
    widget.attrs['class'] = classes
def add_class_attrs(self, widget=None):
    if (widget is None):
        widget = self.widget
    classes = widget.attrs.get('class', )
    if ((ReadOnlyPasswordHashWidget is not None) and isinstance(widget, ReadOnlyPasswordHashWidget)):
        classes = add_css_class(classes, 'form-control-static', prepend=True)
    elif (not isinstance(widget, self.WIDGETS_NO_FORM_CONTROL)):
        classes = add_css_class(classes, 'form-control', prepend=True)
        classes = add_css_class(classes, self.get_size_class())
    elif isinstance(widget, CheckboxInput):
        classes = add_css_class(classes, 'form-check-input', prepend=True)
    elif isinstance(widget, FileInput):
        classes = add_css_class(classes, 'form-control-file', prepend=True)
    if self.field.errors:
        if self.error_css_class:
            classes = add_css_class(classes, self.error_css_class)
    elif self.field.form.is_bound:
        classes = add_css_class(classes, self.success_css_class)
    widget.attrs['class'] = classes