diff options
| author | Tim Graham <timograham@gmail.com> | 2016-03-28 18:33:29 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-08 09:51:06 -0400 |
| commit | df8d8d4292684d6ffa7474f1e201aed486f02b53 (patch) | |
| tree | c661bf9b33de5288afe4f63347a2a9c768ef98eb /django/forms | |
| parent | 2956e2f5e3f63d279f5dae2a995265364d3e6db1 (diff) | |
Fixed E128 flake8 warnings in django/.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/fields.py | 13 | ||||
| -rw-r--r-- | django/forms/forms.py | 3 | ||||
| -rw-r--r-- | django/forms/models.py | 18 | ||||
| -rw-r--r-- | django/forms/widgets.py | 63 |
4 files changed, 51 insertions, 46 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 3ad362b9b8..c6704883a3 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -775,8 +775,10 @@ class ChoiceField(Field): def __init__(self, choices=(), required=True, widget=None, label=None, initial=None, help_text='', *args, **kwargs): - super(ChoiceField, self).__init__(required=required, widget=widget, label=label, - initial=initial, help_text=help_text, *args, **kwargs) + super(ChoiceField, self).__init__( + required=required, widget=widget, label=label, initial=initial, + help_text=help_text, *args, **kwargs + ) self.choices = choices def __deepcopy__(self, memo): @@ -1090,9 +1092,10 @@ class FilePathField(ChoiceField): initial=None, help_text='', *args, **kwargs): self.path, self.match, self.recursive = path, match, recursive self.allow_files, self.allow_folders = allow_files, allow_folders - super(FilePathField, self).__init__(choices=(), required=required, - widget=widget, label=label, initial=initial, help_text=help_text, - *args, **kwargs) + super(FilePathField, self).__init__( + choices=(), required=required, widget=widget, label=label, + initial=initial, help_text=help_text, *args, **kwargs + ) if self.required: self.choices = [] diff --git a/django/forms/forms.py b/django/forms/forms.py index 0a15ec510f..df382deda9 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -38,8 +38,7 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass): current_fields.sort(key=lambda x: x[1].creation_counter) attrs['declared_fields'] = OrderedDict(current_fields) - new_class = (super(DeclarativeFieldsMetaclass, mcs) - .__new__(mcs, name, bases, attrs)) + new_class = super(DeclarativeFieldsMetaclass, mcs).__new__(mcs, name, bases, attrs) # Walk through the MRO. declared_fields = OrderedDict() diff --git a/django/forms/models.py b/django/forms/models.py index b06709ea23..849f7a111a 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -738,14 +738,15 @@ class BaseModelFormSet(BaseFormSet): "field": unique_check[0], } else: - return ugettext("Please correct the duplicate data for %(field)s, " - "which must be unique.") % { + return ugettext("Please correct the duplicate data for %(field)s, which must be unique.") % { "field": get_text_list(unique_check, six.text_type(_("and"))), } def get_date_error_message(self, date_check): - return ugettext("Please correct the duplicate data for %(field_name)s " - "which must be unique for the %(lookup)s in %(date_field)s.") % { + return ugettext( + "Please correct the duplicate data for %(field_name)s " + "which must be unique for the %(lookup)s in %(date_field)s." + ) % { 'field_name': date_check[2], 'date_field': date_check[3], 'lookup': six.text_type(date_check[1]), @@ -1126,8 +1127,7 @@ class ModelChoiceIterator(object): yield self.choice(obj) def __len__(self): - return (len(self.queryset) + - (1 if self.field.empty_label is not None else 0)) + return (len(self.queryset) + (1 if self.field.empty_label is not None else 0)) def choice(self, obj): return (self.field.prepare_value(obj), self.field.label_from_instance(obj)) @@ -1252,8 +1252,10 @@ class ModelMultipleChoiceField(ModelChoiceField): def __init__(self, queryset, required=True, widget=None, label=None, initial=None, help_text='', *args, **kwargs): - super(ModelMultipleChoiceField, self).__init__(queryset, None, - required, widget, label, initial, help_text, *args, **kwargs) + super(ModelMultipleChoiceField, self).__init__( + queryset, None, required, widget, label, initial, help_text, + *args, **kwargs + ) def to_python(self, value): if not value: diff --git a/django/forms/widgets.py b/django/forms/widgets.py index f48f84dfa8..4ec2cce075 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -147,8 +147,7 @@ class MediaDefiningClass(type): Metaclass for classes that can have media definitions. """ def __new__(mcs, name, bases, attrs): - new_class = (super(MediaDefiningClass, mcs) - .__new__(mcs, name, bases, attrs)) + new_class = super(MediaDefiningClass, mcs).__new__(mcs, name, bases, attrs) if 'media' not in attrs: new_class.media = media_property(new_class) @@ -433,9 +432,7 @@ class Textarea(Widget): if value is None: value = '' final_attrs = self.build_attrs(attrs, name=name) - return format_html('<textarea{}>\r\n{}</textarea>', - flatatt(final_attrs), - force_text(value)) + return format_html('<textarea{}>\r\n{}</textarea>', flatatt(final_attrs), force_text(value)) class DateTimeBaseInput(TextInput): @@ -447,8 +444,7 @@ class DateTimeBaseInput(TextInput): self.format = format if format else None def _format_value(self, value): - return formats.localize_input(value, - self.format or formats.get_format(self.format_key)[0]) + return formats.localize_input(value, self.format or formats.get_format(self.format_key)[0]) class DateInput(DateTimeBaseInput): @@ -536,10 +532,7 @@ class Select(Widget): selected_choices.remove(option_value) else: selected_html = '' - return format_html('<option value="{}"{}>{}</option>', - option_value, - selected_html, - force_text(option_label)) + return format_html('<option value="{}"{}>{}</option>', option_value, selected_html, force_text(option_label)) def render_options(self, selected_choices): # Normalize to strings. @@ -561,9 +554,11 @@ class NullBooleanSelect(Select): A Select Widget intended to be used with NullBooleanField. """ def __init__(self, attrs=None): - choices = (('1', ugettext_lazy('Unknown')), - ('2', ugettext_lazy('Yes')), - ('3', ugettext_lazy('No'))) + choices = ( + ('1', ugettext_lazy('Unknown')), + ('2', ugettext_lazy('Yes')), + ('3', ugettext_lazy('No')), + ) super(NullBooleanSelect, self).__init__(attrs, choices) def render(self, name, value, attrs=None): @@ -575,12 +570,14 @@ class NullBooleanSelect(Select): def value_from_datadict(self, data, files, name): value = data.get(name) - return {'2': True, - True: True, - 'True': True, - '3': False, - 'False': False, - False: False}.get(value) + return { + '2': True, + True: True, + 'True': True, + '3': False, + 'False': False, + False: False, + }.get(value) class SelectMultiple(Select): @@ -714,16 +711,18 @@ class ChoiceFieldRenderer(object): choices=choice_label, ) sub_ul_renderer.choice_input_class = self.choice_input_class - output.append(format_html(self.inner_html, choice_value=choice_value, - sub_widgets=sub_ul_renderer.render())) + output.append(format_html( + self.inner_html, choice_value=choice_value, + sub_widgets=sub_ul_renderer.render(), + )) else: - w = self.choice_input_class(self.name, self.value, - self.attrs.copy(), choice, i) - output.append(format_html(self.inner_html, - choice_value=force_text(w), sub_widgets='')) - return format_html(self.outer_html, - id_attr=format_html(' id="{}"', id_) if id_ else '', - content=mark_safe('\n'.join(output))) + w = self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, i) + output.append(format_html(self.inner_html, choice_value=force_text(w), sub_widgets='')) + return format_html( + self.outer_html, + id_attr=format_html(' id="{}"', id_) if id_ else '', + content=mark_safe('\n'.join(output)), + ) class RadioFieldRenderer(ChoiceFieldRenderer): @@ -889,8 +888,10 @@ class SplitDateTimeWidget(MultiWidget): supports_microseconds = False def __init__(self, attrs=None, date_format=None, time_format=None): - widgets = (DateInput(attrs=attrs, format=date_format), - TimeInput(attrs=attrs, format=time_format)) + widgets = ( + DateInput(attrs=attrs, format=date_format), + TimeInput(attrs=attrs, format=time_format), + ) super(SplitDateTimeWidget, self).__init__(widgets, attrs) def decompress(self, value): |
