diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index 1f8cb5ed61..9e539614a3 100644
--- a/django/contrib/admin/filters.py
+++ b/django/contrib/admin/filters.py
@@ -179,9 +179,9 @@ class RelatedFieldListFilter(FieldListFilter):
self.title = self.lookup_title
def has_output(self):
- if (isinstance(self.field, models.related.RelatedObject)
- and self.field.field.null or hasattr(self.field, 'rel')
- and self.field.null):
+ if (isinstance(self.field, models.related.RelatedObject) and
+ self.field.field.null or hasattr(self.field, 'rel') and
+ self.field.null):
extra = 1
else:
extra = 0
@@ -206,9 +206,9 @@ class RelatedFieldListFilter(FieldListFilter):
}, [self.lookup_kwarg_isnull]),
'display': val,
}
- if (isinstance(self.field, models.related.RelatedObject)
- and self.field.field.null or hasattr(self.field, 'rel')
- and self.field.null):
+ if (isinstance(self.field, models.related.RelatedObject) and
+ self.field.field.null or hasattr(self.field, 'rel') and
+ self.field.null):
yield {
'selected': bool(self.lookup_val_isnull),
'query_string': cl.get_query_string({
diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py
index c4ce53fec0..4a6f5c3192 100644
--- a/django/contrib/admin/templatetags/admin_modify.py
+++ b/django/contrib/admin/templatetags/admin_modify.py
@@ -32,8 +32,7 @@ def submit_row(context):
save_as = context['save_as']
ctx = {
'opts': opts,
- 'show_delete_link': (not is_popup and context['has_delete_permission']
- and change and context.get('show_delete', True)),
+ '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_continue': not is_popup and context['has_change_permission'],
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index a17f875f40..f527d72f3f 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -153,10 +153,13 @@ class ForeignKeyRawIdWidget(forms.TextInput):
extra = []
if rel_to in self.admin_site._registry:
# The related object is registered with the same AdminSite
- related_url = reverse('admin:%s_%s_changelist' %
- (rel_to._meta.app_label,
- rel_to._meta.model_name),
- current_app=self.admin_site.name)
+ related_url = reverse(
+ 'admin:%s_%s_changelist' % (
+ rel_to._meta.app_label,
+ rel_to._meta.model_name,
+ ),
+ current_app=self.admin_site.name,
+ )
params = self.url_parameters()
if params:
@@ -167,10 +170,10 @@ class ForeignKeyRawIdWidget(forms.TextInput):
attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript code looks for this hook.
# TODO: "lookup_id_" is hard-coded here. This should instead use
# the correct API to determine the ID dynamically.
- extra.append(' '
- % (related_url, url, name))
- extra.append(''
- % (static('admin/img/selector-search.gif'), _('Lookup')))
+ extra.append(' ' %
+ (related_url, url, name))
+ extra.append('' %
+ (static('admin/img/selector-search.gif'), _('Lookup')))
output = [super(ForeignKeyRawIdWidget, self).render(name, value, attrs)] + extra
if value:
output.append(self.label_for_value(value))
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index b13131fc94..e3c139a5fd 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -75,7 +75,7 @@ class UserCreationForm(forms.ModelForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r'^[\w.@+-]+$',
help_text=_("Required. 30 characters or fewer. Letters, digits and "
- "@/./+/-/_ only."),
+ "@/./+/-/_ only."),
error_messages={
'invalid': _("This value may contain only letters, numbers and "
"@/./+/-/_ characters.")})
@@ -124,7 +124,7 @@ class UserChangeForm(forms.ModelForm):
username = forms.RegexField(
label=_("Username"), max_length=30, regex=r"^[\w.@+-]+$",
help_text=_("Required. 30 characters or fewer. Letters, digits and "
- "@/./+/-/_ only."),
+ "@/./+/-/_ only."),
error_messages={
'invalid': _("This value may contain only letters, numbers and "
"@/./+/-/_ characters.")})
diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py
index 1373a3c1c1..a858bb2566 100644
--- a/django/contrib/auth/tests/test_models.py
+++ b/django/contrib/auth/tests/test_models.py
@@ -69,9 +69,11 @@ class UserManagerTestCase(TestCase):
self.assertEqual(returned, 'email\ with_whitespace@d.com')
def test_empty_username(self):
- self.assertRaisesMessage(ValueError,
- 'The given username must be set',
- User.objects.create_user, username='')
+ self.assertRaisesMessage(
+ ValueError,
+ 'The given username must be set',
+ User.objects.create_user, username=''
+ )
class AbstractUserTestCase(TestCase):
diff --git a/django/contrib/flatpages/templatetags/flatpages.py b/django/contrib/flatpages/templatetags/flatpages.py
index a32ac7f490..5e7e9bdfe5 100644
--- a/django/contrib/flatpages/templatetags/flatpages.py
+++ b/django/contrib/flatpages/templatetags/flatpages.py
@@ -73,8 +73,8 @@ def get_flatpages(parser, token):
"""
bits = token.split_contents()
syntax_message = ("%(tag_name)s expects a syntax of %(tag_name)s "
- "['url_starts_with'] [for user] as context_name" %
- dict(tag_name=bits[0]))
+ "['url_starts_with'] [for user] as context_name" %
+ dict(tag_name=bits[0]))
# Must have at 3-6 bits in the tag
if len(bits) >= 3 and len(bits) <= 6:
diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py
index d0eee9324e..29e423df28 100644
--- a/django/contrib/gis/forms/fields.py
+++ b/django/contrib/gis/forms/fields.py
@@ -23,7 +23,7 @@ class GeometryField(forms.Field):
'invalid_geom': _('Invalid geometry value.'),
'invalid_geom_type': _('Invalid geometry type.'),
'transform_error': _('An error occurred when transforming the geometry '
- 'to the SRID of the geometry form field.'),
+ 'to the SRID of the geometry form field.'),
}
def __init__(self, **kwargs):
diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py
index 6b38dc593f..3d2e3046c8 100644
--- a/django/contrib/gis/gdal/prototypes/generation.py
+++ b/django/contrib/gis/gdal/prototypes/generation.py
@@ -104,7 +104,7 @@ def string_output(func, argtypes, offset=-1, str_result=False, decoding=None):
# given offset.
def _check_str(result, func, cargs):
res = check_string(result, func, cargs,
- offset=offset, str_result=str_result)
+ offset=offset, str_result=str_result)
if res and decoding:
res = res.decode(decoding)
return res
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index 059eb5b602..239067a433 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -48,9 +48,11 @@ if lib_names:
# No GEOS library could be found.
if lib_path is None:
- raise ImportError('Could not find the GEOS library (tried "%s"). '
- 'Try setting GEOS_LIBRARY_PATH in your settings.' %
- '", "'.join(lib_names))
+ raise ImportError(
+ 'Could not find the GEOS library (tried "%s"). '
+ 'Try setting GEOS_LIBRARY_PATH in your settings.' %
+ '", "'.join(lib_names)
+ )
# Getting the GEOS C library. The C interface (CDLL) is used for
# both *NIX and Windows.
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index f617f1fe76..171bd971cd 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -171,5 +171,5 @@ class Polygon(GEOSGeometry):
def kml(self):
"Returns the KML representation of this Polygon."
inner_kml = ''.join("%s" % self[i + 1].kml
- for i in xrange(self.num_interior_rings))
+ for i in xrange(self.num_interior_rings))
return "%s%s" % (self[0].kml, inner_kml)
diff --git a/django/contrib/gis/geos/tests/test_geos_mutation.py b/django/contrib/gis/geos/tests/test_geos_mutation.py
index ba95ff7582..db9f12d3b6 100644
--- a/django/contrib/gis/geos/tests/test_geos_mutation.py
+++ b/django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -117,7 +117,7 @@ class GEOSMutationTest(unittest.TestCase):
def test04_LineStringMutations(self):
'Testing LineString mutations'
for ls in (LineString((1, 0), (4, 1), (6, -1)),
- fromstr('LINESTRING (1 0,4 1,6 -1)')):
+ fromstr('LINESTRING (1 0,4 1,6 -1)')):
self.assertEqual(ls._get_single_external(1), (4.0, 1.0), 'LineString _get_single_external')
# _set_single
@@ -135,14 +135,14 @@ class GEOSMutationTest(unittest.TestCase):
def test05_Polygon(self):
'Testing Polygon mutations'
for pg in (Polygon(((1, 0), (4, 1), (6, -1), (8, 10), (1, 0)),
- ((5, 4), (6, 4), (6, 3), (5, 4))),
- fromstr('POLYGON ((1 0,4 1,6 -1,8 10,1 0),(5 4,6 4,6 3,5 4))')):
+ ((5, 4), (6, 4), (6, 3), (5, 4))),
+ fromstr('POLYGON ((1 0,4 1,6 -1,8 10,1 0),(5 4,6 4,6 3,5 4))')):
self.assertEqual(pg._get_single_external(0),
- LinearRing((1, 0), (4, 1), (6, -1), (8, 10), (1, 0)),
- 'Polygon _get_single_external(0)')
+ LinearRing((1, 0), (4, 1), (6, -1), (8, 10), (1, 0)),
+ 'Polygon _get_single_external(0)')
self.assertEqual(pg._get_single_external(1),
- LinearRing((5, 4), (6, 4), (6, 3), (5, 4)),
- 'Polygon _get_single_external(1)')
+ LinearRing((5, 4), (6, 4), (6, 3), (5, 4)),
+ 'Polygon _get_single_external(1)')
# _set_list
pg._set_list(2, (((1, 2), (10, 0), (12, 9), (-1, 15), (1, 2)),
@@ -160,7 +160,7 @@ class GEOSMutationTest(unittest.TestCase):
def test06_Collection(self):
'Testing Collection mutations'
for mp in (MultiPoint(*map(Point, ((3, 4), (-1, 2), (5, -4), (2, 8)))),
- fromstr('MULTIPOINT (3 4,-1 2,5 -4,2 8)')):
+ fromstr('MULTIPOINT (3 4,-1 2,5 -4,2 8)')):
self.assertEqual(mp._get_single_external(2), Point(5, -4), 'Collection _get_single_external')
mp._set_list(3, map(Point, ((5, 5), (3, -2), (8, 1))))
diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py
index c294ca1790..917085013d 100644
--- a/django/contrib/gis/tests/geo3d/tests.py
+++ b/django/contrib/gis/tests/geo3d/tests.py
@@ -47,9 +47,9 @@ interstate_data = (
('I-45',
'LINESTRING(-95.3708481 29.7765870 11.339,-95.3694580 29.7787980 4.536,-95.3690305 29.7797359 9.762,-95.3691886 29.7812450 12.448,-95.3696447 29.7850144 10.457,-95.3702511 29.7868518 9.418,-95.3706724 29.7881286 14.858,-95.3711632 29.7896157 15.386,-95.3714525 29.7936267 13.168,-95.3717848 29.7955007 15.104,-95.3717719 29.7969804 16.516,-95.3717305 29.7982117 13.923,-95.3717254 29.8000778 14.385,-95.3719875 29.8013539 15.160,-95.3720575 29.8026785 15.544,-95.3721321 29.8040912 14.975,-95.3722074 29.8050998 15.688,-95.3722779 29.8060430 16.099,-95.3733818 29.8076750 15.197,-95.3741563 29.8103686 17.268,-95.3749458 29.8129927 19.857,-95.3763564 29.8144557 15.435)',
(11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858,
- 15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16,
- 15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857,
- 15.435),
+ 15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16,
+ 15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857,
+ 15.435),
),
)
diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py
index 3744546ccd..2bbee70a47 100644
--- a/django/contrib/gis/tests/test_spatialrefsys.py
+++ b/django/contrib/gis/tests/test_spatialrefsys.py
@@ -23,8 +23,8 @@ test_srs = ({'srid': 4326,
'auth_srid': 32140,
'srtext': 'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980"',
'proj4_re': r'\+proj=lcc \+lat_1=30.28333333333333 \+lat_2=28.38333333333333 \+lat_0=27.83333333333333 '
- r'\+lon_0=-99 \+x_0=600000 \+y_0=4000000 (\+ellps=GRS80 )?'
- r'(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0 )?\+units=m \+no_defs ',
+ r'\+lon_0=-99 \+x_0=600000 \+y_0=4000000 (\+ellps=GRS80 )?'
+ r'(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0 )?\+units=m \+no_defs ',
'spheroid': 'GRS 1980', 'name': 'NAD83 / Texas South Central',
'geographic': False, 'projected': True, 'spatialite': False,
'ellipsoid': (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
index d0d09dee48..a318002127 100644
--- a/django/contrib/messages/storage/cookie.py
+++ b/django/contrib/messages/storage/cookie.py
@@ -39,7 +39,7 @@ class MessageDecoder(json.JSONDecoder):
return [self.process_messages(item) for item in obj]
if isinstance(obj, dict):
return dict((key, self.process_messages(value))
- for key, value in six.iteritems(obj))
+ for key, value in six.iteritems(obj))
return obj
def decode(self, s, **kwargs):
diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
index 1b1a9c0048..f3e676fac5 100644
--- a/django/contrib/messages/tests/base.py
+++ b/django/contrib/messages/tests/base.py
@@ -62,7 +62,7 @@ class BaseTests(object):
TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
MESSAGE_TAGS='',
MESSAGE_STORAGE='%s.%s' % (self.storage_class.__module__,
- self.storage_class.__name__),
+ self.storage_class.__name__),
SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer',
)
self.settings_override.enable()
@@ -164,8 +164,7 @@ class BaseTests(object):
response = self.client.post(add_url, data, follow=True)
self.assertRedirects(response, show_url)
self.assertTrue('messages' in response.context)
- messages = [Message(self.levels[level], msg) for msg in
- data['messages']]
+ messages = [Message(self.levels[level], msg) for msg in data['messages']]
self.assertEqual(list(response.context['messages']), messages)
for msg in data['messages']:
self.assertContains(response, msg)
@@ -209,8 +208,7 @@ class BaseTests(object):
show_url = reverse('django.contrib.messages.tests.urls.show')
messages = []
for level in ('debug', 'info', 'success', 'warning', 'error'):
- messages.extend([Message(self.levels[level], msg) for msg in
- data['messages']])
+ messages.extend([Message(self.levels[level], msg) for msg in data['messages']])
add_url = reverse('django.contrib.messages.tests.urls.add',
args=(level,))
self.client.post(add_url, data)
@@ -285,7 +283,7 @@ class BaseTests(object):
def get_existing_storage(self):
return self.get_storage([Message(constants.INFO, 'Test message 1'),
Message(constants.INFO, 'Test message 2',
- extra_tags='tag')])
+ extra_tags='tag')])
def test_existing_read(self):
"""
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index 66af3015bb..51a65a1fef 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -446,7 +446,7 @@ class FileSessionTests(SessionTestsMixin, unittest.TestCase):
def count_sessions():
return len([session_file for session_file in os.listdir(storage_path)
- if session_file.startswith(file_prefix)])
+ if session_file.startswith(file_prefix)])
self.assertEqual(0, count_sessions())
diff --git a/django/core/files/move.py b/django/core/files/move.py
index 8aee5afaa6..902cd1fada 100644
--- a/django/core/files/move.py
+++ b/django/core/files/move.py
@@ -68,8 +68,8 @@ def file_move_safe(old_file_name, new_file_name, chunk_size=1024 * 64, allow_ove
# first open the old file, so that it won't go away
with open(old_file_name, 'rb') as old_file:
# now open the new file, not forgetting allow_overwrite
- fd = os.open(new_file_name, os.O_WRONLY | os.O_CREAT | getattr(os, 'O_BINARY', 0) |
- (os.O_EXCL if not allow_overwrite else 0))
+ fd = os.open(new_file_name, (os.O_WRONLY | os.O_CREAT | getattr(os, 'O_BINARY', 0) |
+ (os.O_EXCL if not allow_overwrite else 0)))
try:
locks.lock(fd, locks.LOCK_EX)
current_chunk = None
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index e24193c52b..0b47e179db 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -118,8 +118,7 @@ def get_commands():
for app_name in apps:
try:
path = find_management_module(app_name)
- _commands.update(dict((name, app_name)
- for name in find_commands(path)))
+ _commands.update(dict((name, app_name) for name in find_commands(path)))
except ImportError:
pass # No management module - ignore this app
diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py
index d1ec277b63..915176e6a7 100644
--- a/django/core/management/commands/compilemessages.py
+++ b/django/core/management/commands/compilemessages.py
@@ -13,8 +13,8 @@ def has_bom(fn):
with open(fn, 'rb') as f:
sample = f.read(4)
return sample[:3] == b'\xef\xbb\xbf' or \
- sample.startswith(codecs.BOM_UTF16_LE) or \
- sample.startswith(codecs.BOM_UTF16_BE)
+ sample.startswith(codecs.BOM_UTF16_LE) or \
+ sample.startswith(codecs.BOM_UTF16_BE)
def compile_messages(stdout, locale=None):
diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index 634eb7519a..1dca15b4aa 100644
--- a/django/core/urlresolvers.py
+++ b/django/core/urlresolvers.py
@@ -131,8 +131,7 @@ def get_ns_resolver(ns_pattern, resolver):
# Build a namespaced resolver for the given parent urlconf pattern.
# This makes it possible to have captured parameters in the parent
# urlconf pattern.
- ns_resolver = RegexURLResolver(ns_pattern,
- resolver.url_patterns)
+ ns_resolver = RegexURLResolver(ns_pattern, resolver.url_patterns)
return RegexURLResolver(r'^/', [ns_resolver])
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 6a6a877b46..6078eecb20 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -390,9 +390,11 @@ WHEN (new.%(col_name)s IS NULL)
sequence_name = self._get_sequence_name(sequence_info['table'])
table_name = self.quote_name(sequence_info['table'])
column_name = self.quote_name(sequence_info['column'] or 'id')
- query = _get_sequence_reset_sql() % {'sequence': sequence_name,
- 'table': table_name,
- 'column': column_name}
+ query = _get_sequence_reset_sql() % {
+ 'sequence': sequence_name,
+ 'table': table_name,
+ 'column': column_name,
+ }
sql.append(query)
return sql
@@ -880,12 +882,10 @@ class FormatStylePlaceholderCursor(object):
def fetchmany(self, size=None):
if size is None:
size = self.arraysize
- return tuple(_rowfactory(r, self.cursor)
- for r in self.cursor.fetchmany(size))
+ return tuple(_rowfactory(r, self.cursor) for r in self.cursor.fetchmany(size))
def fetchall(self):
- return tuple(_rowfactory(r, self.cursor)
- for r in self.cursor.fetchall())
+ return tuple(_rowfactory(r, self.cursor) for r in self.cursor.fetchall())
def var(self, *args):
return VariableWrapper(self.cursor.var(*args))
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 015fc9ff3c..dd4850c3d4 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -160,9 +160,11 @@ class ModelBase(type):
new_class.add_to_class(obj_name, obj)
# All the fields of any type declared on this model
- new_fields = new_class._meta.local_fields + \
- new_class._meta.local_many_to_many + \
- new_class._meta.virtual_fields
+ new_fields = (
+ new_class._meta.local_fields +
+ new_class._meta.local_many_to_many +
+ new_class._meta.virtual_fields
+ )
field_names = set(f.name for f in new_fields)
# Basic setup for proxy models.
@@ -216,10 +218,11 @@ class ModelBase(type):
# moment).
for field in parent_fields:
if field.name in field_names:
- raise FieldError('Local field %r in class %r clashes '
- 'with field of similar name from '
- 'base class %r' %
- (field.name, name, base.__name__))
+ raise FieldError(
+ 'Local field %r in class %r clashes '
+ 'with field of similar name from '
+ 'base class %r' % (field.name, name, base.__name__)
+ )
if not base._meta.abstract:
# Concrete classes...
base = base._meta.concrete_model
@@ -253,10 +256,11 @@ class ModelBase(type):
# class
for field in base._meta.virtual_fields:
if base._meta.abstract and field.name in field_names:
- raise FieldError('Local field %r in class %r clashes '
- 'with field of similar name from '
- 'abstract base class %r' %
- (field.name, name, base.__name__))
+ raise FieldError(
+ 'Local field %r in class %r clashes '
+ 'with field of similar name from '
+ 'abstract base class %r' % (field.name, name, base.__name__)
+ )
new_class.add_to_class(field.name, copy.deepcopy(field))
if abstract:
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index fbdf67d4c5..33adaedc7e 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -603,7 +603,7 @@ class Field(object):
rel_model = self.rel.to
if hasattr(self.rel, 'get_related_field'):
lst = [(getattr(x, self.rel.get_related_field().attname),
- smart_text(x))
+ smart_text(x))
for x in rel_model._default_manager.complex_filter(
self.rel.limit_choices_to)]
else:
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 87404ed931..3eb6799a5f 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -227,12 +227,21 @@ class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescri
# If null=True, we can assign null here, but otherwise the value needs
# to be an instance of the related class.
if value is None and self.related.field.null is False:
- raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' %
- (instance._meta.object_name, self.related.get_accessor_name()))
+ raise ValueError(
+ 'Cannot assign None: "%s.%s" does not allow null values.' % (
+ instance._meta.object_name,
+ self.related.get_accessor_name(),
+ )
+ )
elif value is not None and not isinstance(value, self.related.model):
- raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' %
- (value, instance._meta.object_name,
- self.related.get_accessor_name(), self.related.opts.object_name))
+ raise ValueError(
+ 'Cannot assign "%r": "%s.%s" must be a "%s" instance.' % (
+ value,
+ instance._meta.object_name,
+ self.related.get_accessor_name(),
+ self.related.opts.object_name,
+ )
+ )
elif value is not None:
if instance._state.db is None:
instance._state.db = router.db_for_write(instance.__class__, instance=value)
@@ -244,8 +253,10 @@ class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescri
related_pk = tuple(getattr(instance, field.attname) for field in self.related.field.foreign_related_fields)
if None in related_pk:
- raise ValueError('Cannot assign "%r": "%s" instance isn\'t saved in the database.' %
- (value, instance._meta.object_name))
+ raise ValueError(
+ 'Cannot assign "%r": "%s" instance isn\'t saved in the database.' %
+ (value, instance._meta.object_name)
+ )
# Set the value of the related field to the value of the related object's related field
for index, field in enumerate(self.related.field.local_related_fields):
@@ -355,12 +366,19 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec
# If null=True, we can assign null here, but otherwise the value needs
# to be an instance of the related class.
if value is None and self.field.null is False:
- raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' %
- (instance._meta.object_name, self.field.name))
+ raise ValueError(
+ 'Cannot assign None: "%s.%s" does not allow null values.' %
+ (instance._meta.object_name, self.field.name)
+ )
elif value is not None and not isinstance(value, self.field.rel.to):
- raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' %
- (value, instance._meta.object_name,
- self.field.name, self.field.rel.to._meta.object_name))
+ raise ValueError(
+ 'Cannot assign "%r": "%s.%s" must be a "%s" instance.' % (
+ value,
+ instance._meta.object_name,
+ self.field.name,
+ self.field.rel.to._meta.object_name,
+ )
+ )
elif value is not None:
if instance._state.db is None:
instance._state.db = router.db_for_write(instance.__class__, instance=value)
@@ -706,7 +724,10 @@ def create_many_related_manager(superclass, rel):
# from the method lookup table, as we do with add and remove.
if not self.through._meta.auto_created:
opts = self.through._meta
- raise AttributeError("Cannot use create() on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name))
+ raise AttributeError(
+ "Cannot use create() on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." %
+ (opts.app_label, opts.object_name)
+ )
db = router.db_for_write(self.instance.__class__, instance=self.instance)
new_obj = super(ManyRelatedManager, self.db_manager(db)).create(**kwargs)
self.add(new_obj)
@@ -736,16 +757,23 @@ def create_many_related_manager(superclass, rel):
for obj in objs:
if isinstance(obj, self.model):
if not router.allow_relation(obj, self.instance):
- raise ValueError('Cannot add "%r": instance is on database "%s", value is on database "%s"' %
- (obj, self.instance._state.db, obj._state.db))
+ raise ValueError(
+ 'Cannot add "%r": instance is on database "%s", value is on database "%s"' %
+ (obj, self.instance._state.db, obj._state.db)
+ )
fk_val = self.through._meta.get_field(
target_field_name).get_foreign_related_value(obj)[0]
if fk_val is None:
- raise ValueError('Cannot add "%r": the value for field "%s" is None' %
- (obj, target_field_name))
+ raise ValueError(
+ 'Cannot add "%r": the value for field "%s" is None' %
+ (obj, target_field_name)
+ )
new_ids.add(fk_val)
elif isinstance(obj, Model):
- raise TypeError("'%s' instance expected, got %r" % (self.model._meta.object_name, obj))
+ raise TypeError(
+ "'%s' instance expected, got %r" %
+ (self.model._meta.object_name, obj)
+ )
else:
new_ids.add(obj)
db = router.db_for_write(self.through, instance=self.instance)
diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index b4581ce0da..21440216e0 100644
--- a/django/db/models/loading.py
+++ b/django/db/models/loading.py
@@ -276,16 +276,15 @@ class BaseAppCache(object):
try:
model_list = self._get_models_cache[cache_key]
if self.available_apps is not None and only_installed:
- model_list = [m for m in model_list
- if m._meta.app_label in self.available_apps]
+ model_list = [m for m in model_list if m._meta.app_label in self.available_apps]
+
return model_list
except KeyError:
pass
self._populate()
if app_mod:
if app_mod in self.app_store:
- app_list = [self.app_models.get(self._label_for(app_mod),
- ModelDict())]
+ app_list = [self.app_models.get(self._label_for(app_mod), ModelDict())]
else:
app_list = []
else:
@@ -304,8 +303,7 @@ class BaseAppCache(object):
)
self._get_models_cache[cache_key] = model_list
if self.available_apps is not None and only_installed:
- model_list = [m for m in model_list
- if m._meta.app_label in self.available_apps]
+ model_list = [m for m in model_list if m._meta.app_label in self.available_apps]
return model_list
def get_model(self, app_label, model_name,
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 3226f38753..48d295ccca 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -150,10 +150,10 @@ class QuerySet(object):
"""
if not isinstance(k, (slice,) + six.integer_types):
raise TypeError
- assert ((not isinstance(k, slice) and (k >= 0))
- or (isinstance(k, slice) and (k.start is None or k.start >= 0)
- and (k.stop is None or k.stop >= 0))), \
- "Negative indexing is not supported."
+ assert ((not isinstance(k, slice) and (k >= 0)) or
+ (isinstance(k, slice) and (k.start is None or k.start >= 0) and
+ (k.stop is None or k.stop >= 0))), \
+ "Negative indexing is not supported."
if self._result_cache is not None:
return self._result_cache[k]
@@ -521,7 +521,7 @@ class QuerySet(object):
that ID.
"""
assert self.query.can_filter(), \
- "Cannot use 'limit' or 'offset' with in_bulk"
+ "Cannot use 'limit' or 'offset' with in_bulk"
if not id_list:
return {}
qs = self.filter(pk__in=id_list).order_by()
@@ -532,7 +532,7 @@ class QuerySet(object):
Deletes the records in the current QuerySet.
"""
assert self.query.can_filter(), \
- "Cannot use 'limit' or 'offset' with delete."
+ "Cannot use 'limit' or 'offset' with delete."
del_query = self._clone()
@@ -569,7 +569,7 @@ class QuerySet(object):
fields to the appropriate values.
"""
assert self.query.can_filter(), \
- "Cannot update a query once a slice has been taken."
+ "Cannot update a query once a slice has been taken."
self._for_write = True
query = self.query.clone(sql.UpdateQuery)
query.add_update_values(kwargs)
@@ -587,7 +587,7 @@ class QuerySet(object):
useful at that level).
"""
assert self.query.can_filter(), \
- "Cannot update a query once a slice has been taken."
+ "Cannot update a query once a slice has been taken."
query = self.query.clone(sql.UpdateQuery)
query.add_update_fields(values)
self._result_cache = None
@@ -635,11 +635,11 @@ class QuerySet(object):
the given field_name, scoped to 'kind'.
"""
assert kind in ("year", "month", "day"), \
- "'kind' must be one of 'year', 'month' or 'day'."
+ "'kind' must be one of 'year', 'month' or 'day'."
assert order in ('ASC', 'DESC'), \
- "'order' must be either 'ASC' or 'DESC'."
+ "'order' must be either 'ASC' or 'DESC'."
return self._clone(klass=DateQuerySet, setup=True,
- _field_name=field_name, _kind=kind, _order=order)
+ _field_name=field_name, _kind=kind, _order=order)
def datetimes(self, field_name, kind, order='ASC', tzinfo=None):
"""
@@ -647,9 +647,9 @@ class QuerySet(object):
datetimes for the given field_name, scoped to 'kind'.
"""
assert kind in ("year", "month", "day", "hour", "minute", "second"), \
- "'kind' must be one of 'year', 'month', 'day', 'hour', 'minute' or 'second'."
+ "'kind' must be one of 'year', 'month', 'day', 'hour', 'minute' or 'second'."
assert order in ('ASC', 'DESC'), \
- "'order' must be either 'ASC' or 'DESC'."
+ "'order' must be either 'ASC' or 'DESC'."
if settings.USE_TZ:
if tzinfo is None:
tzinfo = timezone.get_current_timezone()
@@ -804,7 +804,7 @@ class QuerySet(object):
Returns a new QuerySet instance with the ordering changed.
"""
assert self.query.can_filter(), \
- "Cannot reorder a query once a slice has been taken."
+ "Cannot reorder a query once a slice has been taken."
obj = self._clone()
obj.query.clear_ordering(force_empty=False)
obj.query.add_ordering(*field_names)
@@ -815,7 +815,7 @@ class QuerySet(object):
Returns a new QuerySet instance that will select only distinct results.
"""
assert self.query.can_filter(), \
- "Cannot create distinct fields once a slice has been taken."
+ "Cannot create distinct fields once a slice has been taken."
obj = self._clone()
obj.query.add_distinct_fields(*field_names)
return obj
@@ -826,7 +826,7 @@ class QuerySet(object):
Adds extra SQL fragments to the query.
"""
assert self.query.can_filter(), \
- "Cannot change a query once a slice has been taken"
+ "Cannot change a query once a slice has been taken"
clone = self._clone()
clone.query.add_extra(select, select_params, where, params, tables, order_by)
return clone
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 7e48adb1d6..54d0063b9e 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -893,7 +893,7 @@ class SQLDeleteCompiler(SQLCompiler):
parameters.
"""
assert len(self.query.tables) == 1, \
- "Can only delete from one table at a time."
+ "Can only delete from one table at a time."
qn = self.quote_name_unless_alias
result = ['DELETE FROM %s' % qn(self.query.tables[0])]
where, params = self.query.where.as_sql(qn=qn, connection=self.connection)
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index db1a630a66..43026d2d82 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -452,9 +452,9 @@ class Query(object):
'rhs' query.
"""
assert self.model == rhs.model, \
- "Cannot combine queries on two different base models."
+ "Cannot combine queries on two different base models."
assert self.can_filter(), \
- "Cannot combine queries once a slice has been taken."
+ "Cannot combine queries once a slice has been taken."
assert self.distinct == rhs.distinct, \
"Cannot combine a unique query with a non-unique query."
assert self.distinct_fields == rhs.distinct_fields, \
diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py
index 8826c476f1..d040ecdbde 100644
--- a/django/dispatch/saferef.py
+++ b/django/dispatch/saferef.py
@@ -221,7 +221,7 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):
which will be passed a pointer to this object.
"""
assert getattr(target.__self__, target.__name__) == target, \
- ("method %s isn't available as the attribute %s of %s" %
+ ("method %s isn't available as the attribute %s of %s" %
(target, target.__name__, target.__self__))
super(BoundNonDescriptorMethodWeakref, self).__init__(target, onDelete)
diff --git a/django/forms/models.py b/django/forms/models.py
index 2d068eba1e..a8494360c2 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -240,8 +240,7 @@ class ModelFormMetaclass(DeclarativeFieldsMetaclass):
def __new__(mcs, name, bases, attrs):
formfield_callback = attrs.pop('formfield_callback', None)
- new_class = (super(ModelFormMetaclass, mcs)
- .__new__(mcs, name, bases, attrs))
+ new_class = super(ModelFormMetaclass, mcs).__new__(mcs, name, bases, attrs)
if bases == (BaseModelForm,):
return new_class
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index 1c64195f25..eecf6150d4 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -259,10 +259,9 @@ class MultiPartParser(object):
file_obj = handler.file_complete(counters[i])
if file_obj:
# If it returns a file object, then set the files dict.
- self._files.appendlist(force_text(old_field_name,
- self._encoding,
- errors='replace'),
- file_obj)
+ self._files.appendlist(
+ force_text(old_field_name, self._encoding, errors='replace'),
+ file_obj)
break
def IE_sanitize(self, filename):
diff --git a/django/template/base.py b/django/template/base.py
index fd87b33c5d..c314637c42 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -92,8 +92,7 @@ class VariableDoesNotExist(Exception):
self.params = params
def __str__(self):
- return self.msg % tuple(force_text(p, errors='replace')
- for p in self.params)
+ return self.msg % tuple(force_text(p, errors='replace') for p in self.params)
class InvalidTemplateLibrary(Exception):
@@ -1055,8 +1054,7 @@ class TagHelperNode(Node):
resolved_args = [var.resolve(context) for var in self.args]
if self.takes_context:
resolved_args = [context] + resolved_args
- resolved_kwargs = dict((k, v.resolve(context))
- for k, v in self.kwargs.items())
+ resolved_kwargs = dict((k, v.resolve(context)) for k, v in self.kwargs.items())
return resolved_args, resolved_kwargs
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 011d15ea65..6daf234d12 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -430,7 +430,7 @@ class URLNode(Node):
from django.core.urlresolvers import reverse, NoReverseMatch
args = [arg.resolve(context) for arg in self.args]
kwargs = dict((smart_text(k, 'ascii'), v.resolve(context))
- for k, v in self.kwargs.items())
+ for k, v in self.kwargs.items())
view_name = self.view_name.resolve(context)
@@ -525,7 +525,7 @@ class WithNode(Node):
def render(self, context):
values = dict((key, val.resolve(context)) for key, val in
- six.iteritems(self.extra_context))
+ six.iteritems(self.extra_context))
with context.push(**values):
return self.nodelist.render(context)
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index 31ba3475d3..e5e79725d2 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -117,7 +117,7 @@ class ExtendsNode(Node):
if not isinstance(node, TextNode):
if not isinstance(node, ExtendsNode):
blocks = dict((n.name, n) for n in
- compiled_parent.nodelist.get_nodes_by_type(BlockNode))
+ compiled_parent.nodelist.get_nodes_by_type(BlockNode))
block_context.add_blocks(blocks)
break
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 9e1b568191..4dbff55204 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -394,15 +394,15 @@ class SimpleTestCase(unittest.TestCase):
msg_prefix + "The field '%s' on form '%s' in"
" context %d does not contain the error '%s'"
" (actual errors: %s)" %
- (field, form, i, err, repr(field_errors)))
+ (field, form, i, err, repr(field_errors)))
elif field in context[form].fields:
self.fail(msg_prefix + "The field '%s' on form '%s'"
" in context %d contains no errors" %
- (field, form, i))
+ (field, form, i))
else:
self.fail(msg_prefix + "The form '%s' in context %d"
" does not contain the field '%s'" %
- (form, i, field))
+ (form, i, field))
else:
non_field_errors = context[form].non_field_errors()
self.assertTrue(err in non_field_errors,
@@ -452,30 +452,30 @@ class SimpleTestCase(unittest.TestCase):
msg_prefix + "The field '%s' on formset '%s', "
"form %d in context %d does not contain the "
"error '%s' (actual errors: %s)" %
- (field, formset, form_index, i, err,
- repr(field_errors)))
+ (field, formset, form_index, i, err,
+ repr(field_errors)))
elif field in context[formset].forms[form_index].fields:
self.fail(msg_prefix + "The field '%s' "
"on formset '%s', form %d in "
"context %d contains no errors" %
- (field, formset, form_index, i))
+ (field, formset, form_index, i))
else:
self.fail(msg_prefix + "The formset '%s', form %d in "
- "context %d does not contain the field '%s'" %
- (formset, form_index, i, field))
+ "context %d does not contain the field '%s'" %
+ (formset, form_index, i, field))
elif form_index is not None:
non_field_errors = context[formset].forms[form_index].non_field_errors()
self.assertFalse(len(non_field_errors) == 0,
- msg_prefix + "The formset '%s', form %d in "
- "context %d does not contain any non-field "
- "errors." % (formset, form_index, i))
+ msg_prefix + "The formset '%s', form %d in "
+ "context %d does not contain any non-field "
+ "errors." % (formset, form_index, i))
self.assertTrue(err in non_field_errors,
msg_prefix + "The formset '%s', form %d "
"in context %d does not contain the "
"non-field error '%s' "
"(actual errors: %s)" %
- (formset, form_index, i, err,
- repr(non_field_errors)))
+ (formset, form_index, i, err,
+ repr(non_field_errors)))
else:
non_form_errors = context[formset].non_form_errors()
self.assertFalse(len(non_form_errors) == 0,
@@ -486,7 +486,7 @@ class SimpleTestCase(unittest.TestCase):
msg_prefix + "The formset '%s' in context "
"%d does not contain the "
"non-form error '%s' (actual errors: %s)" %
- (formset, i, err, repr(non_form_errors)))
+ (formset, i, err, repr(non_form_errors)))
if not found_formset:
self.fail(msg_prefix + "The formset '%s' was not used to render "
"the response" % formset)
diff --git a/django/utils/archive.py b/django/utils/archive.py
index 0a95fa84a6..3e5d22ae1b 100644
--- a/django/utils/archive.py
+++ b/django/utils/archive.py
@@ -160,7 +160,7 @@ class TarArchive(BaseArchive):
# Some corrupt tar files seem to produce this
# (specifically bad symlinks)
print("In the tar file %s the member %s is invalid: %s" %
- (name, member.name, exc))
+ (name, member.name, exc))
else:
dirname = os.path.dirname(filename)
if dirname and not os.path.exists(dirname):
diff --git a/django/utils/html.py b/django/utils/html.py
index daced9a221..fe1776a1e6 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -80,8 +80,7 @@ def format_html(format_string, *args, **kwargs):
of str.format or % interpolation to build up small HTML fragments.
"""
args_safe = map(conditional_escape, args)
- kwargs_safe = dict((k, conditional_escape(v)) for (k, v) in
- six.iteritems(kwargs))
+ kwargs_safe = dict((k, conditional_escape(v)) for (k, v) in six.iteritems(kwargs))
return mark_safe(format_string.format(*args_safe, **kwargs_safe))
diff --git a/django/utils/importlib.py b/django/utils/importlib.py
index 483cea5f94..8059f16095 100644
--- a/django/utils/importlib.py
+++ b/django/utils/importlib.py
@@ -17,8 +17,7 @@ def _resolve_name(name, package, level):
try:
dot = package.rindex('.', 0, dot)
except ValueError:
- raise ValueError("attempted relative import beyond top-level "
- "package")
+ raise ValueError("attempted relative import beyond top-level package")
return "%s.%s" % (package[:dot], name)
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
index 7ad058ff11..7c46f3287f 100644
--- a/docs/_ext/djangodocs.py
+++ b/docs/_ext/djangodocs.py
@@ -344,9 +344,9 @@ class DjangoStandaloneHTMLBuilder(StandaloneHTMLBuilder):
xrefs = self.env.domaindata["std"]["objects"]
templatebuiltins = {
"ttags": [n for ((t, n), (l, a)) in xrefs.items()
- if t == "templatetag" and l == "ref/templates/builtins"],
+ if t == "templatetag" and l == "ref/templates/builtins"],
"tfilters": [n for ((t, n), (l, a)) in xrefs.items()
- if t == "templatefilter" and l == "ref/templates/builtins"],
+ if t == "templatefilter" and l == "ref/templates/builtins"],
}
outfilename = os.path.join(self.outdir, "templatebuiltins.js")
with open(outfilename, 'w') as fp:
diff --git a/setup.cfg b/setup.cfg
index 2288667cee..ac1e029e90 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8]
exclude=.git,./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./django/utils/lru_cache.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/*
-ignore=E127,E128,E501,W601
+ignore=E128,E501,W601
[metadata]
license-file = LICENSE
diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py
index 42012d201e..7381447051 100644
--- a/tests/admin_filters/tests.py
+++ b/tests/admin_filters/tests.py
@@ -243,9 +243,13 @@ class ListFiltersTests(TestCase):
self.assertEqual(force_text(filterspec.title), 'date registered')
choice = select_by(filterspec.choices(changelist), "display", "Today")
self.assertEqual(choice['selected'], True)
- self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
- '&date_registered__lt=%s'
- % (self.today, self.tomorrow))
+ self.assertEqual(
+ choice['query_string'],
+ '?date_registered__gte=%s&date_registered__lt=%s' % (
+ self.today,
+ self.tomorrow,
+ )
+ )
request = self.request_factory.get('/', {'date_registered__gte': self.today.replace(day=1),
'date_registered__lt': self.next_month})
@@ -264,9 +268,13 @@ class ListFiltersTests(TestCase):
self.assertEqual(force_text(filterspec.title), 'date registered')
choice = select_by(filterspec.choices(changelist), "display", "This month")
self.assertEqual(choice['selected'], True)
- self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
- '&date_registered__lt=%s'
- % (self.today.replace(day=1), self.next_month))
+ self.assertEqual(
+ choice['query_string'],
+ '?date_registered__gte=%s&date_registered__lt=%s' % (
+ self.today.replace(day=1),
+ self.next_month,
+ )
+ )
request = self.request_factory.get('/', {'date_registered__gte': self.today.replace(month=1, day=1),
'date_registered__lt': self.next_year})
@@ -285,12 +293,18 @@ class ListFiltersTests(TestCase):
self.assertEqual(force_text(filterspec.title), 'date registered')
choice = select_by(filterspec.choices(changelist), "display", "This year")
self.assertEqual(choice['selected'], True)
- self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
- '&date_registered__lt=%s'
- % (self.today.replace(month=1, day=1), self.next_year))
+ self.assertEqual(
+ choice['query_string'],
+ '?date_registered__gte=%s&date_registered__lt=%s' % (
+ self.today.replace(month=1, day=1),
+ self.next_year,
+ )
+ )
- request = self.request_factory.get('/', {'date_registered__gte': str(self.one_week_ago),
- 'date_registered__lt': str(self.tomorrow)})
+ request = self.request_factory.get('/', {
+ 'date_registered__gte': str(self.one_week_ago),
+ 'date_registered__lt': str(self.tomorrow),
+ })
changelist = self.get_changelist(request, Book, modeladmin)
# Make sure the correct queryset is returned
@@ -302,9 +316,13 @@ class ListFiltersTests(TestCase):
self.assertEqual(force_text(filterspec.title), 'date registered')
choice = select_by(filterspec.choices(changelist), "display", "Past 7 days")
self.assertEqual(choice['selected'], True)
- self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
- '&date_registered__lt=%s'
- % (str(self.one_week_ago), str(self.tomorrow)))
+ self.assertEqual(
+ choice['query_string'],
+ '?date_registered__gte=%s&date_registered__lt=%s' % (
+ str(self.one_week_ago),
+ str(self.tomorrow),
+ )
+ )
@override_settings(USE_TZ=True)
def test_datefieldlistfilter_with_time_zone_support(self):
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index a0319ee894..c813ee8437 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -4643,7 +4643,7 @@ class AdminViewOnSiteTests(TestCase):
# actual regression test
for error_set in response.context['inline_admin_formset'].formset.errors:
self.assertEqual(['Children must share a family name with their parents in this contrived test case'],
- error_set.get('__all__'))
+ error_set.get('__all__'))
def test_change_view_form_and_formsets_run_validation(self):
"""
@@ -4673,7 +4673,7 @@ class AdminViewOnSiteTests(TestCase):
# actual regression test
for error_set in response.context['inline_admin_formset'].formset.errors:
self.assertEqual(['Children must share a family name with their parents in this contrived test case'],
- error_set.get('__all__'))
+ error_set.get('__all__'))
def test_validate(self):
"Ensure that the view_on_site value is either a boolean or a callable"
diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py
index 92972e1edb..2dc6d9cf0c 100644
--- a/tests/defaultfilters/tests.py
+++ b/tests/defaultfilters/tests.py
@@ -59,7 +59,7 @@ class DefaultFiltersTests(TestCase):
self.assertEqual(floatformat(0, 7), '0.0000000')
self.assertEqual(floatformat(0, 10), '0.0000000000')
self.assertEqual(floatformat(0.000000000000000000015, 20),
- '0.00000000000000000002')
+ '0.00000000000000000002')
pos_inf = float(1e30000)
self.assertEqual(floatformat(pos_inf), six.text_type(pos_inf))
@@ -103,10 +103,10 @@ class DefaultFiltersTests(TestCase):
def test_addslashes(self):
self.assertEqual(addslashes('"double quotes" and \'single quotes\''),
- '\\"double quotes\\" and \\\'single quotes\\\'')
+ '\\"double quotes\\" and \\\'single quotes\\\'')
self.assertEqual(addslashes(r'\ : backslashes, too'),
- '\\\\ : backslashes, too')
+ '\\\\ : backslashes, too')
def test_capfirst(self):
self.assertEqual(capfirst('hello world'), 'Hello world')
@@ -126,14 +126,14 @@ class DefaultFiltersTests(TestCase):
def test_fix_ampersands(self):
self.assertEqual(fix_ampersands_filter('Jack & Jill & Jeroboam'),
- 'Jack & Jill & Jeroboam')
+ 'Jack & Jill & Jeroboam')
def test_linenumbers(self):
self.assertEqual(linenumbers('line 1\nline 2'),
- '1. line 1\n2. line 2')
+ '1. line 1\n2. line 2')
self.assertEqual(linenumbers('\n'.join(['x'] * 10)),
- '01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. '
- 'x\n08. x\n09. x\n10. x')
+ '01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. '
+ 'x\n08. x\n09. x\n10. x')
def test_lower(self):
self.assertEqual(lower('TEST'), 'test')
@@ -151,7 +151,7 @@ class DefaultFiltersTests(TestCase):
'jack-jill-like-numbers-123-and-4-and-silly-characters')
self.assertEqual(slugify("Un \xe9l\xe9phant \xe0 l'or\xe9e du bois"),
- 'un-elephant-a-loree-du-bois')
+ 'un-elephant-a-loree-du-bois')
def test_stringformat(self):
self.assertEqual(stringformat(1, '03d'), '001')
@@ -159,7 +159,7 @@ class DefaultFiltersTests(TestCase):
def test_title(self):
self.assertEqual(title('a nice title, isn\'t it?'),
- "A Nice Title, Isn't It?")
+ "A Nice Title, Isn't It?")
self.assertEqual(title('discoth\xe8que'), 'Discoth\xe8que')
def test_truncatewords(self):
@@ -203,14 +203,14 @@ class DefaultFiltersTests(TestCase):
def test_urlencode(self):
self.assertEqual(urlencode('fran\xe7ois & jill'),
- 'fran%C3%A7ois%20%26%20jill')
+ 'fran%C3%A7ois%20%26%20jill')
self.assertEqual(urlencode(1), '1')
def test_iriencode(self):
self.assertEqual(iriencode('S\xf8r-Tr\xf8ndelag'),
- 'S%C3%B8r-Tr%C3%B8ndelag')
+ 'S%C3%B8r-Tr%C3%B8ndelag')
self.assertEqual(iriencode(urlencode('fran\xe7ois & jill')),
- 'fran%C3%A7ois%20%26%20jill')
+ 'fran%C3%A7ois%20%26%20jill')
def test_urlizetrunc(self):
self.assertEqual(urlizetrunc('http://short.com/', 20), ' here')
@@ -402,19 +402,19 @@ class DefaultFiltersTests(TestCase):
def test_linebreaks(self):
self.assertEqual(linebreaks_filter('line 1'), 'line 1
')
self.assertEqual(linebreaks_filter('line 1\nline 2'),
- 'line 1
line 2
')
+ 'line 1
line 2
')
self.assertEqual(linebreaks_filter('line 1\rline 2'),
- 'line 1
line 2
')
+ 'line 1
line 2
')
self.assertEqual(linebreaks_filter('line 1\r\nline 2'),
- 'line 1
line 2
')
+ 'line 1
line 2
')
def test_linebreaksbr(self):
self.assertEqual(linebreaksbr('line 1\nline 2'),
- 'line 1
line 2')
+ 'line 1
line 2')
self.assertEqual(linebreaksbr('line 1\rline 2'),
- 'line 1
line 2')
+ 'line 1
line 2')
self.assertEqual(linebreaksbr('line 1\r\nline 2'),
- 'line 1
line 2')
+ 'line 1
line 2')
def test_removetags(self):
self.assertEqual(removetags('some html with