Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start attacking E231 violations

  • Loading branch information...
commit 9bf5610890530ce5db9af7ef89ae5b8612f46a94 1 parent 382d324
@alex alex authored
Showing with 92 additions and 90 deletions.
  1. +1 −1  django/conf/urls/__init__.py
  2. +1 −1  django/contrib/admin/templatetags/admin_list.py
  3. +2 −2 django/contrib/auth/tests/urls.py
  4. +1 −1  django/contrib/flatpages/tests/test_csrf.py
  5. +2 −2 django/contrib/flatpages/tests/test_middleware.py
  6. +1 −1  django/contrib/flatpages/tests/test_views.py
  7. +3 −3 django/contrib/formtools/tests/tests.py
  8. +1 −1  django/contrib/gis/admin/widgets.py
  9. +2 −2 django/contrib/gis/db/models/query.py
  10. +1 −1  django/contrib/gis/forms/widgets.py
  11. +8 −8 django/contrib/gis/gdal/tests/test_ds.py
  12. +7 −7 django/contrib/gis/gdal/tests/test_srs.py
  13. +1 −1  django/contrib/gis/geos/mutable_list.py
  14. +8 −8 django/contrib/gis/geos/tests/test_geos.py
  15. +17 −17 django/contrib/gis/geos/tests/test_geos_mutation.py
  16. +2 −2 django/contrib/gis/geos/tests/test_mutable_list.py
  17. +10 −10 django/contrib/gis/measure.py
  18. +1 −1  django/contrib/sitemaps/__init__.py
  19. +1 −1  django/core/cache/backends/filebased.py
  20. +1 −1  django/core/files/locks.py
  21. +1 −1  django/core/files/move.py
  22. +5 −3 django/core/files/uploadhandler.py
  23. +1 −1  django/core/mail/backends/filebased.py
  24. +1 −1  django/dispatch/saferef.py
  25. +1 −1  django/forms/models.py
  26. +1 −1  django/forms/widgets.py
  27. +1 −1  django/template/defaultfilters.py
  28. +1 −1  tests/admin_views/admin.py
  29. +3 −3 tests/aggregation/tests.py
  30. +1 −1  tests/inspectdb/tests.py
  31. +5 −5 tests/validation/tests.py
View
2  django/conf/urls/__init__.py
@@ -50,7 +50,7 @@ def patterns(prefix, *args):
return pattern_list
def url(regex, view, kwargs=None, name=None, prefix=''):
- if isinstance(view, (list,tuple)):
+ if isinstance(view, (list, tuple)):
# For include(...) processing.
urlconf_module, app_name, namespace = view
return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace)
View
2  django/contrib/admin/templatetags/admin_list.py
@@ -26,7 +26,7 @@
DOT = '.'
@register.simple_tag
-def paginator_number(cl,i):
+def paginator_number(cl, i):
"""
Generates an individual page index link in a paginated list.
"""
View
4 django/contrib/auth/tests/urls.py
@@ -27,13 +27,13 @@ def auth_processor_no_attr_access(request):
RequestContext(request, {}, processors=[context_processors.auth]))
# *After* rendering, we check whether the session was accessed
return render_to_response('context_processors/auth_attrs_test_access.html',
- {'session_accessed':request.session.accessed})
+ {'session_accessed': request.session.accessed})
def auth_processor_attr_access(request):
render_to_response('context_processors/auth_attrs_access.html',
RequestContext(request, {}, processors=[context_processors.auth]))
return render_to_response('context_processors/auth_attrs_test_access.html',
- {'session_accessed':request.session.accessed})
+ {'session_accessed': request.session.accessed})
def auth_processor_user(request):
return render_to_response('context_processors/auth_attrs_user.html',
View
2  django/contrib/flatpages/tests/test_csrf.py
@@ -45,7 +45,7 @@ def test_view_authenticated_flatpage(self):
response = self.client.get('/flatpage_root/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit')
- self.client.login(username='testuser',password='s3krit')
+ self.client.login(username='testuser', password='s3krit')
response = self.client.get('/flatpage_root/sekrit/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
View
4 django/contrib/flatpages/tests/test_middleware.py
@@ -43,7 +43,7 @@ def test_view_authenticated_flatpage(self):
response = self.client.get('/flatpage_root/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit')
- self.client.login(username='testuser',password='s3krit')
+ self.client.login(username='testuser', password='s3krit')
response = self.client.get('/flatpage_root/sekrit/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
@@ -65,7 +65,7 @@ def test_fallback_authenticated_flatpage(self):
response = self.client.get('/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit')
- self.client.login(username='testuser',password='s3krit')
+ self.client.login(username='testuser', password='s3krit')
response = self.client.get('/sekrit/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
View
2  django/contrib/flatpages/tests/test_views.py
@@ -43,7 +43,7 @@ def test_view_authenticated_flatpage(self):
response = self.client.get('/flatpage_root/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit')
- self.client.login(username='testuser',password='s3krit')
+ self.client.login(username='testuser', password='s3krit')
response = self.client.get('/flatpage_root/sekrit/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
View
6 django/contrib/formtools/tests/tests.py
@@ -119,7 +119,7 @@ def test_bool_submit(self):
``bool1``. We need to make sure the hashes are the same in both cases.
"""
- self.test_data.update({'stage':2})
+ self.test_data.update({'stage': 2})
hash = self.preview.security_hash(None, TestForm(self.test_data))
self.test_data.update({'hash': hash, 'bool1': 'False'})
with warnings.catch_warnings(record=True):
@@ -133,7 +133,7 @@ def test_form_submit_good_hash(self):
"""
# Pass strings for form submittal and add stage variable to
# show we previously saw first stage of the form.
- self.test_data.update({'stage':2})
+ self.test_data.update({'stage': 2})
response = self.client.post('/preview/', self.test_data)
self.assertNotEqual(response.content, success_string_encoded)
hash = utils.form_hmac(TestForm(self.test_data))
@@ -148,7 +148,7 @@ def test_form_submit_bad_hash(self):
"""
# Pass strings for form submittal and add stage variable to
# show we previously saw first stage of the form.
- self.test_data.update({'stage':2})
+ self.test_data.update({'stage': 2})
response = self.client.post('/preview/', self.test_data)
self.assertEqual(response.status_code, 200)
self.assertNotEqual(response.content, success_string_encoded)
View
2  django/contrib/gis/admin/widgets.py
@@ -53,7 +53,7 @@ def render(self, name, value, attrs=None):
self.params['name'] = name
# note: we must switch out dashes for underscores since js
# functions are created using the module variable
- js_safe_name = self.params['name'].replace('-','_')
+ js_safe_name = self.params['name'].replace('-', '_')
self.params['module'] = 'geodjango_%s' % js_safe_name
if value:
View
4 django/contrib/gis/db/models/query.py
@@ -286,7 +286,7 @@ def reverse_geom(self, **kwargs):
Reverses the coordinate order of the geometry, and attaches as a
`reverse` attribute on each element of this GeoQuerySet.
"""
- s = {'select_field' : GeomField(),}
+ s = {'select_field': GeomField()}
kwargs.setdefault('model_att', 'reverse_geom')
if connections[self.db].ops.oracle:
s['geo_field_type'] = LineStringField
@@ -733,7 +733,7 @@ def _geom_attribute(self, func, tolerance=0.05, **kwargs):
DRY routine for setting up a GeoQuerySet method that attaches a
Geometry attribute (e.g., `centroid`, `point_on_surface`).
"""
- s = {'select_field' : GeomField(),}
+ s = {'select_field': GeomField()}
if connections[self.db].ops.oracle:
s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s'
s['procedure_args'] = {'tolerance' : tolerance}
View
2  django/contrib/gis/forms/widgets.py
@@ -68,7 +68,7 @@ def render(self, name, value, attrs=None):
context = self.build_attrs(attrs,
name=name,
- module='geodjango_%s' % name.replace('-','_'), # JS-safe
+ module='geodjango_%s' % name.replace('-', '_'), # JS-safe
serialized=self.serialize(value),
geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
STATIC_URL=settings.STATIC_URL,
View
16 django/contrib/gis/gdal/tests/test_ds.py
@@ -12,20 +12,20 @@
# List of acceptable data sources.
ds_list = (
TestDS('test_point', nfeat=5, nfld=3, geom='POINT', gtype=1, driver='ESRI Shapefile',
- fields={'dbl' : OFTReal, 'int' : OFTInteger, 'str' : OFTString,},
- extent=(-1.35011,0.166623,-0.524093,0.824508), # Got extent from QGIS
+ fields={'dbl': OFTReal, 'int': OFTInteger, 'str': OFTString},
+ extent=(-1.35011, 0.166623, -0.524093, 0.824508), # Got extent from QGIS
srs_wkt='GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]',
- field_values={'dbl' : [float(i) for i in range(1, 6)], 'int' : list(range(1, 6)), 'str' : [str(i) for i in range(1, 6)]},
+ field_values={'dbl': [float(i) for i in range(1, 6)], 'int': list(range(1, 6)), 'str': [str(i) for i in range(1, 6)]},
fids=range(5)),
TestDS('test_vrt', ext='vrt', nfeat=3, nfld=3, geom='POINT', gtype='Point25D', driver='VRT',
- fields={'POINT_X' : OFTString, 'POINT_Y' : OFTString, 'NUM' : OFTString}, # VRT uses CSV, which all types are OFTString.
+ fields={'POINT_X': OFTString, 'POINT_Y': OFTString, 'NUM': OFTString}, # VRT uses CSV, which all types are OFTString.
extent=(1.0, 2.0, 100.0, 523.5), # Min/Max from CSV
- field_values={'POINT_X' : ['1.0', '5.0', '100.0'], 'POINT_Y' : ['2.0', '23.0', '523.5'], 'NUM' : ['5', '17', '23']},
- fids=range(1,4)),
+ field_values={'POINT_X': ['1.0', '5.0', '100.0'], 'POINT_Y': ['2.0', '23.0', '523.5'], 'NUM': ['5', '17', '23']},
+ fids=range(1, 4)),
TestDS('test_poly', nfeat=3, nfld=3, geom='POLYGON', gtype=3,
driver='ESRI Shapefile',
- fields={'float' : OFTReal, 'int' : OFTInteger, 'str' : OFTString,},
- extent=(-1.01513,-0.558245,0.161876,0.839637), # Got extent from QGIS
+ fields={'float': OFTReal, 'int': OFTInteger, 'str': OFTString},
+ extent=(-1.01513, -0.558245, 0.161876, 0.839637), # Got extent from QGIS
srs_wkt='GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'),
)
View
14 django/contrib/gis/gdal/tests/test_srs.py
@@ -18,20 +18,20 @@ def __init__(self, wkt, **kwargs):
proj='+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ',
epsg=4326, projected=False, geographic=True, local=False,
lin_name='unknown', ang_name='degree', lin_units=1.0, ang_units=0.0174532925199,
- auth={'GEOGCS' : ('EPSG', '4326'), 'spheroid' : ('EPSG', '7030')},
- attr=(('DATUM', 'WGS_1984'), (('SPHEROID', 1), '6378137'),('primem|authority', 'EPSG'),),
+ auth={'GEOGCS': ('EPSG', '4326'), 'spheroid': ('EPSG', '7030')},
+ attr=(('DATUM', 'WGS_1984'), (('SPHEROID', 1), '6378137'), ('primem|authority', 'EPSG'),),
),
TestSRS('PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",30.28333333333333],PARAMETER["standard_parallel_2",28.38333333333333],PARAMETER["latitude_of_origin",27.83333333333333],PARAMETER["central_meridian",-99],PARAMETER["false_easting",600000],PARAMETER["false_northing",4000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32140"]]',
proj=None, epsg=32140, projected=True, geographic=False, local=False,
lin_name='metre', ang_name='degree', lin_units=1.0, ang_units=0.0174532925199,
- auth={'PROJCS' : ('EPSG', '32140'), 'spheroid' : ('EPSG', '7019'), 'unit' : ('EPSG', '9001'),},
- attr=(('DATUM', 'North_American_Datum_1983'),(('SPHEROID', 2), '298.257222101'),('PROJECTION','Lambert_Conformal_Conic_2SP'),),
+ auth={'PROJCS': ('EPSG', '32140'), 'spheroid': ('EPSG', '7019'), 'unit': ('EPSG', '9001')},
+ attr=(('DATUM', 'North_American_Datum_1983'), (('SPHEROID', 2), '298.257222101'), ('PROJECTION', 'Lambert_Conformal_Conic_2SP'),),
),
TestSRS('PROJCS["NAD_1983_StatePlane_Texas_South_Central_FIPS_4204_Feet",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",1968500.0],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-99.0],PARAMETER["Standard_Parallel_1",28.38333333333333],PARAMETER["Standard_Parallel_2",30.28333333333334],PARAMETER["Latitude_Of_Origin",27.83333333333333],UNIT["Foot_US",0.3048006096012192]]',
proj=None, epsg=None, projected=True, geographic=False, local=False,
lin_name='Foot_US', ang_name='Degree', lin_units=0.3048006096012192, ang_units=0.0174532925199,
- auth={'PROJCS' : (None, None),},
- attr=(('PROJCS|GeOgCs|spheroid', 'GRS_1980'),(('projcs', 9), 'UNIT'), (('projcs', 11), None),),
+ auth={'PROJCS': (None, None)},
+ attr=(('PROJCS|GeOgCs|spheroid', 'GRS_1980'), (('projcs', 9), 'UNIT'), (('projcs', 11), None),),
),
# This is really ESRI format, not WKT -- but the import should work the same
TestSRS('LOCAL_CS["Non-Earth (Meter)",LOCAL_DATUM["Local Datum",0],UNIT["Meter",1.0],AXIS["X",EAST],AXIS["Y",NORTH]]',
@@ -46,7 +46,7 @@ def __init__(self, wkt, **kwargs):
TestSRS('GEOGCS["WGS 72",DATUM["WGS_1972",SPHEROID["WGS 72",6378135,298.26,AUTHORITY["EPSG","7043"]],AUTHORITY["EPSG","6322"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4322"]]', wk='WGS72', name='WGS 72', attrs=(('GEOGCS|AUTHORITY', 1, '4322'), ('SPHEROID', 'WGS 72'))),
TestSRS('GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.9786982138982,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]]', wk='NAD27', name='NAD27', attrs=(('GEOGCS|AUTHORITY', 1, '4267'), ('SPHEROID', 'Clarke 1866'))),
TestSRS('GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]', wk='NAD83', name='NAD83', attrs=(('GEOGCS|AUTHORITY', 1, '4269'), ('SPHEROID', 'GRS 1980'))),
- TestSRS('PROJCS["NZGD49 / Karamea Circuit",GEOGCS["NZGD49",DATUM["New_Zealand_Geodetic_Datum_1949",SPHEROID["International 1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993],AUTHORITY["EPSG","6272"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4272"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",-41.28991152777778],PARAMETER["central_meridian",172.1090281944444],PARAMETER["scale_factor",1],PARAMETER["false_easting",300000],PARAMETER["false_northing",700000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","27216"]]', wk='EPSG:27216', name='NZGD49 / Karamea Circuit', attrs=(('PROJECTION','Transverse_Mercator'), ('SPHEROID', 'International 1924'))),
+ TestSRS('PROJCS["NZGD49 / Karamea Circuit",GEOGCS["NZGD49",DATUM["New_Zealand_Geodetic_Datum_1949",SPHEROID["International 1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993],AUTHORITY["EPSG","6272"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4272"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",-41.28991152777778],PARAMETER["central_meridian",172.1090281944444],PARAMETER["scale_factor",1],PARAMETER["false_easting",300000],PARAMETER["false_northing",700000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","27216"]]', wk='EPSG:27216', name='NZGD49 / Karamea Circuit', attrs=(('PROJECTION', 'Transverse_Mercator'), ('SPHEROID', 'International 1924'))),
)
bad_srlist = ('Foobar', 'OOJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",30.28333333333333],PARAMETER["standard_parallel_2",28.38333333333333],PARAMETER["latitude_of_origin",27.83333333333333],PARAMETER["central_meridian",-99],PARAMETER["false_easting",600000],PARAMETER["false_northing",4000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32140"]]',)
View
2  django/contrib/gis/geos/mutable_list.py
@@ -223,7 +223,7 @@ def reverse(self):
def sort(self, cmp=None, key=None, reverse=False):
"Standard list sort method"
if key:
- temp = [(key(v),v) for v in self]
+ temp = [(key(v), v) for v in self]
temp.sort(key=lambda x: x[0], reverse=reverse)
self[:] = [v[1] for v in temp]
else:
View
16 django/contrib/gis/geos/tests/test_geos.py
@@ -757,17 +757,17 @@ def test_threed(self):
"Testing three-dimensional geometries."
# Testing a 3D Point
pnt = Point(2, 3, 8)
- self.assertEqual((2.,3.,8.), pnt.coords)
- self.assertRaises(TypeError, pnt.set_coords, (1.,2.))
- pnt.coords = (1.,2.,3.)
- self.assertEqual((1.,2.,3.), pnt.coords)
+ self.assertEqual((2., 3., 8.), pnt.coords)
+ self.assertRaises(TypeError, pnt.set_coords, (1., 2.))
+ pnt.coords = (1., 2., 3.)
+ self.assertEqual((1., 2., 3.), pnt.coords)
# Testing a 3D LineString
ls = LineString((2., 3., 8.), (50., 250., -117.))
- self.assertEqual(((2.,3.,8.), (50.,250.,-117.)), ls.tuple)
- self.assertRaises(TypeError, ls.__setitem__, 0, (1.,2.))
- ls[0] = (1.,2.,3.)
- self.assertEqual((1.,2.,3.), ls[0])
+ self.assertEqual(((2., 3., 8.), (50., 250., -117.)), ls.tuple)
+ self.assertRaises(TypeError, ls.__setitem__, 0, (1., 2.))
+ ls[0] = (1., 2., 3.)
+ self.assertEqual((1., 2., 3.), ls[0])
def test_distance(self):
"Testing the distance() function."
View
34 django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -14,7 +14,7 @@
if HAS_GEOS:
def api_get_distance(x):
- return x.distance(Point(-200,-200))
+ return x.distance(Point(-200, -200))
def api_get_buffer(x):
return x.buffer(10)
@@ -69,24 +69,24 @@ class GEOSMutationTest(unittest.TestCase):
def test00_GEOSIndexException(self):
'Testing Geometry GEOSIndexError'
- p = Point(1,2)
- for i in range(-2,2):
+ p = Point(1, 2)
+ for i in range(-2, 2):
p._checkindex(i)
self.assertRaises(GEOSIndexError, p._checkindex, 2)
self.assertRaises(GEOSIndexError, p._checkindex, -3)
def test01_PointMutations(self):
'Testing Point mutations'
- for p in (Point(1,2,3), fromstr('POINT (1 2 3)')):
+ for p in (Point(1, 2, 3), fromstr('POINT (1 2 3)')):
self.assertEqual(p._get_single_external(1), 2.0, 'Point _get_single_external')
# _set_single
- p._set_single(0,100)
- self.assertEqual(p.coords, (100.0,2.0,3.0), 'Point _set_single')
+ p._set_single(0, 100)
+ self.assertEqual(p.coords, (100.0, 2.0, 3.0), 'Point _set_single')
# _set_list
- p._set_list(2,(50,3141))
- self.assertEqual(p.coords, (50.0,3141.0), 'Point _set_list')
+ p._set_list(2, (50, 3141))
+ self.assertEqual(p.coords, (50.0, 3141.0), 'Point _set_list')
def test02_PointExceptions(self):
'Testing Point exceptions'
@@ -95,25 +95,25 @@ def test02_PointExceptions(self):
def test03_PointApi(self):
'Testing Point API'
- q = Point(4,5,3)
- for p in (Point(1,2,3), fromstr('POINT (1 2 3)')):
- p[0:2] = [4,5]
+ q = Point(4, 5, 3)
+ for p in (Point(1, 2, 3), fromstr('POINT (1 2 3)')):
+ p[0:2] = [4, 5]
for f in geos_function_tests:
self.assertEqual(f(q), f(p), 'Point ' + f.__name__)
def test04_LineStringMutations(self):
'Testing LineString mutations'
- for ls in (LineString((1,0),(4,1),(6,-1)),
+ for ls in (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')
+ self.assertEqual(ls._get_single_external(1), (4.0, 1.0), 'LineString _get_single_external')
# _set_single
- ls._set_single(0,(-50,25))
- self.assertEqual(ls.coords, ((-50.0,25.0),(4.0,1.0),(6.0,-1.0)), 'LineString _set_single')
+ ls._set_single(0, (-50, 25))
+ self.assertEqual(ls.coords, ((-50.0, 25.0),(4.0, 1.0),(6.0, -1.0)), 'LineString _set_single')
# _set_list
- ls._set_list(2, ((-50.0,25.0),(6.0,-1.0)))
- self.assertEqual(ls.coords, ((-50.0,25.0),(6.0,-1.0)), 'LineString _set_list')
+ ls._set_list(2, ((-50.0, 25.0), (6.0, -1.0)))
+ self.assertEqual(ls.coords, ((-50.0, 25.0), (6.0, -1.0)), 'LineString _set_list')
lsa = LineString(ls.coords)
for f in geos_function_tests:
View
4 django/contrib/gis/geos/tests/test_mutable_list.py
@@ -320,7 +320,7 @@ def test09_iterable_check(self):
def setfcn(x, i, v):
x[i] = v
- self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), 2)
+ self.assertRaises(TypeError, setfcn, ul, slice(0, 3, 2), 2)
def test10_checkindex(self):
'Index check'
@@ -374,7 +374,7 @@ def test_12_arithmetic(self):
self.assertEqual(pl[:], ul[:], 'in-place add')
self.assertEqual(objid, id(ul), 'in-place add id')
- for n in (-1,0,1,3):
+ for n in (-1, 0, 1, 3):
pl, ul = self.lists_of_len()
self.assertEqual(list(pl * n), list(ul * n), 'mul by %d' % n)
self.assertEqual(type(ul), type(ul * n), 'type of mul by %d result' % n)
View
20 django/contrib/gis/measure.py
@@ -103,42 +103,42 @@ def __add__(self, other):
return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard + other.standard)})
else:
- raise TypeError('%(class)s must be added with %(class)s' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be added with %(class)s' % {"class": pretty_name(self)})
def __iadd__(self, other):
if isinstance(other, self.__class__):
self.standard += other.standard
return self
else:
- raise TypeError('%(class)s must be added with %(class)s' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be added with %(class)s' % {"class": pretty_name(self)})
def __sub__(self, other):
if isinstance(other, self.__class__):
return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard - other.standard)})
else:
- raise TypeError('%(class)s must be subtracted from %(class)s' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be subtracted from %(class)s' % {"class": pretty_name(self)})
def __isub__(self, other):
if isinstance(other, self.__class__):
self.standard -= other.standard
return self
else:
- raise TypeError('%(class)s must be subtracted from %(class)s' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be subtracted from %(class)s' % {"class": pretty_name(self)})
def __mul__(self, other):
if isinstance(other, NUMERIC_TYPES):
return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard * other)})
else:
- raise TypeError('%(class)s must be multiplied with number' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be multiplied with number' % {"class": pretty_name(self)})
def __imul__(self, other):
if isinstance(other, NUMERIC_TYPES):
self.standard *= float(other)
return self
else:
- raise TypeError('%(class)s must be multiplied with number' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be multiplied with number' % {"class": pretty_name(self)})
def __rmul__(self, other):
return self * other
@@ -150,7 +150,7 @@ def __truediv__(self, other):
return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard / other)})
else:
- raise TypeError('%(class)s must be divided with number or %(class)s' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be divided with number or %(class)s' % {"class": pretty_name(self)})
def __div__(self, other): # Python 2 compatibility
return type(self).__truediv__(self, other)
@@ -160,7 +160,7 @@ def __itruediv__(self, other):
self.standard /= float(other)
return self
else:
- raise TypeError('%(class)s must be divided with number' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be divided with number' % {"class": pretty_name(self)})
def __idiv__(self, other): # Python 2 compatibility
return type(self).__itruediv__(self, other)
@@ -304,7 +304,7 @@ def __mul__(self, other):
**{self.STANDARD_UNIT: (self.standard * other)})
else:
raise TypeError('%(distance)s must be multiplied with number or %(distance)s' % {
- "distance" : pretty_name(self.__class__),
+ "distance": pretty_name(self.__class__),
})
@@ -320,7 +320,7 @@ def __truediv__(self, other):
return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard / other)})
else:
- raise TypeError('%(class)s must be divided by a number' % {"class":pretty_name(self)})
+ raise TypeError('%(class)s must be divided by a number' % {"class": pretty_name(self)})
def __div__(self, other): # Python 2 compatibility
return type(self).__truediv__(self, other)
View
2  django/contrib/sitemaps/__init__.py
@@ -32,7 +32,7 @@ def ping_google(sitemap_url=None, ping_url=PING_URL):
current_site = Site.objects.get_current()
url = "http://%s%s" % (current_site.domain, sitemap_url)
- params = urlencode({'sitemap':url})
+ params = urlencode({'sitemap': url})
urlopen("%s?%s" % (ping_url, params))
class Sitemap(object):
View
2  django/core/cache/backends/filebased.py
@@ -141,7 +141,7 @@ def _key_to_file(self, key):
def _get_num_entries(self):
count = 0
- for _,_,files in os.walk(self._dir):
+ for _, _, files in os.walk(self._dir):
count += len(files)
return count
_num_entries = property(_get_num_entries)
View
2  django/core/files/locks.py
@@ -14,7 +14,7 @@
... f.write('Django')
"""
-__all__ = ('LOCK_EX','LOCK_SH','LOCK_NB','lock','unlock')
+__all__ = ('LOCK_EX', 'LOCK_SH', 'LOCK_NB', 'lock', 'unlock')
system_type = None
View
2  django/core/files/move.py
@@ -26,7 +26,7 @@ def copystat(src, dst):
def _samefile(src, dst):
# Macintosh, Unix.
- if hasattr(os.path,'samefile'):
+ if hasattr(os.path, 'samefile'):
try:
return os.path.samefile(src, dst)
except OSError:
View
8 django/core/files/uploadhandler.py
@@ -11,9 +11,11 @@
from django.utils.encoding import python_2_unicode_compatible
from django.utils.module_loading import import_by_path
-__all__ = ['UploadFileException','StopUpload', 'SkipFile', 'FileUploadHandler',
- 'TemporaryFileUploadHandler', 'MemoryFileUploadHandler',
- 'load_handler', 'StopFutureHandlers']
+__all__ = [
+ 'UploadFileException', 'StopUpload', 'SkipFile', 'FileUploadHandler',
+ 'TemporaryFileUploadHandler', 'MemoryFileUploadHandler', 'load_handler',
+ 'StopFutureHandlers'
+]
class UploadFileException(Exception):
"""
View
2  django/core/mail/backends/filebased.py
@@ -14,7 +14,7 @@ def __init__(self, *args, **kwargs):
if 'file_path' in kwargs:
self.file_path = kwargs.pop('file_path')
else:
- self.file_path = getattr(settings, 'EMAIL_FILE_PATH',None)
+ self.file_path = getattr(settings, 'EMAIL_FILE_PATH', None)
# Make sure self.file_path is a string.
if not isinstance(self.file_path, six.string_types):
raise ImproperlyConfigured('Path for saving emails is invalid: %r' % self.file_path)
View
2  django/dispatch/saferef.py
@@ -70,7 +70,7 @@ class BoundMethodWeakref(object):
_allInstances = weakref.WeakValueDictionary()
- def __new__(cls, target, onDelete=None, *arguments,**named):
+ def __new__(cls, target, onDelete=None, *arguments, **named):
"""Create new instance or return current instance
Basically this method of construction allows us to
View
2  django/forms/models.py
@@ -859,7 +859,7 @@ def _construct_form(self, i, **kwargs):
@classmethod
def get_default_prefix(cls):
from django.db.models.fields.related import RelatedObject
- return RelatedObject(cls.fk.rel.to, cls.model, cls.fk).get_accessor_name().replace('+','')
+ return RelatedObject(cls.fk.rel.to, cls.model, cls.fk).get_accessor_name().replace('+', '')
def save_new(self, form, commit=True):
# Use commit=False so we can assign the parent key afterwards, then
View
2  django/forms/widgets.py
@@ -660,7 +660,7 @@ def render(self):
output = [start_tag]
for i, choice in enumerate(self.choices):
choice_value, choice_label = choice
- if isinstance(choice_label, (tuple,list)):
+ if isinstance(choice_label, (tuple, list)):
attrs_plus = self.attrs.copy()
if id_:
attrs_plus['id'] += '_{0}'.format(i)
View
2  django/template/defaultfilters.py
@@ -810,7 +810,7 @@ def filesizeformat(bytes):
"""
try:
bytes = float(bytes)
- except (TypeError,ValueError,UnicodeDecodeError):
+ except (TypeError, ValueError, UnicodeDecodeError):
value = ungettext("%(size)d byte", "%(size)d bytes", 0) % {'size': 0}
return avoid_wrapping(value)
View
2  tests/admin_views/admin.py
@@ -723,7 +723,7 @@ class EmptyModelVisibleAdmin(admin.ModelAdmin):
form = FormWithoutHiddenField
fieldsets = (
(None, {
- 'fields':(('first', 'second'),),
+ 'fields': (('first', 'second'),),
}),
)
View
6 tests/aggregation/tests.py
@@ -340,7 +340,7 @@ def test_filtering(self):
price=Decimal("1000"),
publisher=p,
contact_id=1,
- pubdate=datetime.date(2008,12,1)
+ pubdate=datetime.date(2008, 12, 1)
)
Book.objects.create(
name='ExpensiveBook2',
@@ -350,7 +350,7 @@ def test_filtering(self):
price=Decimal("1000"),
publisher=p,
contact_id=1,
- pubdate=datetime.date(2008,12,2)
+ pubdate=datetime.date(2008, 12, 2)
)
Book.objects.create(
name='ExpensiveBook3',
@@ -360,7 +360,7 @@ def test_filtering(self):
price=Decimal("35"),
publisher=p,
contact_id=1,
- pubdate=datetime.date(2008,12,3)
+ pubdate=datetime.date(2008, 12, 3)
)
publishers = Publisher.objects.annotate(num_books=Count("book__id")).filter(num_books__gt=1).order_by("pk")
View
2  tests/inspectdb/tests.py
@@ -35,7 +35,7 @@ def test_field_types(self):
"""Test introspection of various Django field types"""
out = StringIO()
call_command('inspectdb',
- table_name_filter=lambda tn:tn.startswith('inspectdb_columntypes'),
+ table_name_filter=lambda tn: tn.startswith('inspectdb_columntypes'),
stdout=out)
output = out.getvalue()
View
10 tests/validation/tests.py
@@ -129,9 +129,9 @@ def test_correct_v4_ip_passes(self):
def test_invalid_v4_ip_raises_error(self):
giptm = GenericIPAddressTestModel(v4_ip="294.4.2.1")
- self.assertFailsValidation(giptm.full_clean, ['v4_ip',])
+ self.assertFailsValidation(giptm.full_clean, ['v4_ip'])
giptm = GenericIPAddressTestModel(v4_ip="2001::2")
- self.assertFailsValidation(giptm.full_clean, ['v4_ip',])
+ self.assertFailsValidation(giptm.full_clean, ['v4_ip'])
def test_correct_v6_ip_passes(self):
giptm = GenericIPAddressTestModel(v6_ip="2001::2")
@@ -139,16 +139,16 @@ def test_correct_v6_ip_passes(self):
def test_invalid_v6_ip_raises_error(self):
giptm = GenericIPAddressTestModel(v6_ip="1.2.3.4")
- self.assertFailsValidation(giptm.full_clean, ['v6_ip',])
+ self.assertFailsValidation(giptm.full_clean, ['v6_ip'])
giptm = GenericIPAddressTestModel(v6_ip="1:2")
- self.assertFailsValidation(giptm.full_clean, ['v6_ip',])
+ self.assertFailsValidation(giptm.full_clean, ['v6_ip'])
def test_v6_uniqueness_detection(self):
# These two addresses are the same with different syntax
giptm = GenericIPAddressTestModel(generic_ip="2001::1:0:0:0:0:2")
giptm.save()
giptm = GenericIPAddressTestModel(generic_ip="2001:0:1:2")
- self.assertFailsValidation(giptm.full_clean, ['generic_ip',])
+ self.assertFailsValidation(giptm.full_clean, ['generic_ip'])
def test_v4_unpack_uniqueness_detection(self):
# These two are different, because we are not doing IPv4 unpacking
Please sign in to comment.
Something went wrong with that request. Please try again.