mirror of
https://github.com/django/django.git
synced 2025-07-22 04:35:17 +00:00
Fixed E128 flake8 warnings in django/.
This commit is contained in:
parent
2956e2f5e3
commit
df8d8d4292
136 changed files with 1641 additions and 1212 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue