Permalink
Browse files

Fixed flake8 E251 violations

  • Loading branch information...
1 parent fe995e6 commit cbc7cbbc5b5ef03059d8876074560635f2f647b7 @milmazz milmazz committed Nov 3, 2013
@@ -96,8 +96,8 @@ def result_headers(cl):
ordering_field_columns = cl.get_ordering_field_columns()
for i, field_name in enumerate(cl.list_display):
text, attr = label_for_field(field_name, cl.model,
- model_admin = cl.model_admin,
- return_attr = True
+ model_admin=cl.model_admin,
+ return_attr=True
)
if attr:
# Potentially not sortable
@@ -21,9 +21,9 @@ def description(self):
def items(self):
qs = comments.get_model().objects.filter(
- site__pk = self.site.pk,
- is_public = True,
- is_removed = False,
+ site__pk=self.site.pk,
+ is_public=True,
+ is_removed=False,
)
return qs.order_by('-submit_date')[:40]
@@ -132,16 +132,16 @@ def get_comment_create_data(self):
method to add extra fields onto a custom comment model.
"""
return dict(
- content_type = ContentType.objects.get_for_model(self.target_object),
- object_pk = force_text(self.target_object._get_pk_val()),
- user_name = self.cleaned_data["name"],
- user_email = self.cleaned_data["email"],
- user_url = self.cleaned_data["url"],
- comment = self.cleaned_data["comment"],
- submit_date = timezone.now(),
- site_id = settings.SITE_ID,
- is_public = True,
- is_removed = False,
+ content_type=ContentType.objects.get_for_model(self.target_object),
+ object_pk=force_text(self.target_object._get_pk_val()),
+ user_name=self.cleaned_data["name"],
+ user_email=self.cleaned_data["email"],
+ user_url=self.cleaned_data["url"],
+ comment=self.cleaned_data["comment"],
+ submit_date=timezone.now(),
+ site_id=settings.SITE_ID,
+ is_public=True,
+ is_removed=False,
)
def check_for_duplicate_comment(self, new):
@@ -152,11 +152,11 @@ def check_for_duplicate_comment(self, new):
possible_duplicates = self.get_comment_model()._default_manager.using(
self.target_object._state.db
).filter(
- content_type = new.content_type,
- object_pk = new.object_pk,
- user_name = new.user_name,
- user_email = new.user_email,
- user_url = new.user_url,
+ content_type=new.content_type,
+ object_pk=new.object_pk,
+ user_name=new.user_name,
+ user_email=new.user_email,
+ user_url=new.user_url,
)
for old in possible_duplicates:
if old.submit_date.date() == new.submit_date.date() and old.comment == new.comment:
@@ -35,18 +35,18 @@ def handle_token(cls, parser, token):
if tokens[3] != 'as':
raise template.TemplateSyntaxError("Third argument in %r must be 'as'" % tokens[0])
return cls(
- object_expr = parser.compile_filter(tokens[2]),
- as_varname = tokens[4],
+ object_expr=parser.compile_filter(tokens[2]),
+ as_varname=tokens[4],
)
# {% get_whatever for app.model pk as varname %}
elif len(tokens) == 6:
if tokens[4] != 'as':
raise template.TemplateSyntaxError("Fourth argument in %r must be 'as'" % tokens[0])
return cls(
- ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
- object_pk_expr = parser.compile_filter(tokens[3]),
- as_varname = tokens[5]
+ ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
+ object_pk_expr=parser.compile_filter(tokens[3]),
+ as_varname=tokens[5]
)
else:
@@ -83,9 +83,9 @@ def get_queryset(self, context):
return self.comment_model.objects.none()
qs = self.comment_model.objects.filter(
- content_type = ctype,
- object_pk = smart_text(object_pk),
- site__pk = settings.SITE_ID,
+ content_type=ctype,
+ object_pk=smart_text(object_pk),
+ site__pk=settings.SITE_ID,
)
# The is_public and is_removed fields are implementation details of the
@@ -166,8 +166,8 @@ def handle_token(cls, parser, token):
# {% render_comment_form for app.models pk %}
elif len(tokens) == 4:
return cls(
- ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
- object_pk_expr = parser.compile_filter(tokens[3])
+ ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
+ object_pk_expr=parser.compile_filter(tokens[3])
)
def render(self, context):
@@ -202,8 +202,8 @@ def handle_token(cls, parser, token):
# {% render_comment_list for app.models pk %}
elif len(tokens) == 4:
return cls(
- ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
- object_pk_expr = parser.compile_filter(tokens[3])
+ ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
+ object_pk_expr=parser.compile_filter(tokens[3])
)
def render(self, context):
@@ -99,65 +99,65 @@ def perform_flag(request, comment):
Actually perform the flagging of a comment from a request.
"""
flag, created = comments.models.CommentFlag.objects.get_or_create(
- comment = comment,
- user = request.user,
- flag = comments.models.CommentFlag.SUGGEST_REMOVAL
+ comment=comment,
+ user=request.user,
+ flag=comments.models.CommentFlag.SUGGEST_REMOVAL
)
signals.comment_was_flagged.send(
- sender = comment.__class__,
- comment = comment,
- flag = flag,
- created = created,
- request = request,
+ sender=comment.__class__,
+ comment=comment,
+ flag=flag,
+ created=created,
+ request=request,
)
def perform_delete(request, comment):
flag, created = comments.models.CommentFlag.objects.get_or_create(
- comment = comment,
- user = request.user,
- flag = comments.models.CommentFlag.MODERATOR_DELETION
+ comment=comment,
+ user=request.user,
+ flag=comments.models.CommentFlag.MODERATOR_DELETION
)
comment.is_removed = True
comment.save()
signals.comment_was_flagged.send(
- sender = comment.__class__,
- comment = comment,
- flag = flag,
- created = created,
- request = request,
+ sender=comment.__class__,
+ comment=comment,
+ flag=flag,
+ created=created,
+ request=request,
)
def perform_approve(request, comment):
flag, created = comments.models.CommentFlag.objects.get_or_create(
- comment = comment,
- user = request.user,
- flag = comments.models.CommentFlag.MODERATOR_APPROVAL,
+ comment=comment,
+ user=request.user,
+ flag=comments.models.CommentFlag.MODERATOR_APPROVAL,
)
comment.is_removed = False
comment.is_public = True
comment.save()
signals.comment_was_flagged.send(
- sender = comment.__class__,
- comment = comment,
- flag = flag,
- created = created,
- request = request,
+ sender=comment.__class__,
+ comment=comment,
+ flag=flag,
+ created=created,
+ request=request,
)
# Confirmation views.
flag_done = confirmation_view(
- template = "comments/flagged.html",
- doc = 'Displays a "comment was flagged" success page.'
+ template="comments/flagged.html",
+ doc='Displays a "comment was flagged" success page.'
)
delete_done = confirmation_view(
- template = "comments/deleted.html",
- doc = 'Displays a "comment was deleted" success page.'
+ template="comments/deleted.html",
+ doc='Displays a "comment was deleted" success page.'
)
approve_done = confirmation_view(
- template = "comments/approved.html",
- doc = 'Displays a "comment was approved" success page.'
+ template="comments/approved.html",
+ doc='Displays a "comment was approved" success page.'
)
@@ -276,14 +276,14 @@ def __get__(self, instance, instance_type=None):
join_cols = self.field.get_joining_columns(reverse_join=True)[0]
manager = RelatedManager(
- model = rel_model,
- instance = instance,
- source_col_name = qn(join_cols[0]),
- target_col_name = qn(join_cols[1]),
- content_type = content_type,
- content_type_field_name = self.field.content_type_field_name,
- object_id_field_name = self.field.object_id_field_name,
- prefetch_cache_name = self.field.attname,
+ model=rel_model,
+ instance=instance,
+ source_col_name=qn(join_cols[0]),
+ target_col_name=qn(join_cols[1]),
+ content_type=content_type,
+ content_type_field_name=self.field.content_type_field_name,
+ object_id_field_name=self.field.object_id_field_name,
+ prefetch_cache_name=self.field.attname,
)
return manager
@@ -329,15 +329,15 @@ def __call__(self, **kwargs):
manager = getattr(self.model, kwargs.pop('manager'))
manager_class = create_generic_related_manager(manager.__class__)
return manager_class(
- model = self.model,
- instance = self.instance,
- symmetrical = self.symmetrical,
- source_col_name = self.source_col_name,
- target_col_name = self.target_col_name,
- content_type = self.content_type,
- content_type_field_name = self.content_type_field_name,
- object_id_field_name = self.object_id_field_name,
- prefetch_cache_name = self.prefetch_cache_name,
+ model=self.model,
+ instance=self.instance,
+ symmetrical=self.symmetrical,
+ source_col_name=self.source_col_name,
+ target_col_name=self.target_col_name,
+ content_type=self.content_type,
+ content_type_field_name=self.content_type_field_name,
+ object_id_field_name=self.object_id_field_name,
+ prefetch_cache_name=self.prefetch_cache_name,
)
do_not_call_in_templates = True
@@ -43,9 +43,9 @@ def get_for_model(self, model, for_concrete_model=True):
# needed around opts.verbose_name_raw because name_raw might be a
# django.utils.functional.__proxy__ object.
ct, created = self.get_or_create(
- app_label = opts.app_label,
- model = opts.model_name,
- defaults = {'name': smart_text(opts.verbose_name_raw)},
+ app_label=opts.app_label,
+ model=opts.model_name,
+ defaults={'name': smart_text(opts.verbose_name_raw)},
)
self._add_to_cache(self.db, ct)
@@ -271,9 +271,9 @@ def test_missing_model(self):
is defined anymore.
"""
ct = ContentType.objects.create(
- name = 'Old model',
- app_label = 'contenttypes',
- model = 'OldModel',
+ name='Old model',
+ app_label='contenttypes',
+ model='OldModel',
)
self.assertEqual(six.text_type(ct), 'Old model')
self.assertIsNone(ct.model_class())
@@ -6,10 +6,10 @@
class FlatpageForm(forms.ModelForm):
url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
- help_text = _("Example: '/about/contact/'. Make sure to have leading"
- " and trailing slashes."),
- error_message = _("This value must contain only letters, numbers,"
- " dots, underscores, dashes, slashes or tildes."))
+ help_text=_("Example: '/about/contact/'. Make sure to have leading"
+ " and trailing slashes."),
+ error_message=_("This value must contain only letters, numbers,"
+ " dots, underscores, dashes, slashes or tildes."))
class Meta:
model = FlatPage
@@ -87,7 +87,7 @@ def test_fallback_flatpage_special_chars(self):
@override_settings(
- APPEND_SLASH = True,
+ APPEND_SLASH=True,
LOGIN_URL='/accounts/login/',
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
@@ -75,7 +75,7 @@ def test_view_flatpage_special_chars(self):
@override_settings(
- APPEND_SLASH = True,
+ APPEND_SLASH=True,
LOGIN_URL='/accounts/login/',
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
@@ -58,12 +58,12 @@ class BaseTests(object):
def setUp(self):
self.settings_override = override_settings_tags(
- TEMPLATE_DIRS = (),
- TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS,
- MESSAGE_TAGS = '',
- MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
+ TEMPLATE_DIRS=(),
+ TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
+ MESSAGE_TAGS='',
+ MESSAGE_STORAGE='%s.%s' % (self.storage_class.__module__,
self.storage_class.__name__),
- SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer',
+ SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer',
)
self.settings_override.enable()
Oops, something went wrong.

0 comments on commit cbc7cbb

Please sign in to comment.