Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed all E226 violations

  • Loading branch information...
commit c347f78cc1b2a06958f692f0622deceac534dc6b 1 parent 7288e1b
Alex Gaynor authored November 03, 2013

Showing 51 changed files with 150 additions and 150 deletions. Show diff stats Hide diff stats

  1. 6  django/contrib/admin/templatetags/admin_list.py
  2. 2  django/contrib/admin/utils.py
  3. 2  django/contrib/admin/views/main.py
  4. 2  django/contrib/gis/geos/mutable_list.py
  5. 4  django/contrib/gis/geos/polygon.py
  6. 4  django/contrib/gis/geos/tests/test_geos.py
  7. 8  django/contrib/gis/geos/tests/test_mutable_list.py
  8. 10  django/contrib/gis/maps/google/zoom.py
  9. 2  django/contrib/gis/sitemaps/views.py
  10. 2  django/contrib/gis/tests/test_measure.py
  11. 2  django/contrib/gis/utils/layermapping.py
  12. 2  django/contrib/humanize/templatetags/humanize.py
  13. 4  django/core/cache/backends/base.py
  14. 2  django/core/files/base.py
  15. 2  django/core/files/images.py
  16. 2  django/core/files/move.py
  17. 2  django/core/files/uploadedfile.py
  18. 4  django/core/management/__init__.py
  19. 2  django/core/management/commands/createcachetable.py
  20. 2  django/core/urlresolvers.py
  21. 2  django/db/migrations/operations/special.py
  22. 6  django/db/migrations/optimizer.py
  23. 2  django/db/models/query.py
  24. 2  django/forms/extras/widgets.py
  25. 2  django/forms/formsets.py
  26. 2  django/forms/models.py
  27. 14  django/http/multipartparser.py
  28. 4  django/template/defaultfilters.py
  29. 4  django/template/defaulttags.py
  30. 2  django/template/smartif.py
  31. 4  django/test/runner.py
  32. 2  django/utils/dateformat.py
  33. 6  django/utils/datetime_safe.py
  34. 2  django/utils/jslex.py
  35. 2  django/utils/translation/trans_null.py
  36. 10  django/utils/translation/trans_real.py
  37. 8  django/views/debug.py
  38. 4  docs/_ext/literals_to_xrefs.py
  39. 2  extras/csrf_migration_helper.py
  40. 2  setup.cfg
  41. 2  tests/admin_filters/tests.py
  42. 8  tests/aggregation_regress/tests.py
  43. 8  tests/bulk_create/tests.py
  44. 8  tests/cache/tests.py
  45. 36  tests/defaultfilters/tests.py
  46. 2  tests/expressions/tests.py
  47. 4  tests/forms_tests/tests/test_fields.py
  48. 28  tests/lookup/tests.py
  49. 2  tests/requests/tests.py
  50. 6  tests/sites_framework/tests.py
  51. 48  tests/utils_tests/test_timesince.py
6  django/contrib/admin/templatetags/admin_list.py
@@ -34,12 +34,12 @@ def paginator_number(cl, i):
34 34
     if i == DOT:
35 35
         return '... '
36 36
     elif i == cl.page_num:
37  
-        return format_html('<span class="this-page">{0}</span> ', i+1)
  37
+        return format_html('<span class="this-page">{0}</span> ', i + 1)
38 38
     else:
39 39
         return format_html('<a href="{0}"{1}>{2}</a> ',
40 40
                            cl.get_query_string({PAGE_VAR: i}),
41  
-                           mark_safe(' class="end"' if i == cl.paginator.num_pages-1 else ''),
42  
-                           i+1)
  41
+                           mark_safe(' class="end"' if i == cl.paginator.num_pages - 1 else ''),
  42
+                           i + 1)
43 43
 
44 44
 
45 45
 @register.inclusion_tag('admin/pagination.html')
2  django/contrib/admin/utils.py
@@ -412,7 +412,7 @@ def reverse_field_path(model, path):
412 412
     for piece in pieces:
413 413
         field, model, direct, m2m = parent._meta.get_field_by_name(piece)
414 414
         # skip trailing data field if extant:
415  
-        if len(reversed_path) == len(pieces)-1:  # final iteration
  415
+        if len(reversed_path) == len(pieces) - 1:  # final iteration
416 416
             try:
417 417
                 get_model_from_relation(field)
418 418
             except NotRelationField:
2  django/contrib/admin/views/main.py
@@ -236,7 +236,7 @@ def get_results(self, request):
236 236
             result_list = self.queryset._clone()
237 237
         else:
238 238
             try:
239  
-                result_list = paginator.page(self.page_num+1).object_list
  239
+                result_list = paginator.page(self.page_num + 1).object_list
240 240
             except InvalidPage:
241 241
                 raise IncorrectLookupParameters
242 242
 
2  django/contrib/gis/geos/mutable_list.py
@@ -145,7 +145,7 @@ def __imul__(self, n):
145 145
             del self[:]
146 146
         else:
147 147
             cache = list(self)
148  
-            for i in range(n-1):
  148
+            for i in range(n - 1):
149 149
                 self.extend(cache)
150 150
         return self
151 151
 
4  django/contrib/gis/geos/polygon.py
@@ -134,7 +134,7 @@ def _get_single_internal(self, index):
134 134
             return capi.get_extring(self.ptr)
135 135
         else:
136 136
             # Getting the interior ring, have to subtract 1 from the index.
137  
-            return capi.get_intring(self.ptr, index-1)
  137
+            return capi.get_intring(self.ptr, index - 1)
138 138
 
139 139
     def _get_single_external(self, index):
140 140
         return GEOSGeometry(capi.geom_clone(self._get_single_internal(index)), srid=self.srid)
@@ -170,6 +170,6 @@ def tuple(self):
170 170
     @property
171 171
     def kml(self):
172 172
         "Returns the KML representation of this Polygon."
173  
-        inner_kml = ''.join("<innerBoundaryIs>%s</innerBoundaryIs>" % self[i+1].kml
  173
+        inner_kml = ''.join("<innerBoundaryIs>%s</innerBoundaryIs>" % self[i + 1].kml
174 174
                              for i in xrange(self.num_interior_rings))
175 175
         return "<Polygon><outerBoundaryIs>%s</outerBoundaryIs>%s</Polygon>" % (self[0].kml, inner_kml)
4  django/contrib/gis/geos/tests/test_geos.py
@@ -1081,11 +1081,11 @@ def test_linearref(self):
1081 1081
 
1082 1082
         self.assertEqual(ls.project(Point(0, 20)), 10.0)
1083 1083
         self.assertEqual(ls.project(Point(7, 6)), 24)
1084  
-        self.assertEqual(ls.project_normalized(Point(0, 20)), 1.0/3)
  1084
+        self.assertEqual(ls.project_normalized(Point(0, 20)), 1.0 / 3)
1085 1085
 
1086 1086
         self.assertEqual(ls.interpolate(10), Point(0, 10))
1087 1087
         self.assertEqual(ls.interpolate(24), Point(10, 6))
1088  
-        self.assertEqual(ls.interpolate_normalized(1.0/3), Point(0, 10))
  1088
+        self.assertEqual(ls.interpolate_normalized(1.0 / 3), Point(0, 10))
1089 1089
 
1090 1090
         self.assertEqual(mls.project(Point(0, 20)), 10)
1091 1091
         self.assertEqual(mls.project(Point(7, 6)), 16)
8  django/contrib/gis/geos/tests/test_mutable_list.py
@@ -349,8 +349,8 @@ def test_11_sorting(self):
349 349
         ul.sort()
350 350
         self.assertEqual(pl[:], ul[:], 'sort')
351 351
         mid = pl[len(pl) // 2]
352  
-        pl.sort(key=lambda x: (mid-x)**2)
353  
-        ul.sort(key=lambda x: (mid-x)**2)
  352
+        pl.sort(key=lambda x: (mid - x) ** 2)
  353
+        ul.sort(key=lambda x: (mid - x) ** 2)
354 354
         self.assertEqual(pl[:], ul[:], 'sort w/ key')
355 355
 
356 356
         pl.insert(0, pl.pop())
@@ -359,8 +359,8 @@ def test_11_sorting(self):
359 359
         ul.sort(reverse=True)
360 360
         self.assertEqual(pl[:], ul[:], 'sort w/ reverse')
361 361
         mid = pl[len(pl) // 2]
362  
-        pl.sort(key=lambda x: (mid-x)**2)
363  
-        ul.sort(key=lambda x: (mid-x)**2)
  362
+        pl.sort(key=lambda x: (mid - x) ** 2)
  363
+        ul.sort(key=lambda x: (mid - x) ** 2)
364 364
         self.assertEqual(pl[:], ul[:], 'sort w/ key')
365 365
 
366 366
     def test_12_arithmetic(self):
10  django/contrib/gis/maps/google/zoom.py
@@ -79,7 +79,7 @@ def lonlat_to_pixel(self, lonlat, zoom):
79 79
         fac = min(max(sin(DTOR * lat), -0.9999), 0.9999)
80 80
 
81 81
         # Calculating the pixel y coordinate.
82  
-        px_y = round(npix + (0.5 * log((1 + fac)/(1 - fac)) * (-1.0 * self._radpp[zoom])))
  82
+        px_y = round(npix + (0.5 * log((1 + fac) / (1 - fac)) * (-1.0 * self._radpp[zoom])))
83 83
 
84 84
         # Returning the pixel x, y to the caller of the function.
85 85
         return (px_x, px_y)
@@ -116,8 +116,8 @@ def tile(self, lonlat, zoom):
116 116
 
117 117
         # Getting the lower-left and upper-right lat/lon coordinates
118 118
         # for the bounding box of the tile.
119  
-        ll = self.pixel_to_lonlat((px[0]-delta, px[1]-delta), zoom)
120  
-        ur = self.pixel_to_lonlat((px[0]+delta, px[1]+delta), zoom)
  119
+        ll = self.pixel_to_lonlat((px[0] - delta, px[1] - delta), zoom)
  120
+        ur = self.pixel_to_lonlat((px[0] + delta, px[1] + delta), zoom)
121 121
 
122 122
         # Constructing the Polygon, representing the tile and returning.
123 123
         return Polygon(LinearRing(ll, (ll[0], ur[1]), ur, (ur[0], ll[1]), ll), srid=4326)
@@ -143,10 +143,10 @@ def get_zoom(self, geom):
143 143
             if (env_w > tile_w) or (env_h > tile_h):
144 144
                 if z == 0:
145 145
                     raise GoogleMapException('Geometry width and height should not exceed that of the Earth.')
146  
-                return z-1
  146
+                return z - 1
147 147
 
148 148
         # Otherwise, we've zoomed in to the max.
149  
-        return self._nzoom-1
  149
+        return self._nzoom - 1
150 150
 
151 151
     def get_width_height(self, extent):
152 152
         """
2  django/contrib/gis/sitemaps/views.py
@@ -32,7 +32,7 @@ def index(request, sitemaps):
32 32
         sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url))
33 33
 
34 34
         if pages > 1:
35  
-            for page in range(2, pages+1):
  35
+            for page in range(2, pages + 1):
36 36
                 sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
37 37
     xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})
38 38
     return HttpResponse(xml, content_type='application/xml')
2  django/contrib/gis/tests/test_measure.py
@@ -94,7 +94,7 @@ def testMultiplication(self):
94 94
 
95 95
         a5 = d1 * D(m=10)
96 96
         self.assertTrue(isinstance(a5, Area))
97  
-        self.assertEqual(a5.sq_m, 100*10)
  97
+        self.assertEqual(a5.sq_m, 100 * 10)
98 98
 
99 99
         with self.assertRaises(TypeError):
100 100
             d1 *= D(m=1)
2  django/contrib/gis/utils/layermapping.py
@@ -600,7 +600,7 @@ def _save(feat_range=default_range, num_feat=0, num_saved=0):
600 600
             for i, end in enumerate(indices):
601 601
                 # Constructing the slice to use for this step; the last slice is
602 602
                 # special (e.g, [100:] instead of [90:100]).
603  
-                if i+1 == n_i:
  603
+                if i + 1 == n_i:
604 604
                     step_slice = slice(beg, None)
605 605
                 else:
606 606
                     step_slice = slice(beg, end)
2  django/contrib/humanize/templatetags/humanize.py
@@ -148,7 +148,7 @@ def apnumber(value):
148 148
         return value
149 149
     if not 0 < value < 10:
150 150
         return value
151  
-    return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1]
  151
+    return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value - 1]
152 152
 
153 153
 
154 154
 # Perform the comparison in the default time zone when USE_TZ = True
4  django/core/cache/backends/base.py
@@ -233,9 +233,9 @@ def incr_version(self, key, delta=1, version=None):
233 233
         if value is None:
234 234
             raise ValueError("Key '%s' not found" % key)
235 235
 
236  
-        self.set(key, value, version=version+delta)
  236
+        self.set(key, value, version=version + delta)
237 237
         self.delete(key, version=version)
238  
-        return version+delta
  238
+        return version + delta
239 239
 
240 240
     def decr_version(self, key, delta=1, version=None):
241 241
         """Substracts delta from the cache version for the supplied key. Returns
2  django/core/files/base.py
@@ -11,7 +11,7 @@
11 11
 
12 12
 @python_2_unicode_compatible
13 13
 class File(FileProxyMixin):
14  
-    DEFAULT_CHUNK_SIZE = 64 * 2**10
  14
+    DEFAULT_CHUNK_SIZE = 64 * 2 ** 10
15 15
 
16 16
     def __init__(self, file, name=None):
17 17
         self.file = file
2  django/core/files/images.py
@@ -65,7 +65,7 @@ def get_image_dimensions(file_or_path, close=False):
65 65
                     raise
66 66
             if p.image:
67 67
                 return p.image.size
68  
-            chunk_size = chunk_size*2
  68
+            chunk_size *= 2
69 69
         return None
70 70
     finally:
71 71
         if close:
2  django/core/files/move.py
@@ -38,7 +38,7 @@ def _samefile(src, dst):
38 38
             os.path.normcase(os.path.abspath(dst)))
39 39
 
40 40
 
41  
-def file_move_safe(old_file_name, new_file_name, chunk_size=1024*64, allow_overwrite=False):
  41
+def file_move_safe(old_file_name, new_file_name, chunk_size=1024 * 64, allow_overwrite=False):
42 42
     """
43 43
     Moves a file from one location to another in the safest way possible.
44 44
 
2  django/core/files/uploadedfile.py
@@ -23,7 +23,7 @@ class UploadedFile(File):
23 23
     An ``UploadedFile`` object behaves somewhat like a file object and
24 24
     represents some file data that the user submitted with a form.
25 25
     """
26  
-    DEFAULT_CHUNK_SIZE = 64 * 2**10
  26
+    DEFAULT_CHUNK_SIZE = 64 * 2 ** 10
27 27
 
28 28
     def __init__(self, file=None, name=None, content_type=None, size=None, charset=None, content_type_extra=None):
29 29
         super(UploadedFile, self).__init__(file, name)
4  django/core/management/__init__.py
@@ -317,7 +317,7 @@ def autocomplete(self):
317 317
         cword = int(os.environ['COMP_CWORD'])
318 318
 
319 319
         try:
320  
-            curr = cwords[cword-1]
  320
+            curr = cwords[cword - 1]
321 321
         except IndexError:
322 322
             curr = ''
323 323
 
@@ -350,7 +350,7 @@ def autocomplete(self):
350 350
             options += [(s_opt.get_opt_string(), s_opt.nargs) for s_opt in
351 351
                         subcommand_cls.option_list]
352 352
             # filter out previously specified options from available options
353  
-            prev_opts = [x.split('=')[0] for x in cwords[1:cword-1]]
  353
+            prev_opts = [x.split('=')[0] for x in cwords[1:cword - 1]]
354 354
             options = [opt for opt in options if opt[0] not in prev_opts]
355 355
 
356 356
             # filter options by current input
2  django/core/management/commands/createcachetable.py
@@ -69,7 +69,7 @@ def create_table(self, database, tablename):
69 69
             table_output.append(" ".join(field_output))
70 70
         full_statement = ["CREATE TABLE %s (" % qn(tablename)]
71 71
         for i, line in enumerate(table_output):
72  
-            full_statement.append('    %s%s' % (line, ',' if i < len(table_output)-1 else ''))
  72
+            full_statement.append('    %s%s' % (line, ',' if i < len(table_output) - 1 else ''))
73 73
         full_statement.append(');')
74 74
         with transaction.commit_on_success_unless_managed():
75 75
             curs = connection.cursor()
2  django/core/urlresolvers.py
@@ -147,7 +147,7 @@ def get_mod_func(callback):
147 147
         dot = callback.rindex('.')
148 148
     except ValueError:
149 149
         return callback, ''
150  
-    return callback[:dot], callback[dot+1:]
  150
+    return callback[:dot], callback[dot + 1:]
151 151
 
152 152
 
153 153
 class LocaleRegexProvider(object):
2  django/db/migrations/operations/special.py
@@ -33,7 +33,7 @@ def database_backwards(self, app_label, schema_editor, from_state, to_state):
33 33
         base_state = to_state
34 34
         for pos, database_operation in enumerate(reversed(self.database_operations)):
35 35
             to_state = base_state.clone()
36  
-            for dbop in self.database_operations[:-(pos+1)]:
  36
+            for dbop in self.database_operations[:-(pos + 1)]:
37 37
                 dbop.state_forwards(app_label, to_state)
38 38
             from_state = base_state.clone()
39 39
             database_operation.state_forwards(app_label, from_state)
6  django/db/migrations/optimizer.py
@@ -48,13 +48,13 @@ def optimize_inner(self, operations, app_label=None):
48 48
         new_operations = []
49 49
         for i, operation in enumerate(operations):
50 50
             # Compare it to each operation after it
51  
-            for j, other in enumerate(operations[i+1:]):
  51
+            for j, other in enumerate(operations[i + 1:]):
52 52
                 result = self.reduce(operation, other)
53 53
                 if result is not None:
54 54
                     # Optimize! Add result, then remaining others, then return
55 55
                     new_operations.extend(result)
56  
-                    new_operations.extend(operations[i+1:i+1+j])
57  
-                    new_operations.extend(operations[i+j+2:])
  56
+                    new_operations.extend(operations[i + 1:i + 1 + j])
  57
+                    new_operations.extend(operations[i + j + 2:])
58 58
                     return new_operations
59 59
                 if not self.can_optimize_through(operation, other, app_label):
60 60
                     new_operations.append(operation)
2  django/db/models/query.py
@@ -1359,7 +1359,7 @@ def get_klass_info(klass, max_depth=0, cur_depth=0, requested=None,
1359 1359
                 next = requested[f.name]
1360 1360
             else:
1361 1361
                 next = None
1362  
-            klass_info = get_klass_info(f.rel.to, max_depth=max_depth, cur_depth=cur_depth+1,
  1362
+            klass_info = get_klass_info(f.rel.to, max_depth=max_depth, cur_depth=cur_depth + 1,
1363 1363
                                         requested=next, only_load=only_load)
1364 1364
             related_fields.append((f, klass_info))
1365 1365
 
2  django/forms/extras/widgets.py
@@ -62,7 +62,7 @@ def __init__(self, attrs=None, years=None, required=True, months=None):
62 62
             self.years = years
63 63
         else:
64 64
             this_year = datetime.date.today().year
65  
-            self.years = range(this_year, this_year+10)
  65
+            self.years = range(this_year, this_year + 10)
66 66
 
67 67
         # Optional dict of months to use in the "month" select box.
68 68
         if months:
2  django/forms/formsets.py
@@ -363,7 +363,7 @@ def add_fields(self, form, index):
363 363
         if self.can_order:
364 364
             # Only pre-fill the ordering field for initial forms.
365 365
             if index is not None and index < self.initial_form_count():
366  
-                form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), initial=index+1, required=False)
  366
+                form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), initial=index + 1, required=False)
367 367
             else:
368 368
                 form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), required=False)
369 369
         if self.can_delete:
2  django/forms/models.py
@@ -572,7 +572,7 @@ def _construct_form(self, i, **kwargs):
572 572
         if i >= self.initial_form_count() and self.initial_extra:
573 573
             # Set initial values for extra forms
574 574
             try:
575  
-                kwargs['initial'] = self.initial_extra[i-self.initial_form_count()]
  575
+                kwargs['initial'] = self.initial_extra[i - self.initial_form_count()]
576 576
             except IndexError:
577 577
                 pass
578 578
         return super(BaseModelFormSet, self)._construct_form(i, **kwargs)
14  django/http/multipartparser.py
@@ -94,7 +94,7 @@ def __init__(self, META, input_data, upload_handlers, encoding=None):
94 94
         # For compatibility with low-level network APIs (with 32-bit integers),
95 95
         # the chunk size should be < 2^31, but still divisible by 4.
96 96
         possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size]
97  
-        self._chunk_size = min([2**31-4] + possible_sizes)
  97
+        self._chunk_size = min([2 ** 31 - 4] + possible_sizes)
98 98
 
99 99
         self._meta = META
100 100
         self._encoding = encoding or settings.DEFAULT_CHARSET
@@ -267,7 +267,7 @@ def handle_file_complete(self, old_field_name, counters):
267 267
 
268 268
     def IE_sanitize(self, filename):
269 269
         """Cleanup filename from Internet Explorer full paths."""
270  
-        return filename and filename[filename.rfind("\\")+1:].strip()
  270
+        return filename and filename[filename.rfind("\\") + 1:].strip()
271 271
 
272 272
 
273 273
 class LazyStream(six.Iterator):
@@ -512,11 +512,11 @@ def _find_boundary(self, data, eof=False):
512 512
             end = index
513 513
             next = index + len(self._boundary)
514 514
             # backup over CRLF
515  
-            last = max(0, end-1)
516  
-            if data[last:last+1] == b'\n':
  515
+            last = max(0, end - 1)
  516
+            if data[last:last + 1] == b'\n':
517 517
                 end -= 1
518  
-            last = max(0, end-1)
519  
-            if data[last:last+1] == b'\r':
  518
+            last = max(0, end - 1)
  519
+            if data[last:last + 1] == b'\r':
520 520
                 end -= 1
521 521
             return end, next
522 522
 
@@ -623,7 +623,7 @@ def parse_header(line):
623 623
         i = p.find(b'=')
624 624
         if i >= 0:
625 625
             name = p[:i].strip().lower().decode('ascii')
626  
-            value = p[i+1:].strip()
  626
+            value = p[i + 1:].strip()
627 627
             if len(value) >= 2 and value[:1] == value[-1:] == b'"':
628 628
                 value = value[1:-1]
629 629
                 value = value.replace(b'\\\\', b'\\').replace(b'\\"', b'"')
4  django/template/defaultfilters.py
@@ -680,14 +680,14 @@ def _helper(list_, tabs=1):
680 680
                 sublist_item = title
681 681
                 title = ''
682 682
             elif i < list_length - 1:
683  
-                next_item = list_[i+1]
  683
+                next_item = list_[i + 1]
684 684
                 if next_item and isinstance(next_item, (list, tuple)):
685 685
                     # The next item is a sub-list.
686 686
                     sublist_item = next_item
687 687
                     # We've processed the next item now too.
688 688
                     i += 1
689 689
             if sublist_item:
690  
-                sublist = _helper(sublist_item, tabs+1)
  690
+                sublist = _helper(sublist_item, tabs + 1)
691 691
                 sublist = '\n%s<ul>\n%s\n%s</ul>\n%s' % (indent, sublist,
692 692
                                                          indent, indent)
693 693
             output.append('%s<li>%s%s</li>' % (indent,
4  django/template/defaulttags.py
@@ -171,7 +171,7 @@ def render(self, context):
171 171
             for i, item in enumerate(values):
172 172
                 # Shortcuts for current loop iteration number.
173 173
                 loop_dict['counter0'] = i
174  
-                loop_dict['counter'] = i+1
  174
+                loop_dict['counter'] = i + 1
175 175
                 # Reverse counter iteration numbers.
176 176
                 loop_dict['revcounter'] = len_values - i
177 177
                 loop_dict['revcounter0'] = len_values - i - 1
@@ -832,7 +832,7 @@ def do_for(parser, token):
832 832
             raise TemplateSyntaxError("'for' tag received an invalid argument:"
833 833
                                       " %s" % token.contents)
834 834
 
835  
-    sequence = parser.compile_filter(bits[in_index+1])
  835
+    sequence = parser.compile_filter(bits[in_index + 1])
836 836
     nodelist_loop = parser.parse(('empty', 'endfor',))
837 837
     token = parser.next_token()
838 838
     if token.contents == 'empty':
2  django/template/smartif.py
@@ -158,7 +158,7 @@ def __init__(self, tokens):
158 158
         i = 0
159 159
         while i < l:
160 160
             token = tokens[i]
161  
-            if token == "not" and i + 1 < l and tokens[i+1] == "in":
  161
+            if token == "not" and i + 1 < l and tokens[i + 1] == "in":
162 162
                 token = "not in"
163 163
                 i += 1  # skip 'in'
164 164
             mapped_tokens.append(self.translate_token(token))
4  django/test/runner.py
@@ -203,10 +203,10 @@ def reorder_suite(suite, classes):
203 203
     """
204 204
     class_count = len(classes)
205 205
     suite_class = type(suite)
206  
-    bins = [suite_class() for i in range(class_count+1)]
  206
+    bins = [suite_class() for i in range(class_count + 1)]
207 207
     partition_suite(suite, classes, bins)
208 208
     for i in range(class_count):
209  
-        bins[0].addTests(bins[i+1])
  209
+        bins[0].addTests(bins[i + 1])
210 210
     return bins[0]
211 211
 
212 212
 
2  django/utils/dateformat.py
@@ -303,7 +303,7 @@ def W(self):
303 303
         weekday = self.data.weekday() + 1
304 304
         day_of_year = self.z()
305 305
         if day_of_year <= (8 - jan1_weekday) and jan1_weekday > 4:
306  
-            if jan1_weekday == 5 or (jan1_weekday == 6 and calendar.isleap(self.data.year-1)):
  306
+            if jan1_weekday == 5 or (jan1_weekday == 6 and calendar.isleap(self.data.year - 1)):
307 307
                 week_number = 53
308 308
             else:
309 309
                 week_number = 52
6  django/utils/datetime_safe.py
@@ -83,8 +83,8 @@ def strftime(dt, fmt):
83 83
     s1 = time.strftime(fmt, (year,) + timetuple[1:])
84 84
     sites1 = _findall(s1, str(year))
85 85
 
86  
-    s2 = time.strftime(fmt, (year+28,) + timetuple[1:])
87  
-    sites2 = _findall(s2, str(year+28))
  86
+    s2 = time.strftime(fmt, (year + 28,) + timetuple[1:])
  87
+    sites2 = _findall(s2, str(year + 28))
88 88
 
89 89
     sites = []
90 90
     for site in sites1:
@@ -94,5 +94,5 @@ def strftime(dt, fmt):
94 94
     s = s1
95 95
     syear = "%04d" % (dt.year,)
96 96
     for site in sites:
97  
-        s = s[:site] + syear + s[site+4:]
  97
+        s = s[:site] + syear + s[site + 4:]
98 98
     return s
2  django/utils/jslex.py
@@ -25,7 +25,7 @@ def literals(choices, prefix="", suffix=""):
25 25
     individually.
26 26
 
27 27
     """
28  
-    return "|".join(prefix+re.escape(c)+suffix for c in choices.split())
  28
+    return "|".join(prefix + re.escape(c) + suffix for c in choices.split())
29 29
 
30 30
 
31 31
 class Lexer(object):
2  django/utils/translation/trans_null.py
@@ -59,7 +59,7 @@ def ugettext(message):
59 59
 def to_locale(language):
60 60
     p = language.find('-')
61 61
     if p >= 0:
62  
-        return language[:p].lower()+'_'+language[p+1:].upper()
  62
+        return language[:p].lower() + '_' + language[p + 1:].upper()
63 63
     else:
64 64
         return language.lower()
65 65
 
10  django/utils/translation/trans_real.py
@@ -55,12 +55,12 @@ def to_locale(language, to_lower=False):
55 55
     p = language.find('-')
56 56
     if p >= 0:
57 57
         if to_lower:
58  
-            return language[:p].lower()+'_'+language[p+1:].lower()
  58
+            return language[:p].lower() + '_' + language[p + 1:].lower()
59 59
         else:
60 60
             # Get correct locale for sr-latn
61  
-            if len(language[p+1:]) > 2:
62  
-                return language[:p].lower()+'_'+language[p+1].upper()+language[p+2:].lower()
63  
-            return language[:p].lower()+'_'+language[p+1:].upper()
  61
+            if len(language[p + 1:]) > 2:
  62
+                return language[:p].lower() + '_' + language[p + 1].upper() + language[p + 2:].lower()
  63
+            return language[:p].lower() + '_' + language[p + 1:].upper()
64 64
     else:
65 65
         return language.lower()
66 66
 
@@ -69,7 +69,7 @@ def to_language(locale):
69 69
     """Turns a locale name (en_US) into a language name (en-us)."""
70 70
     p = locale.find('_')
71 71
     if p >= 0:
72  
-        return locale[:p].lower()+'-'+locale[p+1:].lower()
  72
+        return locale[:p].lower() + '-' + locale[p + 1:].lower()
73 73
     else:
74 74
         return locale.lower()
75 75
 
8  django/views/debug.py
@@ -26,8 +26,8 @@ def linebreak_iter(template_source):
26 26
     yield 0
27 27
     p = template_source.find('\n')
28 28
     while p >= 0:
29  
-        yield p+1
30  
-        p = template_source.find('\n', p+1)
  29
+        yield p + 1
  30
+        p = template_source.find('\n', p + 1)
31 31
     yield len(template_source) + 1
32 32
 
33 33
 
@@ -302,7 +302,7 @@ def get_traceback_data(self):
302 302
             end = getattr(self.exc_value, 'end', None)
303 303
             if start is not None and end is not None:
304 304
                 unicode_str = self.exc_value.args[1]
305  
-                unicode_hint = smart_text(unicode_str[max(start-5, 0):min(end+5, len(unicode_str))], 'ascii', errors='replace')
  305
+                unicode_hint = smart_text(unicode_str[max(start - 5, 0):min(end + 5, len(unicode_str))], 'ascii', errors='replace')
306 306
         from django import get_version
307 307
         c = {
308 308
             'is_email': self.is_email,
@@ -419,7 +419,7 @@ def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, mod
419 419
 
420 420
         pre_context = source[lower_bound:lineno]
421 421
         context_line = source[lineno]
422  
-        post_context = source[lineno+1:upper_bound]
  422
+        post_context = source[lineno + 1:upper_bound]
423 423
 
424 424
         return lower_bound, pre_context, context_line, post_context
425 425
 
4  docs/_ext/literals_to_xrefs.py
@@ -68,8 +68,8 @@ def fixliterals(fname):
68 68
             new.append(m.group(0))
69 69
             continue
70 70
 
71  
-        sys.stdout.write("\n"+"-"*80+"\n")
72  
-        sys.stdout.write(data[prev_start+1:m.start()])
  71
+        sys.stdout.write("\n" + "-" * 80 + "\n")
  72
+        sys.stdout.write(data[prev_start + 1:m.start()])
73 73
         sys.stdout.write(colorize(m.group(0), fg="red"))
74 74
         sys.stdout.write(data[m.end():next_end])
75 75
         sys.stdout.write("\n\n")
2  extras/csrf_migration_helper.py
@@ -161,7 +161,7 @@ def make_template_info(filename, root_dirs):
161 161
     relative_filenames from the supplied filename and root template directories
162 162
     """
163 163
     return Template(filename,
164  
-                    [filename[len(d)+1:] for d in root_dirs if filename.startswith(d)])
  164
+                    [filename[len(d) + 1:] for d in root_dirs if filename.startswith(d)])
165 165
 
166 166
 
167 167
 class Template(object):
2  setup.cfg
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
4 4
 
5 5
 [flake8]
6 6
 exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/*
7  
-ignore=E124,E125,E127,E128,E226,E251,E501,W601
  7
+ignore=E124,E125,E127,E128,E251,E501,W601
8 8
 
9 9
 [metadata]
10 10
 license-file = LICENSE
2  tests/admin_filters/tests.py
@@ -61,7 +61,7 @@ def lookups(self, request, model_admin):
61 61
 class DecadeListFilterWithFailingQueryset(DecadeListFilterWithTitleAndParameter):
62 62
 
63 63
     def queryset(self, request, queryset):
64  
-        raise 1/0
  64
+        raise 1 / 0
65 65
 
66 66
 
67 67
 class DecadeListFilterWithQuerysetBasedLookups(DecadeListFilterWithTitleAndParameter):
8  tests/aggregation_regress/tests.py
@@ -346,7 +346,7 @@ def test_more(self):
346 346
     def test_aggregate_fexpr(self):
347 347
         # Aggregates can be used with F() expressions
348 348
         # ... where the F() is pushed into the HAVING clause
349  
-        qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_books__lt=F('num_awards')/2).order_by('name').values('name', 'num_books', 'num_awards')
  349
+        qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_books__lt=F('num_awards') / 2).order_by('name').values('name', 'num_books', 'num_awards')
350 350
         self.assertQuerysetEqual(
351 351
             qs, [
352 352
                 {'num_books': 1, 'name': 'Morgan Kaufmann', 'num_awards': 9},
@@ -355,7 +355,7 @@ def test_aggregate_fexpr(self):
355 355
             lambda p: p,
356 356
         )
357 357
 
358  
-        qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name', 'num_books', 'num_awards')
  358
+        qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards') / 2).order_by('name').values('name', 'num_books', 'num_awards')
359 359
         self.assertQuerysetEqual(
360 360
             qs, [
361 361
                 {'num_books': 2, 'name': 'Apress', 'num_awards': 3},
@@ -366,7 +366,7 @@ def test_aggregate_fexpr(self):
366 366
         )
367 367
 
368 368
         # ... and where the F() references an aggregate
369  
-        qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_awards__gt=2*F('num_books')).order_by('name').values('name', 'num_books', 'num_awards')
  369
+        qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_awards__gt=2 * F('num_books')).order_by('name').values('name', 'num_books', 'num_awards')
370 370
         self.assertQuerysetEqual(
371 371
             qs, [
372 372
                 {'num_books': 1, 'name': 'Morgan Kaufmann', 'num_awards': 9},
@@ -375,7 +375,7 @@ def test_aggregate_fexpr(self):
375 375
             lambda p: p,
376 376
         )
377 377
 
378  
-        qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name', 'num_books', 'num_awards')
  378
+        qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards') / 2).order_by('name').values('name', 'num_books', 'num_awards')
379 379
         self.assertQuerysetEqual(
380 380
             qs, [
381 381
                 {'num_books': 2, 'name': 'Apress', 'num_awards': 3},
8  tests/bulk_create/tests.py
@@ -94,7 +94,7 @@ def test_large_batch(self):
94 94
         with override_settings(DEBUG=True):
95 95
             connection.queries = []
96 96
             TwoFields.objects.bulk_create([
97  
-                TwoFields(f1=i, f2=i+1) for i in range(0, 1001)
  97
+                TwoFields(f1=i, f2=i + 1) for i in range(0, 1001)
98 98
             ])
99 99
         self.assertEqual(TwoFields.objects.count(), 1001)
100 100
         self.assertEqual(
@@ -115,7 +115,7 @@ def test_large_batch_efficiency(self):
115 115
         with override_settings(DEBUG=True):
116 116
             connection.queries = []
117 117
             TwoFields.objects.bulk_create([
118  
-                TwoFields(f1=i, f2=i+1) for i in range(0, 1001)
  118
+                TwoFields(f1=i, f2=i + 1) for i in range(0, 1001)
119 119
             ])
120 120
             self.assertTrue(len(connection.queries) < 10)
121 121
 
@@ -127,7 +127,7 @@ def test_large_batch_mixed(self):
127 127
         with override_settings(DEBUG=True):
128 128
             connection.queries = []
129 129
             TwoFields.objects.bulk_create([
130  
-                TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i+1)
  130
+                TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i + 1)
131 131
                 for i in range(100000, 101000)])
132 132
         self.assertEqual(TwoFields.objects.count(), 1000)
133 133
         # We can't assume much about the ID's created, except that the above
@@ -145,7 +145,7 @@ def test_large_batch_mixed_efficiency(self):
145 145
         with override_settings(DEBUG=True):
146 146
             connection.queries = []
147 147
             TwoFields.objects.bulk_create([
148  
-                TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i+1)
  148
+                TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i + 1)
149 149
                 for i in range(100000, 101000)])
150 150
             self.assertTrue(len(connection.queries) < 10)
151 151
 
8  tests/cache/tests.py
@@ -436,13 +436,13 @@ def test_long_timeout(self):
436 436
         it is an absolute expiration timestamp instead of a relative
437 437
         offset. Test that we honour this convention. Refs #12399.
438 438
         '''
439  
-        self.cache.set('key1', 'eggs', 60*60*24*30 + 1)  # 30 days + 1 second
  439
+        self.cache.set('key1', 'eggs', 60 * 60 * 24 * 30 + 1)  # 30 days + 1 second
440 440
         self.assertEqual(self.cache.get('key1'), 'eggs')
441 441
 
442  
-        self.cache.add('key2', 'ham', 60*60*24*30 + 1)
  442
+        self.cache.add('key2', 'ham', 60 * 60 * 24 * 30 + 1)
443 443
         self.assertEqual(self.cache.get('key2'), 'ham')
444 444
 
445  
-        self.cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, 60*60*24*30 + 1)
  445
+        self.cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, 60 * 60 * 24 * 30 + 1)
446 446
         self.assertEqual(self.cache.get('key3'), 'sausage')
447 447
         self.assertEqual(self.cache.get('key4'), 'lobster bisque')
448 448
 
@@ -1000,7 +1000,7 @@ def test_incr_decr_timeout(self):
1000 1000
         """incr/decr does not modify expiry time (matches memcached behavior)"""
1001 1001
         key = 'value'
1002 1002
         _key = self.cache.make_key(key)
1003  
-        self.cache.set(key, 1, timeout=self.cache.default_timeout*10)
  1003
+        self.cache.set(key, 1, timeout=self.cache.default_timeout * 10)
1004 1004
         expire = self.cache._expire_info[_key]
1005 1005
         self.cache.incr(key)
1006 1006
         self.assertEqual(expire, self.cache._expire_info[_key])
36  tests/defaultfilters/tests.py
@@ -613,15 +613,15 @@ def test_filesizeformat(self):
613 613
         # NOTE: \xa0 avoids wrapping between value and unit
614 614
         self.assertEqual(filesizeformat(1023), '1023\xa0bytes')
615 615
         self.assertEqual(filesizeformat(1024), '1.0\xa0KB')
616  
-        self.assertEqual(filesizeformat(10*1024), '10.0\xa0KB')
617  
-        self.assertEqual(filesizeformat(1024*1024-1), '1024.0\xa0KB')
618  
-        self.assertEqual(filesizeformat(1024*1024), '1.0\xa0MB')
619  
-        self.assertEqual(filesizeformat(1024*1024*50), '50.0\xa0MB')
620  
-        self.assertEqual(filesizeformat(1024*1024*1024-1), '1024.0\xa0MB')
621  
-        self.assertEqual(filesizeformat(1024*1024*1024), '1.0\xa0GB')
622  
-        self.assertEqual(filesizeformat(1024*1024*1024*1024), '1.0\xa0TB')
623  
-        self.assertEqual(filesizeformat(1024*1024*1024*1024*1024), '1.0\xa0PB')
624  
-        self.assertEqual(filesizeformat(1024*1024*1024*1024*1024*2000),
  616
+        self.assertEqual(filesizeformat(10 * 1024), '10.0\xa0KB')
  617
+        self.assertEqual(filesizeformat(1024 * 1024 - 1), '1024.0\xa0KB')
  618
+        self.assertEqual(filesizeformat(1024 * 1024), '1.0\xa0MB')
  619
+        self.assertEqual(filesizeformat(1024 * 1024 * 50), '50.0\xa0MB')
  620
+        self.assertEqual(filesizeformat(1024 * 1024 * 1024 - 1), '1024.0\xa0MB')
  621
+        self.assertEqual(filesizeformat(1024 * 1024 * 1024), '1.0\xa0GB')
  622
+        self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 1024), '1.0\xa0TB')
  623
+        self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 1024 * 1024), '1.0\xa0PB')
  624
+        self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 1024 * 1024 * 2000),
625 625
                           '2000.0\xa0PB')
626 626
         self.assertEqual(filesizeformat(complex(1, -1)), '0\xa0bytes')
627 627
         self.assertEqual(filesizeformat(""), '0\xa0bytes')
@@ -680,16 +680,16 @@ def test_localized_filesizeformat(self):
680 680
         with self.settings(USE_L10N=True), translation.override('de', deactivate=True):
681 681
             self.assertEqual(filesizeformat(1023), '1023\xa0Bytes')
682 682
             self.assertEqual(filesizeformat(1024), '1,0\xa0KB')
683  
-            self.assertEqual(filesizeformat(10*1024), '10,0\xa0KB')
684  
-            self.assertEqual(filesizeformat(1024*1024-1), '1024,0\xa0KB')
685  
-            self.assertEqual(filesizeformat(1024*1024), '1,0\xa0MB')
686  
-            self.assertEqual(filesizeformat(1024*1024*50), '50,0\xa0MB')
687  
-            self.assertEqual(filesizeformat(1024*1024*1024-1), '1024,0\xa0MB')
688  
-            self.assertEqual(filesizeformat(1024*1024*1024), '1,0\xa0GB')
689  
-            self.assertEqual(filesizeformat(1024*1024*1024*1024), '1,0\xa0TB')
690  
-            self.assertEqual(filesizeformat(1024*1024*1024*1024*1024),
  683
+            self.assertEqual(filesizeformat(10 * 1024), '10,0\xa0KB')
  684
+            self.assertEqual(filesizeformat(1024 * 1024 - 1), '1024,0\xa0KB')
  685
+            self.assertEqual(filesizeformat(1024 * 1024), '1,0\xa0MB')
  686
+            self.assertEqual(filesizeformat(1024 * 1024 * 50), '50,0\xa0MB')
  687
+            self.assertEqual(filesizeformat(1024 * 1024 * 1024 - 1), '1024,0\xa0MB')
  688
+            self.assertEqual(filesizeformat(1024 * 1024 * 1024), '1,0\xa0GB')
  689
+            self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 1024), '1,0\xa0TB')
  690
+            self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 1024 * 1024),
691 691
                               '1,0\xa0PB')
692  
-            self.assertEqual(filesizeformat(1024*1024*1024*1024*1024*2000),
  692
+            self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 1024 * 1024 * 2000),
693 693
                               '2000,0\xa0PB')
694 694
             self.assertEqual(filesizeformat(complex(1, -1)), '0\xa0Bytes')
695 695
             self.assertEqual(filesizeformat(""), '0\xa0Bytes')
2  tests/expressions/tests.py
@@ -74,7 +74,7 @@ def test_filter(self):
74 74
 
75 75
         # We can perform arithmetic operations in expressions
76 76
         # Make sure we have 2 spare chairs
77  
-        company_query.update(num_chairs=F("num_employees")+2)
  77
+        company_query.update(num_chairs=F("num_employees") + 2)
78 78
         self.assertQuerysetEqual(
79 79
             company_query, [
80 80
                 {
4  tests/forms_tests/tests/test_fields.py
@@ -760,11 +760,11 @@ def test_urlfield_1(self):
760 760
     def test_url_regex_ticket11198(self):
761 761
         f = URLField()
762 762
         # hangs "forever" if catastrophic backtracking in ticket:#11198 not fixed
763  
-        self.assertRaisesMessage(ValidationError, "'Enter a valid URL.'", f.clean, 'http://%s' % ("X"*200,))
  763
+        self.assertRaisesMessage(ValidationError, "'Enter a valid URL.'", f.clean, 'http://%s' % ("X" * 200,))
764 764
 
765 765
         # a second test, to make sure the problem is really addressed, even on
766 766
         # domains that don't fail the domain label length check in the regex
767  
-        self.assertRaisesMessage(ValidationError, "'Enter a valid URL.'", f.clean, 'http://%s' % ("X"*60,))
  767
+        self.assertRaisesMessage(ValidationError, "'Enter a valid URL.'", f.clean, 'http://%s' % ("X" * 60,))
768 768
 
769 769
     def test_urlfield_2(self):
770 770
         f = URLField(required=False)
28  tests/lookup/tests.py
@@ -283,26 +283,26 @@ def test_values_list(self):
283 283
             Article.objects.extra(select={'id_plus_one': 'id+1'})
284 284
                            .order_by('id').values_list('id_plus_one', 'id'),
285 285
             [
286  
-                (self.a1.id+1, self.a1.id),
287  
-                (self.a2.id+1, self.a2.id),
288  
-                (self.a3.id+1, self.a3.id),
289  
-                (self.a4.id+1, self.a4.id),
290  
-                (self.a5.id+1, self.a5.id),
291  
-                (self.a6.id+1, self.a6.id),
292  
-                (self.a7.id+1, self.a7.id)
  286
+                (self.a1.id + 1, self.a1.id),
  287
+                (self.a2.id + 1, self.a2.id),
  288
+                (self.a3.id + 1, self.a3.id),
  289
+                (self.a4.id + 1, self.a4.id),
  290
+                (self.a5.id + 1, self.a5.id),
  291
+                (self.a6.id + 1, self.a6.id),
  292
+                (self.a7.id + 1, self.a7.id)
293 293
             ],
294 294
             transform=identity)
295 295
         self.assertQuerysetEqual(
296 296
             Article.objects.extra(select={'id_plus_one': 'id+1'})
297 297
                            .order_by('id').values_list('id', 'id_plus_one'),
298 298
             [
299  
-                (self.a1.id, self.a1.id+1),
300  
-                (self.a2.id, self.a2.id+1),
301  
-                (self.a3.id, self.a3.id+1),
302  
-                (self.a4.id, self.a4.id+1),
303  
-                (self.a5.id, self.a5.id+1),
304  
-                (self.a6.id, self.a6.id+1),
305  
-                (self.a7.id, self.a7.id+1)
  299
+                (self.a1.id, self.a1.id + 1),
  300
+                (self.a2.id, self.a2.id + 1),
  301
+                (self.a3.id, self.a3.id + 1),
  302
+                (self.a4.id, self.a4.id + 1),
  303
+                (self.a5.id, self.a5.id + 1),
  304
+                (self.a6.id, self.a6.id + 1),
  305
+                (self.a7.id, self.a7.id + 1)
306 306
             ],
307 307
             transform=identity)
308 308
         self.assertQuerysetEqual(
2  tests/requests/tests.py
@@ -162,7 +162,7 @@ def test_max_age_expiration(self):
162 162
         response.set_cookie('max_age', max_age=10)
163 163
         max_age_cookie = response.cookies['max_age']
164 164
         self.assertEqual(max_age_cookie['max-age'], 10)
165  
-        self.assertEqual(max_age_cookie['expires'], cookie_date(time.time()+10))
  165
+        self.assertEqual(max_age_cookie['expires'], cookie_date(time.time() + 10))
166 166
 
167 167
     def test_httponly_cookie(self):
168 168
         response = HttpResponse()
6  tests/sites_framework/tests.py
@@ -9,7 +9,7 @@
9 9
 class SitesFrameworkTestCase(TestCase):
10 10
     def setUp(self):
11 11
         Site.objects.get_or_create(id=settings.SITE_ID, domain="example.com", name="example.com")
12  
-        Site.objects.create(id=settings.SITE_ID+1, domain="example2.com", name="example2.com")
  12
+        Site.objects.create(id=settings.SITE_ID + 1, domain="example2.com", name="example2.com")
13 13
 
14 14
     def test_site_fk(self):
15 15
         article = ExclusiveArticle.objects.create(title="Breaking News!", site_id=settings.SITE_ID)
@@ -18,9 +18,9 @@ def test_site_fk(self):
18 18
     def test_sites_m2m(self):
19 19
         article = SyndicatedArticle.objects.create(title="Fresh News!")
20 20
         article.sites.add(Site.objects.get(id=settings.SITE_ID))
21  
-        article.sites.add(Site.objects.get(id=settings.SITE_ID+1))
  21
+        article.sites.add(Site.objects.get(id=settings.SITE_ID + 1))
22 22
         article2 = SyndicatedArticle.objects.create(title="More News!")
23  
-        article2.sites.add(Site.objects.get(id=settings.SITE_ID+1))
  23
+        article2.sites.add(Site.objects.get(id=settings.SITE_ID + 1))
24 24
         self.assertEqual(SyndicatedArticle.on_site.all().get(), article)
25 25
 
26 26
     def test_custom_named_field(self):
48  tests/utils_tests/test_timesince.py
@@ -28,28 +28,28 @@ def test_equal_datetimes(self):
28 28
 
29 29
     def test_ignore_microseconds_and_seconds(self):
30 30
         """ Microseconds and seconds are ignored. """
31  
-        self.assertEqual(timesince(self.t, self.t+self.onemicrosecond),
  31
+        self.assertEqual(timesince(self.t, self.t + self.onemicrosecond),
32 32
             '0\xa0minutes')
33  
-        self.assertEqual(timesince(self.t, self.t+self.onesecond),
  33
+        self.assertEqual(timesince(self.t, self.t + self.onesecond),
34 34
             '0\xa0minutes')
35 35
 
36 36
     def test_other_units(self):
37 37
         """ Test other units. """
38  
-        self.assertEqual(timesince(self.t, self.t+self.oneminute),
  38
+        self.assertEqual(timesince(self.t, self.t + self.oneminute),
39 39
             '1\xa0minute')
40  
-        self.assertEqual(timesince(self.t, self.t+self.onehour), '1\xa0hour')
41  
-        self.assertEqual(timesince(self.t, self.t+self.oneday), '1\xa0day')
42  
-        self.assertEqual(timesince(self.t, self.t+self.oneweek), '1\xa0week')
43  
-        self.assertEqual(timesince(self.t, self.t+self.onemonth),
  40
+        self.assertEqual(timesince(self.t, self.t + self.onehour), '1\xa0hour')
  41
+        self.assertEqual(timesince(self.t, self.t + self.oneday), '1\xa0day')
  42
+        self.assertEqual(timesince(self.t, self.t + self.oneweek), '1\xa0week')
  43
+        self.assertEqual(timesince(self.t, self.t + self.onemonth),
44 44
             '1\xa0month')
45  
-        self.assertEqual(timesince(self.t, self.t+self.oneyear), '1\xa0year')
  45
+        self.assertEqual(timesince(self.t, self.t + self.oneyear), '1\xa0year')
46 46
 
47 47
     def test_multiple_units(self):
48 48
         """ Test multiple units. """
49 49
         self.assertEqual(timesince(self.t,
50  
-            self.t+2*self.oneday+6*self.onehour), '2\xa0days, 6\xa0hours')
  50
+            self.t + 2 * self.oneday + 6 * self.onehour), '2\xa0days, 6\xa0hours')
51 51
         self.assertEqual(timesince(self.t,
52  
-            self.t+2*self.oneweek+2*self.oneday), '2\xa0weeks, 2\xa0days')
  52
+            self.t + 2 * self.oneweek + 2 * self.oneday), '2\xa0weeks, 2\xa0days')
53 53
 
54 54
     def test_display_first_unit(self):
55 55
         """
@@ -57,42 +57,42 @@ def test_display_first_unit(self):
57 57
         displayed.
58 58
         """
59 59
         self.assertEqual(timesince(self.t,
60  
-            self.t+2*self.oneweek+3*self.onehour+4*self.oneminute),
  60
+            self.t + 2 * self.oneweek + 3 * self.onehour + 4 * self.oneminute),
61 61
             '2\xa0weeks')
62 62
 
63 63
         self.assertEqual(timesince(self.t,
64  
-            self.t+4*self.oneday+5*self.oneminute), '4\xa0days')
  64
+            self.t + 4 * self.oneday + 5 * self.oneminute), '4\xa0days')
65 65
 
66 66
     def test_display_second_before_first(self):
67 67
         """
68 68
         When the second date occurs before the first, we should always
69 69
         get 0 minutes.
70 70
         """
71  
-        self.assertEqual(timesince(self.t, self.t-self.onemicrosecond),
  71
+        self.assertEqual(timesince(self.t, self.t - self.onemicrosecond),
72 72
             '0\xa0minutes')
73  
-        self.assertEqual(timesince(self.t, self.t-self.onesecond),
  73
+        self.assertEqual(timesince(self.t, self.t - self.onesecond),
74 74
             '0\xa0minutes')
75  
-        self.assertEqual(timesince(self.t, self.t-self.oneminute),
  75
+        self.assertEqual(timesince(self.t, self.t - self.oneminute),
76 76
             '0\xa0minutes')
77  
-        self.assertEqual(timesince(self.t, self.t-self.onehour),
  77
+        self.assertEqual(timesince(self.t, self.t - self.onehour),
78 78
             '0\xa0minutes')
79  
-        self.assertEqual(timesince(self.t, self.t-self.oneday),
  79
+        self.assertEqual(timesince(self.t, self.t - self.oneday),
80 80
             '0\xa0minutes')
81  
-        self.assertEqual(timesince(self.t, self.t-self.oneweek),
  81
+        self.assertEqual(timesince(self.t, self.t - self.oneweek),
82 82
             '0\xa0minutes')
83  
-        self.assertEqual(timesince(self.t, self.t-self.onemonth),
  83
+        self.assertEqual(timesince(self.t, self.t - self.onemonth),
84 84
             '0\xa0minutes')
85  
-        self.assertEqual(timesince(self.t, self.t-self.oneyear),
  85
+        self.assertEqual(timesince(self.t, self.t - self.oneyear),
86 86
             '0\xa0minutes')
87 87
         self.assertEqual(timesince(self.t,
88  
-            self.t-2*self.oneday-6*self.onehour), '0\xa0minutes')
  88
+            self.t - 2 * self.oneday - 6 * self.onehour), '0\xa0minutes')
89 89
         self.assertEqual(timesince(self.t,
90  
-            self.t-2*self.oneweek-2*self.oneday), '0\xa0minutes')
  90
+            self.t - 2 * self.oneweek - 2 * self.oneday), '0\xa0minutes')
91 91
         self.assertEqual(timesince(self.t,
92  
-            self.t-2*self.oneweek-3*self.onehour-4*self.oneminute),
  92
+            self.t - 2 * self.oneweek - 3 * self.onehour - 4 * self.oneminute),
93 93
             '0\xa0minutes')
94 94
         self.assertEqual(timesince(self.t,
95  
-            self.t-4*self.oneday-5*self.oneminute), '0\xa0minutes')
  95
+            self.t - 4 * self.oneday - 5 * self.oneminute), '0\xa0minutes')
96 96
 
97 97
     @requires_tz_support
98 98
     def test_different_timezones(self):

0 notes on commit c347f78

Please sign in to comment.
Something went wrong with that request. Please try again.