Skip to content

Commit

Permalink
Fixed E124 pep8 warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
loic authored and timgraham committed Dec 10, 2013
1 parent 0873200 commit a281484
Show file tree
Hide file tree
Showing 45 changed files with 371 additions and 262 deletions.
3 changes: 2 additions & 1 deletion django/contrib/admin/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(self, form, fieldsets, prepopulated_fields, readonly_fields=None, m

def __iter__(self):
for name, options in self.fieldsets:
yield Fieldset(self.form, name,
yield Fieldset(
self.form, name,
readonly_fields=self.readonly_fields,
model_admin=self.model_admin,
**options
Expand Down
6 changes: 4 additions & 2 deletions django/contrib/admin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,8 @@ def changelist_view(self, request, extra_context=None):
selection_note_all = ungettext('%(total_count)s selected',
'All %(total_count)s selected', cl.result_count)

context = dict(self.admin_site.each_context(),
context = dict(
self.admin_site.each_context(),
module_name=force_text(opts.verbose_name_plural),
selection_note=_('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
selection_note_all=selection_note_all % {'total_count': cl.result_count},
Expand Down Expand Up @@ -1587,7 +1588,8 @@ def delete_view(self, request, object_id, extra_context=None):
else:
title = _("Are you sure?")

context = dict(self.admin_site.each_context(),
context = dict(
self.admin_site.each_context(),
title=title,
object_name=object_name,
object=obj,
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/admin/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ def index(self, request, extra_context=None):
for app in app_list:
app['models'].sort(key=lambda x: x['name'])

context = dict(self.each_context(),
context = dict(
self.each_context(),
title=self.index_title,
app_list=app_list,
)
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/admin/templatetags/admin_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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,
text, attr = label_for_field(
field_name, cl.model,
model_admin=cl.model_admin,
return_attr=True
)
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/admindocs/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def setUp(self):
pass

def test_field_name(self):
self.assertRaises(AttributeError,
self.assertRaises(
AttributeError,
views.get_readable_field_data_type, "NotAField"
)

Expand Down
27 changes: 9 additions & 18 deletions django/contrib/admindocs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,29 @@
urlpatterns = patterns('',
url('^$',
views.BaseAdminDocsView.as_view(template_name='admin_doc/index.html'),
name='django-admindocs-docroot'
),
name='django-admindocs-docroot'),
url('^bookmarklets/$',
views.BookmarkletsView.as_view(),
name='django-admindocs-bookmarklets'
),
name='django-admindocs-bookmarklets'),
url('^tags/$',
views.TemplateTagIndexView.as_view(),
name='django-admindocs-tags'
),
name='django-admindocs-tags'),
url('^filters/$',
views.TemplateFilterIndexView.as_view(),
name='django-admindocs-filters'
),
name='django-admindocs-filters'),
url('^views/$',
views.ViewIndexView.as_view(),
name='django-admindocs-views-index'
),
name='django-admindocs-views-index'),
url('^views/(?P<view>[^/]+)/$',
views.ViewDetailView.as_view(),
name='django-admindocs-views-detail'
),
name='django-admindocs-views-detail'),
url('^models/$',
views.ModelIndexView.as_view(),
name='django-admindocs-models-index'
),
name='django-admindocs-models-index'),
url('^models/(?P<app_label>[^\.]+)\.(?P<model_name>[^/]+)/$',
views.ModelDetailView.as_view(),
name='django-admindocs-models-detail'
),
name='django-admindocs-models-detail'),
url('^templates/(?P<template>.*)/$',
views.TemplateDetailView.as_view(),
name='django-admindocs-templates'
),
name='django-admindocs-templates'),
)
4 changes: 2 additions & 2 deletions django/contrib/auth/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class UserAdmin(admin.ModelAdmin):
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'password1', 'password2')}
),
'fields': ('username', 'password1', 'password2'),
}),
)
form = UserChangeForm
add_form = UserCreationForm
Expand Down
15 changes: 10 additions & 5 deletions django/contrib/auth/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def test_createsuperuser_management_command(self):
"Check the operation of the createsuperuser management command"
# We can use the management command to create a superuser
new_io = StringIO()
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="joe",
email="[email protected]",
Expand All @@ -146,7 +147,8 @@ def test_createsuperuser_management_command(self):

# We can supress output on the management command
new_io = StringIO()
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="joe2",
email="[email protected]",
Expand All @@ -159,7 +161,8 @@ def test_createsuperuser_management_command(self):
self.assertEqual(u.email, '[email protected]')
self.assertFalse(u.has_usable_password())

call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="[email protected]",
email="[email protected]",
Expand All @@ -182,7 +185,8 @@ def test_createsuperuser_nolocale(self):
locale.getdefaultlocale = lambda: (None, None)

# Call the command in this new environment
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=True,
username="[email protected]",
email="[email protected]",
Expand Down Expand Up @@ -212,7 +216,8 @@ def test_createsuperuser_non_ascii_verbose_name(self):
username_field.verbose_name = ulazy('uživatel')
new_io = StringIO()
try:
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=True,
stdout=new_io
)
Expand Down
15 changes: 10 additions & 5 deletions django/contrib/auth/tests/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def test_createsuperuser(self):
"Check the operation of the createsuperuser management command"
# We can use the management command to create a superuser
new_io = StringIO()
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="joe",
email="[email protected]",
Expand All @@ -108,7 +109,8 @@ def test_createsuperuser(self):
def test_verbosity_zero(self):
# We can supress output on the management command
new_io = StringIO()
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="joe2",
email="[email protected]",
Expand All @@ -123,7 +125,8 @@ def test_verbosity_zero(self):

def test_email_in_username(self):
new_io = StringIO()
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="[email protected]",
email="[email protected]",
Expand All @@ -140,7 +143,8 @@ def test_swappable_user(self):
# We skip validation because the temporary substitution of the
# swappable User model messes with validation.
new_io = StringIO()
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
email="[email protected]",
date_of_birth="1976-04-01",
Expand All @@ -163,7 +167,8 @@ def test_swappable_user_missing_required_field(self):
# swappable User model messes with validation.
new_io = StringIO()
with self.assertRaises(CommandError):
call_command("createsuperuser",
call_command(
"createsuperuser",
interactive=False,
username="[email protected]",
stdout=new_io,
Expand Down
7 changes: 4 additions & 3 deletions django/contrib/contenttypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,10 @@ def __init__(self, data=None, files=None, instance=None, save_as_new=None,
@classmethod
def get_default_prefix(cls):
opts = cls.model._meta
return '-'.join((opts.app_label, opts.model_name,
cls.ct_field.name, cls.ct_fk_field.name,
))
return '-'.join(
(opts.app_label, opts.model_name,
cls.ct_field.name, cls.ct_fk_field.name)
)

def save_new(self, form, commit=True):
setattr(form.instance, self.ct_field.get_attname(),
Expand Down
25 changes: 14 additions & 11 deletions django/contrib/gis/db/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,14 @@ def svg(self, relative=False, precision=8, **kwargs):
relative = int(bool(relative))
if not isinstance(precision, six.integer_types):
raise TypeError('SVG precision keyword argument must be an integer.')
s = {'desc': 'SVG',
'procedure_fmt': '%(geo_col)s,%(rel)s,%(precision)s',
'procedure_args': {'rel': relative,
'precision': precision,
}
}
s = {
'desc': 'SVG',
'procedure_fmt': '%(geo_col)s,%(rel)s,%(precision)s',
'procedure_args': {
'rel': relative,
'precision': precision,
}
}
return self._spatial_attribute('svg', s, **kwargs)

def sym_difference(self, geom, **kwargs):
Expand Down Expand Up @@ -746,11 +748,12 @@ def _geomset_attribute(self, func, geom, tolerance=0.05, **kwargs):
for geometry set-like operations (e.g., intersection, difference,
union, sym_difference).
"""
s = {'geom_args': ('geom',),
'select_field': GeomField(),
'procedure_fmt': '%(geo_col)s,%(geom)s',
'procedure_args': {'geom': geom},
}
s = {
'geom_args': ('geom',),
'select_field': GeomField(),
'procedure_fmt': '%(geo_col)s,%(geom)s',
'procedure_args': {'geom': geom},
}
if connections[self.db].ops.oracle:
s['procedure_fmt'] += ',%(tolerance)s'
s['procedure_args']['tolerance'] = tolerance
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/gis/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def render(self, name, value, attrs=None):
value.srid, self.map_srid, err)
)

context = self.build_attrs(attrs,
context = self.build_attrs(
attrs,
name=name,
module='geodjango_%s' % name.replace('-', '_'), # JS-safe
serialized=self.serialize(value),
Expand Down
9 changes: 5 additions & 4 deletions django/contrib/gis/tests/geoapp/test_regress.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ def test_update(self):
def test_kmz(self):
"Testing `render_to_kmz` with non-ASCII data. See #11624."
name = "Åland Islands"
places = [{'name': name,
'description': name,
'kml': '<Point><coordinates>5.0,23.0</coordinates></Point>'
}]
places = [{
'name': name,
'description': name,
'kml': '<Point><coordinates>5.0,23.0</coordinates></Point>'
}]
render_to_kmz('gis/kml/placemarks.kml', {'places': places})

@no_spatialite
Expand Down
3 changes: 2 additions & 1 deletion django/core/management/commands/testserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def handle(self, *fixture_labels, **options):
# multiple times.
shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name
use_threading = connection.features.test_db_allows_multiple_connections
call_command('runserver',
call_command(
'runserver',
addrport=addrport,
shutdown_message=shutdown_message,
use_reloader=False,
Expand Down
12 changes: 6 additions & 6 deletions django/core/management/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ def get_validation_errors(outfile, app=None):
seen_to = True
if f.rel.through not in models.get_models(include_auto_created=True):
e.add(opts, "'%s' specifies an m2m relation through model "
"%s, which has not been installed." % (f.name, f.rel.through)
)
"%s, which has not been installed." % (f.name, f.rel.through))
signature = (f.rel.to, cls, f.rel.through)
if signature in seen_intermediary_signatures:
e.add(opts, "The model %s has two manually-defined m2m "
Expand All @@ -295,13 +294,14 @@ def get_validation_errors(outfile, app=None):
if not seen_related_fk or not seen_this_fk:
e.add(opts, "'%s' is a manually-defined m2m relation "
"through model %s, which does not have foreign keys "
"to %s and %s" % (f.name, f.rel.through._meta.object_name,
f.rel.to._meta.object_name, cls._meta.object_name)
"to %s and %s" % (
f.name, f.rel.through._meta.object_name,
f.rel.to._meta.object_name, cls._meta.object_name
)
)
elif isinstance(f.rel.through, six.string_types):
e.add(opts, "'%s' specifies an m2m relation through model %s, "
"which has not been installed" % (f.name, f.rel.through)
)
"which has not been installed" % (f.name, f.rel.through))

rel_opts = f.rel.to._meta
rel_name = f.related.get_accessor_name()
Expand Down
3 changes: 1 addition & 2 deletions django/db/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,7 @@ def modify_insert_params(self, placeholders, params):

# Structure returned by the DB-API cursor.description interface (PEP 249)
FieldInfo = namedtuple('FieldInfo',
'name type_code display_size internal_size precision scale null_ok'
)
'name type_code display_size internal_size precision scale null_ok')


class BaseDatabaseIntrospection(object):
Expand Down
8 changes: 5 additions & 3 deletions django/db/backends/mysql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,15 @@ def sequence_reset_by_name_sql(self, style, sequences):
# Truncate already resets the AUTO_INCREMENT field from
# MySQL version 5.0.13 onwards. Refs #16961.
if self.connection.mysql_version < (5, 0, 13):
return ["%s %s %s %s %s;" %
(style.SQL_KEYWORD('ALTER'),
return [
"%s %s %s %s %s;" % (
style.SQL_KEYWORD('ALTER'),
style.SQL_KEYWORD('TABLE'),
style.SQL_TABLE(self.quote_name(sequence['table'])),
style.SQL_KEYWORD('AUTO_INCREMENT'),
style.SQL_FIELD('= 1'),
) for sequence in sequences]
) for sequence in sequences
]
else:
return []

Expand Down
3 changes: 2 additions & 1 deletion django/db/backends/postgresql_psycopg2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def close(self):
# notification. If we don't set self.connection to None, the error
# will occur a every request.
self.connection = None
logger.warning('psycopg2 error while closing the connection.',
logger.warning(
'psycopg2 error while closing the connection.',
exc_info=sys.exc_info()
)
raise
Expand Down
Loading

0 comments on commit a281484

Please sign in to comment.