Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed assorted flake8 errors.

  • Loading branch information...
commit b67ab75e82ec59dd4eeca119eeaf570d7c88556c 1 parent 695bc0d
Tim Graham authored

Showing 38 changed files with 92 additions and 73 deletions. Show diff stats Hide diff stats

  1. 2  django/conf/locale/id/formats.py
  2. 2  django/conf/locale/lv/formats.py
  3. 2  django/contrib/gis/admin/options.py
  4. 2  django/contrib/gis/gdal/geometries.py
  5. 2  django/contrib/gis/gdal/srs.py
  6. 2  django/contrib/gis/gdal/tests/test_geom.py
  7. 6  django/contrib/gis/geos/polygon.py
  8. 6  django/contrib/gis/geos/tests/test_geos_mutation.py
  9. 9  django/contrib/gis/geos/tests/test_mutable_list.py
  10. 2  django/contrib/gis/maps/google/gmap.py
  11. 2  django/contrib/gis/tests/distapp/tests.py
  12. 2  django/contrib/gis/tests/geoapp/tests.py
  13. 6  django/contrib/gis/tests/layermap/tests.py
  14. 14  django/contrib/gis/tests/test_geoforms.py
  15. 3  django/contrib/gis/utils/wkt.py
  16. 2  django/core/files/uploadhandler.py
  17. 2  django/core/signing.py
  18. 2  django/db/models/base.py
  19. 5  django/db/models/fields/files.py
  20. 4  django/dispatch/saferef.py
  21. 2  django/forms/fields.py
  22. 2  django/forms/widgets.py
  23. 2  django/template/context.py
  24. 2  django/templatetags/cache.py
  25. 6  django/utils/autoreload.py
  26. 2  extras/csrf_migration_helper.py
  27. 6  tests/admin_changelist/tests.py
  28. 6  tests/admin_inlines/tests.py
  29. 2  tests/admin_widgets/urls.py
  30. 18  tests/aggregation_regress/tests.py
  31. 6  tests/cache/tests.py
  32. 2  tests/expressions_regress/tests.py
  33. 2  tests/forms_tests/tests/test_formsets.py
  34. 4  tests/multiple_database/tests.py
  35. 2  tests/or_lookups/tests.py
  36. 14  tests/prefetch_related/tests.py
  37. 6  tests/queries/tests.py
  38. 4  tests/swappable_models/models.py
2  django/conf/locale/id/formats.py
@@ -12,7 +12,7 @@
12 12
 MONTH_DAY_FORMAT = 'j F'
13 13
 SHORT_DATE_FORMAT = 'd-m-Y'
14 14
 SHORT_DATETIME_FORMAT = 'd-m-Y G.i.s'
15  
-FIRST_DAY_OF_WEEK = 1 #Monday
  15
+FIRST_DAY_OF_WEEK = 1  # Monday
16 16
 
17 17
 # The *_INPUT_FORMATS strings use the Python strftime format syntax,
18 18
 # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
2  django/conf/locale/lv/formats.py
@@ -12,7 +12,7 @@
12 12
 MONTH_DAY_FORMAT = 'j. F'
13 13
 SHORT_DATE_FORMAT = r'j.m.Y'
14 14
 SHORT_DATETIME_FORMAT = 'j.m.Y H:i:s'
15  
-FIRST_DAY_OF_WEEK = 1 #Monday
  15
+FIRST_DAY_OF_WEEK = 1  # Monday
16 16
 
17 17
 # The *_INPUT_FORMATS strings use the Python strftime format syntax,
18 18
 # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
2  django/contrib/gis/admin/options.py
@@ -101,7 +101,7 @@ class OLMap(self.widget):
101 101
                       'num_zoom' : self.num_zoom,
102 102
                       'max_zoom' : self.max_zoom,
103 103
                       'min_zoom' : self.min_zoom,
104  
-                      'units' : self.units, #likely shoud get from object
  104
+                      'units' : self.units,  # likely should get from object
105 105
                       'max_resolution' : self.max_resolution,
106 106
                       'max_extent' : self.max_extent,
107 107
                       'modifiable' : self.modifiable,
2  django/contrib/gis/gdal/geometries.py
@@ -151,7 +151,7 @@ def __setstate__(self, state):
151 151
     def from_bbox(cls, bbox):
152 152
         "Constructs a Polygon from a bounding box (4-tuple)."
153 153
         x0, y0, x1, y1 = bbox
154  
-        return OGRGeometry( 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' %  (
  154
+        return OGRGeometry( 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (
155 155
                 x0, y0, x0, y1, x1, y1, x1, y0, x0, y0) )
156 156
 
157 157
     ### Geometry set-like operations ###
2  django/contrib/gis/gdal/srs.py
@@ -105,7 +105,7 @@ def __getitem__(self, target):
105 105
         doesn't exist.  Can also take a tuple as a parameter, (target, child),
106 106
         where child is the index of the attribute in the WKT.  For example:
107 107
 
108  
-        >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
  108
+        >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
109 109
         >>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
110 110
         >>> print(srs['GEOGCS'])
111 111
         WGS 84
2  django/contrib/gis/gdal/tests/test_geom.py
@@ -204,7 +204,7 @@ def test07a_polygons(self):
204 204
         "Testing Polygon objects."
205 205
 
206 206
         # Testing `from_bbox` class method
207  
-        bbox =  (-180,-90,180,90)
  207
+        bbox = (-180, -90, 180, 90)
208 208
         p = OGRGeometry.from_bbox( bbox )
209 209
         self.assertEqual(bbox, p.extent)
210 210
 
6  django/contrib/gis/geos/polygon.py
@@ -17,12 +17,14 @@ def __init__(self, *args, **kwargs):
17 17
 
18 18
         Examples of initialization, where shell, hole1, and hole2 are
19 19
         valid LinearRing geometries:
  20
+        >>> from django.contrib.gis.geos import LinearRing, Polygon
  21
+        >>> shell = hole1 = hole2 = LinearRing()
20 22
         >>> poly = Polygon(shell, hole1, hole2)
21 23
         >>> poly = Polygon(shell, (hole1, hole2))
22 24
 
23  
-        Example where a tuple parameters are used:
  25
+        >>> # Example where a tuple parameters are used:
24 26
         >>> poly = Polygon(((0, 0), (0, 10), (10, 10), (0, 10), (0, 0)),
25  
-                           ((4, 4), (4, 6), (6, 6), (6, 4), (4, 4)))
  27
+        ...                ((4, 4), (4, 6), (6, 6), (6, 4), (4, 4)))
26 28
         """
27 29
         if not args:
28 30
             raise TypeError('Must provide at least one LinearRing, or a tuple, to initialize a Polygon.')
6  django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -33,9 +33,9 @@ def api_get_extent(x): return x.extent
33 33
 def api_get_area(x): return x.area
34 34
 def api_get_length(x): return x.length
35 35
 
36  
-geos_function_tests =  [ val for name, val in vars().items()
37  
-                        if hasattr(val, '__call__')
38  
-                        and name.startswith('api_get_') ]
  36
+geos_function_tests = [val for name, val in vars().items()
  37
+                       if hasattr(val, '__call__')
  38
+                       and name.startswith('api_get_')]
39 39
 
40 40
 
41 41
 @skipUnless(HAS_GEOS, "Geos is required.")
9  django/contrib/gis/geos/tests/test_mutable_list.py
@@ -16,11 +16,14 @@ def __init__(self, i_list, *args, **kwargs):
16 16
         self._list = self._mytype(i_list)
17 17
         super(UserListA, self).__init__(*args, **kwargs)
18 18
 
19  
-    def __len__(self):  return len(self._list)
  19
+    def __len__(self):
  20
+        return len(self._list)
20 21
 
21  
-    def __str__(self):  return str(self._list)
  22
+    def __str__(self):
  23
+        return str(self._list)
22 24
 
23  
-    def __repr__(self): return repr(self._list)
  25
+    def __repr__(self):
  26
+        return repr(self._list)
24 27
 
25 28
     def _set_list(self, length, items):
26 29
         # this would work:
2  django/contrib/gis/maps/google/gmap.py
@@ -81,7 +81,7 @@ def __init__(self, key=None, api_url=None, version=None,
81 81
         # level and a center coordinate are provided with polygons/polylines,
82 82
         # no automatic determination will occur.
83 83
         self.calc_zoom = False
84  
-        if self.polygons or self.polylines  or self.markers:
  84
+        if self.polygons or self.polylines or self.markers:
85 85
             if center is None or zoom is None:
86 86
                 self.calc_zoom = True
87 87
 
2  django/contrib/gis/tests/distapp/tests.py
@@ -189,7 +189,7 @@ def test_distance_geodetic(self):
189 189
             self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol)
190 190
         if postgis:
191 191
             # PostGIS uses sphere-only distances by default, testing these as well.
192  
-            qs =  AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)
  192
+            qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)
193 193
             for i, c in enumerate(qs):
194 194
                 self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol)
195 195
 
2  django/contrib/gis/tests/geoapp/tests.py
@@ -568,7 +568,7 @@ def test_kml(self):
568 568
         # The reference KML depends on the version of PostGIS used
569 569
         # (the output stopped including altitude in 1.3.3).
570 570
         if connection.ops.spatial_version >= (1, 3, 3):
571  
-            ref_kml =  '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'
  571
+            ref_kml = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'
572 572
         else:
573 573
             ref_kml = '<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>'
574 574
 
6  django/contrib/gis/tests/layermap/tests.py
@@ -163,8 +163,10 @@ def test_layermap_unique_multigeometry_fk(self):
163 163
 
164 164
         # Passing in invalid ForeignKey mapping parameters -- must be a dictionary
165 165
         # mapping for the model the ForeignKey points to.
166  
-        bad_fk_map1 = copy(co_mapping); bad_fk_map1['state'] = 'name'
167  
-        bad_fk_map2 = copy(co_mapping); bad_fk_map2['state'] = {'nombre' : 'State'}
  166
+        bad_fk_map1 = copy(co_mapping)
  167
+        bad_fk_map1['state'] = 'name'
  168
+        bad_fk_map2 = copy(co_mapping)
  169
+        bad_fk_map2['state'] = {'nombre' : 'State'}
168 170
         self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
169 171
         self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)
170 172
 
14  django/contrib/gis/tests/test_geoforms.py
@@ -163,7 +163,7 @@ class PointForm(forms.Form):
163 163
         self.assertFalse(invalid.is_valid())
164 164
         self.assertTrue('Invalid geometry value' in str(invalid.errors))
165 165
 
166  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='point']:
  166
+        for invalid in [geo for key, geo in self.geometries.items() if key!='point']:
167 167
             self.assertFalse(PointForm(data={'p': invalid.wkt}).is_valid())
168 168
 
169 169
     def test_multipointfield(self):
@@ -176,7 +176,7 @@ class PointForm(forms.Form):
176 176
         self.assertMapWidget(form)
177 177
         self.assertFalse(PointForm().is_valid())
178 178
 
179  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='multipoint']:
  179
+        for invalid in [geo for key, geo in self.geometries.items() if key!='multipoint']:
180 180
             self.assertFalse(PointForm(data={'p': invalid.wkt}).is_valid())
181 181
 
182 182
     def test_linestringfield(self):
@@ -189,7 +189,7 @@ class LineStringForm(forms.Form):
189 189
         self.assertMapWidget(form)
190 190
         self.assertFalse(LineStringForm().is_valid())
191 191
 
192  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='linestring']:
  192
+        for invalid in [geo for key, geo in self.geometries.items() if key!='linestring']:
193 193
             self.assertFalse(LineStringForm(data={'p': invalid.wkt}).is_valid())
194 194
 
195 195
     def test_multilinestringfield(self):
@@ -202,7 +202,7 @@ class LineStringForm(forms.Form):
202 202
         self.assertMapWidget(form)
203 203
         self.assertFalse(LineStringForm().is_valid())
204 204
 
205  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='multilinestring']:
  205
+        for invalid in [geo for key, geo in self.geometries.items() if key!='multilinestring']:
206 206
             self.assertFalse(LineStringForm(data={'p': invalid.wkt}).is_valid())
207 207
 
208 208
     def test_polygonfield(self):
@@ -215,7 +215,7 @@ class PolygonForm(forms.Form):
215 215
         self.assertMapWidget(form)
216 216
         self.assertFalse(PolygonForm().is_valid())
217 217
 
218  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='polygon']:
  218
+        for invalid in [geo for key, geo in self.geometries.items() if key!='polygon']:
219 219
             self.assertFalse(PolygonForm(data={'p': invalid.wkt}).is_valid())
220 220
 
221 221
     def test_multipolygonfield(self):
@@ -228,7 +228,7 @@ class PolygonForm(forms.Form):
228 228
         self.assertMapWidget(form)
229 229
         self.assertFalse(PolygonForm().is_valid())
230 230
 
231  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='multipolygon']:
  231
+        for invalid in [geo for key, geo in self.geometries.items() if key!='multipolygon']:
232 232
             self.assertFalse(PolygonForm(data={'p': invalid.wkt}).is_valid())
233 233
 
234 234
     def test_geometrycollectionfield(self):
@@ -241,7 +241,7 @@ class GeometryForm(forms.Form):
241 241
         self.assertMapWidget(form)
242 242
         self.assertFalse(GeometryForm().is_valid())
243 243
 
244  
-        for invalid in [geom for key, geom in self.geometries.items() if key!='geometrycollection']:
  244
+        for invalid in [geo for key, geo in self.geometries.items() if key!='geometrycollection']:
245 245
             self.assertFalse(GeometryForm(data={'g': invalid.wkt}).is_valid())
246 246
 
247 247
     def test_osm_widget(self):
3  django/contrib/gis/utils/wkt.py
@@ -10,10 +10,11 @@ def precision_wkt(geom, prec):
10 10
     integer or a string).  If the precision is an integer, then the decimal
11 11
     places of coordinates WKT will be truncated to that number:
12 12
 
  13
+     >>> from django.contrib.gis.geos import Point
13 14
      >>> pnt = Point(5, 23)
14 15
      >>> pnt.wkt
15 16
      'POINT (5.0000000000000000 23.0000000000000000)'
16  
-     >>> precision(geom, 1)
  17
+     >>> precision_wkt(pnt, 1)
17 18
      'POINT (5.0 23.0)'
18 19
 
19 20
     If the precision is a string, it must be valid Python format string
2  django/core/files/uploadhandler.py
@@ -199,6 +199,8 @@ def load_handler(path, *args, **kwargs):
199 199
     Given a path to a handler, return an instance of that handler.
200 200
 
201 201
     E.g.::
  202
+        >>> from django.http import HttpRequest
  203
+        >>> request = HttpRequest()
202 204
         >>> load_handler('django.core.files.uploadhandler.TemporaryFileUploadHandler', request)
203 205
         <TemporaryFileUploadHandler object at 0x...>
204 206
 
2  django/core/signing.py
@@ -187,7 +187,7 @@ def unsign(self, value, max_age=None):
187 187
         Retrieve original value and check it wasn't signed more
188 188
         than max_age seconds ago.
189 189
         """
190  
-        result =  super(TimestampSigner, self).unsign(value)
  190
+        result = super(TimestampSigner, self).unsign(value)
191 191
         value, timestamp = result.rsplit(self.sep, 1)
192 192
         timestamp = baseconv.base62.decode(timestamp)
193 193
         if max_age is not None:
2  django/db/models/base.py
@@ -164,7 +164,7 @@ def __new__(cls, name, bases, attrs):
164 164
         # Basic setup for proxy models.
165 165
         if is_proxy:
166 166
             base = None
167  
-            for parent in [cls for cls in parents if hasattr(cls, '_meta')]:
  167
+            for parent in [kls for kls in parents if hasattr(kls, '_meta')]:
168 168
                 if parent._meta.abstract:
169 169
                     if parent._meta.fields:
170 170
                         raise TypeError("Abstract base class containing model fields not permitted for proxy model '%s'." % name)
5  django/db/models/fields/files.py
@@ -142,11 +142,14 @@ class FileDescriptor(object):
142 142
     The descriptor for the file attribute on the model instance. Returns a
143 143
     FieldFile when accessed so you can do stuff like::
144 144
 
  145
+        >>> from myapp.models import MyModel
  146
+        >>> instance = MyModel.objects.get(pk=1)
145 147
         >>> instance.file.size
146 148
 
147 149
     Assigns a file object on assignment so you can do::
148 150
 
149  
-        >>> instance.file = File(...)
  151
+        >>> with open('/tmp/hello.world', 'r') as f:
  152
+        ...     instance.file = File(f)
150 153
 
151 154
     """
152 155
     def __init__(self, field):
4  django/dispatch/saferef.py
@@ -23,7 +23,7 @@ def safeRef(target, onDelete = None):
23 23
         if target.__self__ is not None:
24 24
             # Turn a bound method into a BoundMethodWeakref instance.
25 25
             # Keep track of these instances for lookup by disconnect().
26  
-            assert hasattr(target, '__func__'), """safeRef target %r has __self__, but no __func__, don't know how to create reference"""%( target,)
  26
+            assert hasattr(target, '__func__'), """safeRef target %r has __self__, but no __func__, don't know how to create reference""" % (target,)
27 27
             reference = get_bound_method_weakref(
28 28
                 target=target,
29 29
                 onDelete=onDelete
@@ -144,7 +144,7 @@ def calculateKey( cls, target ):
144 144
 
145 145
     def __str__(self):
146 146
         """Give a friendly representation of the object"""
147  
-        return """%s( %s.%s )"""%(
  147
+        return """%s( %s.%s )""" % (
148 148
             self.__class__.__name__,
149 149
             self.selfName,
150 150
             self.funcName,
2  django/forms/fields.py
@@ -567,7 +567,7 @@ def to_python(self, data):
567 567
             raise ValidationError(self.error_messages['invalid'], code='invalid')
568 568
 
569 569
         if self.max_length is not None and len(file_name) > self.max_length:
570  
-            params =  {'max': self.max_length, 'length': len(file_name)}
  570
+            params = {'max': self.max_length, 'length': len(file_name)}
571 571
             raise ValidationError(self.error_messages['max_length'], code='max_length', params=params)
572 572
         if not file_name:
573 573
             raise ValidationError(self.error_messages['invalid'], code='invalid')
2  django/forms/widgets.py
@@ -117,7 +117,7 @@ def _media(self):
117 117
         if definition:
118 118
             extend = getattr(definition, 'extend', True)
119 119
             if extend:
120  
-                if extend == True:
  120
+                if extend is True:
121 121
                     m = base
122 122
                 else:
123 123
                     m = Media()
2  django/template/context.py
@@ -6,7 +6,7 @@
6 6
 # We need the CSRF processor no matter what the user has in their settings,
7 7
 # because otherwise it is a security vulnerability, and we can't afford to leave
8 8
 # this to human error or failure to read migration instructions.
9  
-_builtin_context_processors =  ('django.core.context_processors.csrf',)
  9
+_builtin_context_processors = ('django.core.context_processors.csrf',)
10 10
 
11 11
 class ContextPopException(Exception):
12 12
     "pop() has been called more times than push()"
2  django/templatetags/cache.py
@@ -60,4 +60,4 @@ def do_cache(parser, token):
60 60
     return CacheNode(nodelist,
61 61
         parser.compile_filter(tokens[1]),
62 62
         tokens[2], # fragment_name can't be a variable.
63  
-        [parser.compile_filter(token) for token in tokens[3:]])
  63
+        [parser.compile_filter(t) for t in tokens[3:]])
6  django/utils/autoreload.py
@@ -28,7 +28,11 @@
28 28
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 29
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
 
31  
-import os, sys, time, signal, traceback
  31
+import os
  32
+import signal
  33
+import sys
  34
+import time
  35
+import traceback
32 36
 
33 37
 try:
34 38
     from django.utils.six.moves import _thread as thread
2  extras/csrf_migration_helper.py
@@ -144,7 +144,7 @@ def get_template_dirs():
144 144
     from django.conf import settings
145 145
     dirs = set()
146 146
     if ('django.template.loaders.filesystem.load_template_source' in settings.TEMPLATE_LOADERS
147  
-        or  'django.template.loaders.filesystem.Loader' in settings.TEMPLATE_LOADERS):
  147
+        or 'django.template.loaders.filesystem.Loader' in settings.TEMPLATE_LOADERS):
148 148
         dirs.update(map(unicode, settings.TEMPLATE_DIRS))
149 149
 
150 150
     if ('django.template.loaders.app_directories.load_template_source' in settings.TEMPLATE_LOADERS
6  tests/admin_changelist/tests.py
@@ -505,7 +505,7 @@ def check_results_order(ascending=False):
505 505
             admin.site.register(UnorderedObject, UnorderedObjectAdmin)
506 506
             model_admin = UnorderedObjectAdmin(UnorderedObject, admin.site)
507 507
             counter = 0 if ascending else 51
508  
-            for page in range (0, 5):
  508
+            for page in range(0, 5):
509 509
                 request = self._mocked_authenticated_request('/unorderedobject/?p=%s' % page, superuser)
510 510
                 response = model_admin.changelist_view(request)
511 511
                 for result in response.context_data['cl'].result_list:
@@ -550,7 +550,7 @@ def check_results_order(ascending=False):
550 550
             admin.site.register(OrderedObject, OrderedObjectAdmin)
551 551
             model_admin = OrderedObjectAdmin(OrderedObject, admin.site)
552 552
             counter = 0 if ascending else 51
553  
-            for page in range (0, 5):
  553
+            for page in range(0, 5):
554 554
                 request = self._mocked_authenticated_request('/orderedobject/?p=%s' % page, superuser)
555 555
                 response = model_admin.changelist_view(request)
556 556
                 for result in response.context_data['cl'].result_list:
@@ -588,7 +588,7 @@ def test_dynamic_list_filter(self):
588 588
         user_parents = self._create_superuser('parents')
589 589
 
590 590
         # Test with user 'noparents'
591  
-        m =  DynamicListFilterChildAdmin(Child, admin.site)
  591
+        m = DynamicListFilterChildAdmin(Child, admin.site)
592 592
         request = self._mocked_authenticated_request('/child/', user_noparents)
593 593
         response = m.changelist_view(request)
594 594
         self.assertEqual(response.context_data['cl'].list_filter, ['name', 'age'])
6  tests/admin_inlines/tests.py
@@ -170,7 +170,7 @@ def test_localize_pk_shortcut(self):
170 170
         holder = Holder.objects.create(pk=123456789, dummy=42)
171 171
         inner = Inner.objects.create(pk=987654321, holder=holder, dummy=42, readonly='')
172 172
         response = self.client.get('/admin/admin_inlines/holder/%i/' % holder.id)
173  
-        inner_shortcut = 'r/%s/%s/'%(ContentType.objects.get_for_model(inner).pk, inner.pk)
  173
+        inner_shortcut = 'r/%s/%s/' % (ContentType.objects.get_for_model(inner).pk, inner.pk)
174 174
         self.assertContains(response, inner_shortcut)
175 175
 
176 176
     def test_custom_pk_shortcut(self):
@@ -182,8 +182,8 @@ def test_custom_pk_shortcut(self):
182 182
         child1 = ChildModel1.objects.create(my_own_pk="bar", name="Bar", parent=parent)
183 183
         child2 = ChildModel2.objects.create(my_own_pk="baz", name="Baz", parent=parent)
184 184
         response = self.client.get('/admin/admin_inlines/parentmodelwithcustompk/foo/')
185  
-        child1_shortcut = 'r/%s/%s/'%(ContentType.objects.get_for_model(child1).pk, child1.pk)
186  
-        child2_shortcut = 'r/%s/%s/'%(ContentType.objects.get_for_model(child2).pk, child2.pk)
  185
+        child1_shortcut = 'r/%s/%s/' % (ContentType.objects.get_for_model(child1).pk, child1.pk)
  186
+        child2_shortcut = 'r/%s/%s/' % (ContentType.objects.get_for_model(child2).pk, child2.pk)
187 187
         self.assertContains(response, child1_shortcut)
188 188
         self.assertContains(response, child2_shortcut)
189 189
 
2  tests/admin_widgets/urls.py
... ...
@@ -1,6 +1,6 @@
1 1
 from django.conf.urls import patterns, include
2 2
 
3  
-from . import  widgetadmin
  3
+from . import widgetadmin
4 4
 
5 5
 
6 6
 urlpatterns = patterns('',
18  tests/aggregation_regress/tests.py
@@ -1017,20 +1017,20 @@ def test_aggregation_with_generic_reverse_relation(self):
1017 1017
 
1018 1018
         tests aggregations with generic reverse relations
1019 1019
         """
1020  
-        b = Book.objects.get(name='Practical Django Projects')
1021  
-        ItemTag.objects.create(object_id=b.id, tag='intermediate',
1022  
-                content_type=ContentType.objects.get_for_model(b))
1023  
-        ItemTag.objects.create(object_id=b.id, tag='django',
1024  
-                content_type=ContentType.objects.get_for_model(b))
  1020
+        django_book = Book.objects.get(name='Practical Django Projects')
  1021
+        ItemTag.objects.create(object_id=django_book.id, tag='intermediate',
  1022
+                content_type=ContentType.objects.get_for_model(django_book))
  1023
+        ItemTag.objects.create(object_id=django_book.id, tag='django',
  1024
+                content_type=ContentType.objects.get_for_model(django_book))
1025 1025
         # Assign a tag to model with same PK as the book above. If the JOIN
1026 1026
         # used in aggregation doesn't have content type as part of the
1027 1027
         # condition the annotation will also count the 'hi mom' tag for b.
1028  
-        wmpk = WithManualPK.objects.create(id=b.pk)
  1028
+        wmpk = WithManualPK.objects.create(id=django_book.pk)
1029 1029
         ItemTag.objects.create(object_id=wmpk.id, tag='hi mom',
1030 1030
                 content_type=ContentType.objects.get_for_model(wmpk))
1031  
-        b = Book.objects.get(name__startswith='Paradigms of Artificial Intelligence')
1032  
-        ItemTag.objects.create(object_id=b.id, tag='intermediate',
1033  
-                content_type=ContentType.objects.get_for_model(b))
  1031
+        ai_book = Book.objects.get(name__startswith='Paradigms of Artificial Intelligence')
  1032
+        ItemTag.objects.create(object_id=ai_book.id, tag='intermediate',
  1033
+                content_type=ContentType.objects.get_for_model(ai_book))
1034 1034
 
1035 1035
         self.assertEqual(Book.objects.aggregate(Count('tags')), {'tags__count': 3})
1036 1036
         results = Book.objects.annotate(Count('tags')).order_by('-tags__count', 'name')
6  tests/cache/tests.py
@@ -149,7 +149,7 @@ def test_unicode(self):
149 149
             'ascii': 'ascii_value',
150 150
             'unicode_ascii': 'Iñtërnâtiônàlizætiøn1',
151 151
             'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2',
152  
-            'ascii2': {'x' : 1 }
  152
+            'ascii2': {'x' : 1}
153 153
             }
154 154
         for (key, value) in stuff.items():
155 155
             self.cache.set(key, value)
@@ -434,7 +434,7 @@ def test_long_timeout(self):
434 434
         it is an absolute expiration timestamp instead of a relative
435 435
         offset. Test that we honour this convention. Refs #12399.
436 436
         '''
437  
-        self.cache.set('key1', 'eggs', 60*60*24*30 + 1) #30 days + 1 second
  437
+        self.cache.set('key1', 'eggs', 60*60*24*30 + 1)  # 30 days + 1 second
438 438
         self.assertEqual(self.cache.get('key1'), 'eggs')
439 439
 
440 440
         self.cache.add('key2', 'ham', 60*60*24*30 + 1)
@@ -1432,7 +1432,7 @@ def test_cache_key_i18n_timezone(self):
1432 1432
         self.assertEqual(key, key2)
1433 1433
 
1434 1434
     @override_settings(USE_I18N=False, USE_L10N=False)
1435  
-    def test_cache_key_no_i18n (self):
  1435
+    def test_cache_key_no_i18n(self):
1436 1436
         request = self._get_request()
1437 1437
         lang = translation.get_language()
1438 1438
         tz = force_text(timezone.get_current_timezone_name(), errors='ignore')
2  tests/expressions_regress/tests.py
@@ -367,7 +367,7 @@ def test_delta_invalid_op_div(self):
367 367
     def test_delta_invalid_op_mod(self):
368 368
         raised = False
369 369
         try:
370  
-            r = repr(Experiment.objects.filter(end__lt=F('start')%self.deltas[0]))
  370
+            r = repr(Experiment.objects.filter(end__lt=F('start') % self.deltas[0]))
371 371
         except TypeError:
372 372
             raised = True
373 373
         self.assertTrue(raised, "TypeError not raised on attempt to modulo divide datetime by timedelta.")
2  tests/forms_tests/tests/test_formsets.py
@@ -1071,7 +1071,7 @@ class CheckForm(Form):
1071 1071
 
1072 1072
     def test_formset_total_error_count(self):
1073 1073
         """A valid formset should have 0 total errors."""
1074  
-        data = [ #  formset_data, expected error count
  1074
+        data = [  # formset_data, expected error count
1075 1075
             ([('Calexico', '100')], 0),
1076 1076
             ([('Calexico', '')], 1),
1077 1077
             ([('', 'invalid')], 2),
4  tests/multiple_database/tests.py
@@ -113,7 +113,7 @@ def test_basic_queries(self):
113 113
         dive = Book.objects.using('other').create(title="Dive into Python",
114 114
                                                   published=datetime.date(2009, 5, 4))
115 115
 
116  
-        dive =  Book.objects.using('other').get(published=datetime.date(2009, 5, 4))
  116
+        dive = Book.objects.using('other').get(published=datetime.date(2009, 5, 4))
117 117
         self.assertEqual(dive.title, "Dive into Python")
118 118
         self.assertRaises(Book.DoesNotExist, Book.objects.using('default').get, published=datetime.date(2009, 5, 4))
119 119
 
@@ -125,7 +125,7 @@ def test_basic_queries(self):
125 125
         self.assertEqual(dive.title, "Dive into Python")
126 126
         self.assertRaises(Book.DoesNotExist, Book.objects.using('default').get, title__iexact="dive INTO python")
127 127
 
128  
-        dive =  Book.objects.using('other').get(published__year=2009)
  128
+        dive = Book.objects.using('other').get(published__year=2009)
129 129
         self.assertEqual(dive.title, "Dive into Python")
130 130
         self.assertEqual(dive.published, datetime.date(2009, 5, 4))
131 131
         self.assertRaises(Book.DoesNotExist, Book.objects.using('default').get, published__year=2009)
2  tests/or_lookups/tests.py
@@ -24,7 +24,7 @@ def setUp(self):
24 24
 
25 25
     def test_filter_or(self):
26 26
         self.assertQuerysetEqual(
27  
-            Article.objects.filter(headline__startswith='Hello') |  Article.objects.filter(headline__startswith='Goodbye'), [
  27
+            Article.objects.filter(headline__startswith='Hello') | Article.objects.filter(headline__startswith='Goodbye'), [
28 28
                 'Hello',
29 29
                 'Goodbye',
30 30
                 'Hello and goodbye'
14  tests/prefetch_related/tests.py
@@ -321,9 +321,9 @@ def test_nullable_GFK(self):
@@ -509,8 +509,8 @@ def test_traverse_nullable(self):
@@ -522,8 +522,8 @@ def test_prefetch_nullable(self):
6  tests/queries/tests.py
@@ -1558,7 +1558,9 @@ def test_ticket7256(self):
1558 1558
         # extra()
1559 1559
         qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'})
1560 1560
         dicts = qs.values().order_by('id')
1561  
-        for d in dicts: del d['id']; del d['author_id']
  1561
+        for d in dicts:
  1562
+            del d['id']
  1563
+            del d['author_id']
1562 1564
         self.assertEqual(
1563 1565
             [sorted(d.items()) for d in dicts],
1564 1566
             [[('good', 0), ('rank', 2)], [('good', 0), ('rank', 1)], [('good', 1), ('rank', 3)]]
@@ -2668,7 +2670,7 @@ def test_ticket_17886(self):
2668 2670
         # problem here was that b__name generates a LOUTER JOIN, then
2669 2671
         # b__c__name generates join to c, which the ORM tried to promote but
2670 2672
         # failed as that join isn't nullable.
2671  
-        q_obj =  (
  2673
+        q_obj = (
2672 2674
             Q(d__name='foo')|
2673 2675
             Q(b__name='foo')|
2674 2676
             Q(b__c__name='foo')
4  tests/swappable_models/models.py
@@ -2,7 +2,7 @@
2 2
 
3 3
 
4 4
 class Article(models.Model):
5  
-    title =  models.CharField(max_length=100)
  5
+    title = models.CharField(max_length=100)
6 6
     publication_date = models.DateField()
7 7
 
8 8
     class Meta:
@@ -10,6 +10,6 @@ class Meta:
10 10
 
11 11
 
12 12
 class AlternateArticle(models.Model):
13  
-    title =  models.CharField(max_length=100)
  13
+    title = models.CharField(max_length=100)
14 14
     publication_date = models.DateField()
15 15
     byline = models.CharField(max_length=100)

0 notes on commit b67ab75

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