Permalink
Browse files

Fixed #21288 -- Fixed E126 pep8 warnings

  • Loading branch information...
1 parent a369016 commit b289fcf1bfeaa717ed465b2529a275b61dc02d92 @alasdairnicol alasdairnicol committed with timgraham Oct 19, 2013
Showing with 647 additions and 635 deletions.
  1. +6 −6 django/contrib/admin/filters.py
  2. +11 −12 django/contrib/admin/options.py
  3. +3 −5 django/contrib/admin/templatetags/admin_list.py
  4. +1 −2 django/contrib/admin/templatetags/admin_modify.py
  5. +1 −1 django/contrib/auth/management/commands/changepassword.py
  6. +1 −1 django/contrib/auth/tests/test_auth_backends.py
  7. +11 −9 django/contrib/auth/tests/test_views.py
  8. +5 −8 django/contrib/contenttypes/generic.py
  9. +40 −40 django/contrib/flatpages/tests/test_templatetags.py
  10. +4 −4 django/contrib/formtools/wizard/storage/base.py
  11. +2 −2 django/contrib/formtools/wizard/views.py
  12. +9 −9 django/contrib/gis/db/models/sql/query.py
  13. +1 −1 django/contrib/gis/db/models/sql/where.py
  14. +1 −1 django/contrib/gis/gdal/geometries.py
  15. +6 −5 django/contrib/gis/geos/tests/test_geos_mutation.py
  16. +5 −5 django/contrib/messages/tests/base.py
  17. +2 −2 django/contrib/redirects/tests.py
  18. +1 −1 django/contrib/sitemaps/views.py
  19. +4 −4 django/core/handlers/base.py
  20. +1 −1 django/core/management/commands/createcachetable.py
  21. +10 −10 django/core/management/commands/loaddata.py
  22. +1 −1 django/core/management/commands/makemessages.py
  23. +4 −4 django/core/serializers/xml_serializer.py
  24. +17 −13 django/db/models/base.py
  25. +1 −1 django/db/models/query.py
  26. +2 −2 django/db/models/sql/query.py
  27. +1 −1 django/db/models/sql/subqueries.py
  28. +2 −2 django/db/transaction.py
  29. +3 −3 django/forms/models.py
  30. +3 −3 django/forms/widgets.py
  31. +2 −2 django/http/utils.py
  32. +1 −1 django/middleware/locale.py
  33. +1 −1 django/test/runner.py
  34. +1 −1 django/test/testcases.py
  35. +2 −2 django/utils/html.py
  36. +2 −2 django/utils/http.py
  37. +9 −9 django/utils/jslex.py
  38. +1 −1 django/utils/timezone.py
  39. +1 −1 django/views/generic/dates.py
  40. +2 −2 django/views/generic/list.py
  41. +2 −2 docs/_ext/applyxrefs.py
  42. +1 −1 setup.cfg
  43. +5 −6 tests/admin_views/models.py
  44. +5 −7 tests/admin_views/tests.py
  45. +6 −2 tests/admin_widgets/tests.py
  46. +2 −4 tests/basic/tests.py
  47. +59 −59 tests/cache/tests.py
  48. +1 −2 tests/distinct_on_fields/tests.py
  49. +15 −16 tests/extra_regress/tests.py
  50. +1 −2 tests/file_uploads/tests.py
  51. +26 −26 tests/forms_tests/tests/test_fields.py
  52. +6 −6 tests/forms_tests/tests/test_widgets.py
  53. +4 −4 tests/forms_tests/tests/tests.py
  54. +21 −21 tests/generic_relations/tests.py
  55. +2 −2 tests/i18n/tests.py
  56. +13 −13 tests/logging_tests/tests.py
  57. +2 −2 tests/mail/tests.py
  58. +8 −8 tests/managers_regress/tests.py
  59. +5 −5 tests/many_to_one/tests.py
  60. +5 −5 tests/middleware_exceptions/tests.py
  61. +6 −6 tests/model_fields/models.py
  62. +65 −65 tests/model_forms/tests.py
  63. +17 −17 tests/model_formsets_regress/tests.py
  64. +2 −2 tests/model_inheritance_regress/models.py
  65. +2 −2 tests/model_inheritance_regress/tests.py
  66. +8 −8 tests/model_regress/tests.py
  67. +5 −5 tests/null_queries/tests.py
  68. +11 −11 tests/pagination/tests.py
  69. +1 −1 tests/queries/tests.py
  70. +24 −24 tests/requests/tests.py
  71. +2 −2 tests/reverse_single_related/tests.py
  72. +2 −2 tests/select_related_regress/tests.py
  73. +2 −4 tests/serializers_regress/tests.py
  74. +2 −2 tests/signing/tests.py
  75. +1 −1 tests/template_tests/test_loaders.py
  76. +8 −8 tests/template_tests/test_response.py
  77. +4 −4 tests/test_client_regress/tests.py
  78. +108 −90 tests/timezones/tests.py
  79. +1 −1 tests/transactions/tests.py
  80. +6 −6 tests/utils_tests/test_tzinfo.py
@@ -217,8 +217,8 @@ def choices(self, cl):
}
FieldListFilter.register(lambda f: (
- bool(f.rel) if hasattr(f, 'rel') else
- isinstance(f, models.related.RelatedObject)), RelatedFieldListFilter)
+ bool(f.rel) if hasattr(f, 'rel') else
+ isinstance(f, models.related.RelatedObject)), RelatedFieldListFilter)
class BooleanFieldListFilter(FieldListFilter):
@@ -241,15 +241,15 @@ def choices(self, cl):
yield {
'selected': self.lookup_val == lookup and not self.lookup_val2,
'query_string': cl.get_query_string({
- self.lookup_kwarg: lookup,
+ self.lookup_kwarg: lookup,
}, [self.lookup_kwarg2]),
'display': title,
}
if isinstance(self.field, models.NullBooleanField):
yield {
'selected': self.lookup_val2 == 'True',
'query_string': cl.get_query_string({
- self.lookup_kwarg2: 'True',
+ self.lookup_kwarg2: 'True',
}, [self.lookup_kwarg]),
'display': _('Unknown'),
}
@@ -278,7 +278,7 @@ def choices(self, cl):
yield {
'selected': smart_text(lookup) == self.lookup_val,
'query_string': cl.get_query_string({
- self.lookup_kwarg: lookup}),
+ self.lookup_kwarg: lookup}),
'display': title,
}
@@ -340,7 +340,7 @@ def choices(self, cl):
yield {
'selected': self.date_params == param_dict,
'query_string': cl.get_query_string(
- param_dict, [self.field_generic]),
+ param_dict, [self.field_generic]),
'display': title,
}
@@ -150,13 +150,12 @@ def formfield_for_dbfield(self, db_field, **kwargs):
# rendered output. formfield can be None if it came from a
# OneToOneField with parent_link=True or a M2M intermediary.
if formfield and db_field.name not in self.raw_id_fields:
- related_modeladmin = self.admin_site._registry.get(
- db_field.rel.to)
+ related_modeladmin = self.admin_site._registry.get(db_field.rel.to)
can_add_related = bool(related_modeladmin and
- related_modeladmin.has_add_permission(request))
+ related_modeladmin.has_add_permission(request))
formfield.widget = widgets.RelatedFieldWidgetWrapper(
- formfield.widget, db_field.rel, self.admin_site,
- can_add_related=can_add_related)
+ formfield.widget, db_field.rel, self.admin_site,
+ can_add_related=can_add_related)
return formfield
@@ -1196,11 +1195,11 @@ def response_delete(self, request, obj_display):
opts = self.model._meta
- self.message_user(request, _(
- 'The %(name)s "%(obj)s" was deleted successfully.') % {
+ self.message_user(request,
+ _('The %(name)s "%(obj)s" was deleted successfully.') % {
'name': force_text(opts.verbose_name),
'obj': force_text(obj_display)
- }, messages.SUCCESS)
+ }, messages.SUCCESS)
if self.has_change_permission(request, None):
post_url = reverse('admin:%s_%s_changelist' %
@@ -1313,9 +1312,9 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(opts.verbose_name), 'key': escape(object_id)})
if request.method == 'POST' and "_saveasnew" in request.POST:
- return self.add_view(request, form_url=reverse('admin:%s_%s_add' %
- (opts.app_label, opts.model_name),
- current_app=self.admin_site.name))
+ return self.add_view(request, form_url=reverse('admin:%s_%s_add' % (
+ opts.app_label, opts.model_name),
+ current_app=self.admin_site.name))
ModelForm = self.get_form(request, obj)
if request.method == 'POST':
@@ -1544,7 +1543,7 @@ def delete_view(self, request, object_id, extra_context=None):
if obj is None:
raise Http404(
_('%(name)s object with primary key %(key)r does not exist.') %
- {'name': force_text(opts.verbose_name), 'key': escape(object_id)}
+ {'name': force_text(opts.verbose_name), 'key': escape(object_id)}
)
using = router.db_for_write(self.model)
@@ -164,8 +164,7 @@ def result_headers(cl):
"url_primary": cl.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}),
"url_remove": cl.get_query_string({ORDER_VAR: '.'.join(o_list_remove)}),
"url_toggle": cl.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}),
- "class_attrib": format_html(' class="{0}"', ' '.join(th_classes))
- if th_classes else '',
+ "class_attrib": format_html(' class="{0}"', ' '.join(th_classes)) if th_classes else '',
}
def _boolean_icon(field_val):
@@ -246,8 +245,7 @@ def link_in_col(is_first, field_name, cl):
link_or_text = format_html(
'<a href="{0}"{1}>{2}</a>',
url,
- format_html(' onclick="opener.dismissRelatedLookupPopup(window, &#39;{0}&#39;); return false;"', result_id)
- if cl.is_popup else '',
+ format_html(' onclick="opener.dismissRelatedLookupPopup(window, &#39;{0}&#39;); return false;"', result_id) if cl.is_popup else '',
result_repr)
yield format_html('<{0}{1}>{2}</{3}>',
@@ -261,7 +259,7 @@ def link_in_col(is_first, field_name, cl):
# can provide fields on a per request basis
if (form and field_name in form.fields and not (
field_name == cl.model._meta.pk.name and
- form[cl.model._meta.pk.name].is_hidden)):
+ form[cl.model._meta.pk.name].is_hidden)):
bf = form[field_name]
result_repr = mark_safe(force_text(bf.errors) + force_text(bf))
yield format_html('<td{0}>{1}</td>', row_class, result_repr)
@@ -33,8 +33,7 @@ def submit_row(context):
'show_delete_link': (not is_popup and context['has_delete_permission']
and change and context.get('show_delete', True)),
'show_save_as_new': not is_popup and change and save_as,
- 'show_save_and_add_another': context['has_add_permission'] and
- not is_popup and (not save_as or context['add']),
+ 'show_save_and_add_another': context['has_add_permission'] and not is_popup and (not save_as or context['add']),
'show_save_and_continue': not is_popup and context['has_change_permission'],
'is_popup': is_popup,
'show_save': True,
@@ -34,7 +34,7 @@ def handle(self, *args, **options):
try:
u = UserModel._default_manager.using(options.get('database')).get(**{
- UserModel.USERNAME_FIELD: username
+ UserModel.USERNAME_FIELD: username
})
except UserModel.DoesNotExist:
raise CommandError("user '%s' does not exist" % username)
@@ -427,7 +427,7 @@ def test_permission_denied(self):
self.assertEqual(authenticate(username='test', password='test'), None)
@override_settings(AUTHENTICATION_BACKENDS=tuple(
- settings.AUTHENTICATION_BACKENDS) + (backend, ))
+ settings.AUTHENTICATION_BACKENDS) + (backend, ))
def test_authenticates(self):
self.assertEqual(authenticate(username='test', password='test'), self.user1)
@@ -177,9 +177,10 @@ def test_poisoned_http_host(self):
# HTTP_HOST header isn't poisoned. This is done as a check when get_host()
# is invoked, but we check here as a practical consequence.
with patch_logger('django.security.DisallowedHost', 'error') as logger_calls:
- response = self.client.post('/password_reset/',
- {'email': 'staffmember@example.com'},
- HTTP_HOST='www.example:dr.frankenstein@evil.tld'
+ response = self.client.post(
+ '/password_reset/',
+ {'email': 'staffmember@example.com'},
+ HTTP_HOST='www.example:dr.frankenstein@evil.tld'
)
self.assertEqual(response.status_code, 400)
self.assertEqual(len(mail.outbox), 0)
@@ -190,9 +191,10 @@ def test_poisoned_http_host(self):
def test_poisoned_http_host_admin_site(self):
"Poisoned HTTP_HOST headers can't be used for reset emails on admin views"
with patch_logger('django.security.DisallowedHost', 'error') as logger_calls:
- response = self.client.post('/admin_password_reset/',
- {'email': 'staffmember@example.com'},
- HTTP_HOST='www.example:dr.frankenstein@evil.tld'
+ response = self.client.post(
+ '/admin_password_reset/',
+ {'email': 'staffmember@example.com'},
+ HTTP_HOST='www.example:dr.frankenstein@evil.tld'
)
self.assertEqual(response.status_code, 400)
self.assertEqual(len(mail.outbox), 0)
@@ -356,7 +358,7 @@ def fail_login(self, password='password'):
'password': password,
})
self.assertFormError(response, AuthenticationForm.error_messages['invalid_login'] % {
- 'username': User._meta.get_field('username').verbose_name
+ 'username': User._meta.get_field('username').verbose_name
})
def logout(self):
@@ -490,8 +492,8 @@ def test_security_check(self, password='password'):
'good_url': urlquote(good_url),
}
response = self.client.post(safe_url, {
- 'username': 'testclient',
- 'password': password,
+ 'username': 'testclient',
+ 'password': password,
})
self.assertEqual(response.status_code, 302)
self.assertTrue(good_url in response.url,
@@ -240,12 +240,10 @@ def bulk_related_objects(self, objs, using=DEFAULT_DB_ALIAS):
"""
return self.rel.to._base_manager.db_manager(using).filter(**{
- "%s__pk" % self.content_type_field_name:
- ContentType.objects.db_manager(using).get_for_model(
- self.model, for_concrete_model=self.for_concrete_model).pk,
- "%s__in" % self.object_id_field_name:
- [obj.pk for obj in objs]
- })
+ "%s__pk" % self.content_type_field_name: ContentType.objects.db_manager(using).get_for_model(
+ self.model, for_concrete_model=self.for_concrete_model).pk,
+ "%s__in" % self.object_id_field_name: [obj.pk for obj in objs]
+ })
class ReverseGenericRelatedObjectsDescriptor(object):
@@ -352,8 +350,7 @@ def get_prefetch_queryset(self, instances):
db = self._db or router.db_for_read(self.model, instance=instances[0])
query = {
'%s__pk' % self.content_type_field_name: self.content_type.id,
- '%s__in' % self.object_id_field_name:
- set(obj._get_pk_val() for obj in instances)
+ '%s__in' % self.object_id_field_name: set(obj._get_pk_val() for obj in instances)
}
qs = super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**query)
# We (possibly) need to convert object IDs to the type of the
@@ -27,24 +27,24 @@ class FlatpageTemplateTagTests(TestCase):
def test_get_flatpages_tag(self):
"The flatpage template tag retrives unregistered prefixed flatpages by default"
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages as flatpages %}"
- "{% for page in flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages as flatpages %}"
+ "{% for page in flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context())
self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
def test_get_flatpages_tag_for_anon_user(self):
"The flatpage template tag retrives unregistered flatpages for an anonymous user"
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages for anonuser as flatpages %}"
- "{% for page in flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages for anonuser as flatpages %}"
+ "{% for page in flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context({
- 'anonuser': AnonymousUser()
+ 'anonuser': AnonymousUser()
}))
self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
@@ -53,37 +53,37 @@ def test_get_flatpages_tag_for_user(self):
"The flatpage template tag retrives all flatpages for an authenticated user"
me = User.objects.create_user('testuser', 'test@example.com', 's3krit')
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages for me as flatpages %}"
- "{% for page in flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages for me as flatpages %}"
+ "{% for page in flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context({
- 'me': me
+ 'me': me
}))
self.assertEqual(out, "A Flatpage,A Nested Flatpage,Sekrit Nested Flatpage,Sekrit Flatpage,")
def test_get_flatpages_with_prefix(self):
"The flatpage template tag retrives unregistered prefixed flatpages by default"
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages '/location/' as location_flatpages %}"
- "{% for page in location_flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages '/location/' as location_flatpages %}"
+ "{% for page in location_flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context())
self.assertEqual(out, "A Nested Flatpage,")
def test_get_flatpages_with_prefix_for_anon_user(self):
"The flatpage template tag retrives unregistered prefixed flatpages for an anonymous user"
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages '/location/' for anonuser as location_flatpages %}"
- "{% for page in location_flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages '/location/' for anonuser as location_flatpages %}"
+ "{% for page in location_flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context({
- 'anonuser': AnonymousUser()
+ 'anonuser': AnonymousUser()
}))
self.assertEqual(out, "A Nested Flatpage,")
@@ -92,26 +92,26 @@ def test_get_flatpages_with_prefix_for_user(self):
"The flatpage template tag retrive prefixed flatpages for an authenticated user"
me = User.objects.create_user('testuser', 'test@example.com', 's3krit')
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages '/location/' for me as location_flatpages %}"
- "{% for page in location_flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages '/location/' for me as location_flatpages %}"
+ "{% for page in location_flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context({
- 'me': me
+ 'me': me
}))
self.assertEqual(out, "A Nested Flatpage,Sekrit Nested Flatpage,")
def test_get_flatpages_with_variable_prefix(self):
"The prefix for the flatpage template tag can be a template variable"
out = Template(
- "{% load flatpages %}"
- "{% get_flatpages location_prefix as location_flatpages %}"
- "{% for page in location_flatpages %}"
- "{{ page.title }},"
- "{% endfor %}"
+ "{% load flatpages %}"
+ "{% get_flatpages location_prefix as location_flatpages %}"
+ "{% for page in location_flatpages %}"
+ "{{ page.title }},"
+ "{% endfor %}"
).render(Context({
- 'location_prefix': '/location/'
+ 'location_prefix': '/location/'
}))
self.assertEqual(out, "A Nested Flatpage,")
@@ -70,8 +70,8 @@ def get_step_files(self, step):
if wizard_files and not self.file_storage:
raise NoFileStorageConfigured(
- "You need to define 'file_storage' in your "
- "wizard view in order to handle file uploads.")
+ "You need to define 'file_storage' in your "
+ "wizard view in order to handle file uploads.")
files = {}
for field, field_dict in six.iteritems(wizard_files):
@@ -84,8 +84,8 @@ def get_step_files(self, step):
def set_step_files(self, step, files):
if files and not self.file_storage:
raise NoFileStorageConfigured(
- "You need to define 'file_storage' in your "
- "wizard view in order to handle file uploads.")
+ "You need to define 'file_storage' in your "
+ "wizard view in order to handle file uploads.")
if step not in self.data[self.step_files_key]:
self.data[self.step_files_key][step] = {}
@@ -184,8 +184,8 @@ def get_initkwargs(cls, form_list=None, initial_dict=None,
if (isinstance(field, forms.FileField) and
not hasattr(cls, 'file_storage')):
raise NoFileStorageConfigured(
- "You need to define 'file_storage' in your "
- "wizard view in order to handle file uploads.")
+ "You need to define 'file_storage' in your "
+ "wizard view in order to handle file uploads.")
# build the kwargs for the wizardview instances
kwargs['form_list'] = computed_form_list
Oops, something went wrong. Retry.

0 comments on commit b289fcf

Please sign in to comment.