Skip to content

Commit

Permalink
Fixed assorted flake8 errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Oct 11, 2013
1 parent 695bc0d commit b67ab75
Show file tree
Hide file tree
Showing 38 changed files with 92 additions and 73 deletions.
2 changes: 1 addition & 1 deletion django/conf/locale/id/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MONTH_DAY_FORMAT = 'j F'
SHORT_DATE_FORMAT = 'd-m-Y'
SHORT_DATETIME_FORMAT = 'd-m-Y G.i.s'
FIRST_DAY_OF_WEEK = 1 #Monday
FIRST_DAY_OF_WEEK = 1 # Monday

# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
Expand Down
2 changes: 1 addition & 1 deletion django/conf/locale/lv/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MONTH_DAY_FORMAT = 'j. F'
SHORT_DATE_FORMAT = r'j.m.Y'
SHORT_DATETIME_FORMAT = 'j.m.Y H:i:s'
FIRST_DAY_OF_WEEK = 1 #Monday
FIRST_DAY_OF_WEEK = 1 # Monday

# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/admin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class OLMap(self.widget):
'num_zoom' : self.num_zoom,
'max_zoom' : self.max_zoom,
'min_zoom' : self.min_zoom,
'units' : self.units, #likely shoud get from object
'units' : self.units, # likely should get from object
'max_resolution' : self.max_resolution,
'max_extent' : self.max_extent,
'modifiable' : self.modifiable,
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/gdal/geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __setstate__(self, state):
def from_bbox(cls, bbox):
"Constructs a Polygon from a bounding box (4-tuple)."
x0, y0, x1, y1 = bbox
return OGRGeometry( 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (
return OGRGeometry( 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (
x0, y0, x0, y1, x1, y1, x1, y0, x0, y0) )

### Geometry set-like operations ###
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/gdal/srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __getitem__(self, target):
doesn't exist. Can also take a tuple as a parameter, (target, child),
where child is the index of the attribute in the WKT. For example:
>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
>>> print(srs['GEOGCS'])
WGS 84
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/gdal/tests/test_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test07a_polygons(self):
"Testing Polygon objects."

# Testing `from_bbox` class method
bbox = (-180,-90,180,90)
bbox = (-180, -90, 180, 90)
p = OGRGeometry.from_bbox( bbox )
self.assertEqual(bbox, p.extent)

Expand Down
6 changes: 4 additions & 2 deletions django/contrib/gis/geos/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ def __init__(self, *args, **kwargs):
Examples of initialization, where shell, hole1, and hole2 are
valid LinearRing geometries:
>>> from django.contrib.gis.geos import LinearRing, Polygon
>>> shell = hole1 = hole2 = LinearRing()
>>> poly = Polygon(shell, hole1, hole2)
>>> poly = Polygon(shell, (hole1, hole2))
Example where a tuple parameters are used:
>>> # Example where a tuple parameters are used:
>>> poly = Polygon(((0, 0), (0, 10), (10, 10), (0, 10), (0, 0)),
((4, 4), (4, 6), (6, 6), (6, 4), (4, 4)))
... ((4, 4), (4, 6), (6, 6), (6, 4), (4, 4)))
"""
if not args:
raise TypeError('Must provide at least one LinearRing, or a tuple, to initialize a Polygon.')
Expand Down
6 changes: 3 additions & 3 deletions django/contrib/gis/geos/tests/test_geos_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def api_get_extent(x): return x.extent
def api_get_area(x): return x.area
def api_get_length(x): return x.length

geos_function_tests = [ val for name, val in vars().items()
if hasattr(val, '__call__')
and name.startswith('api_get_') ]
geos_function_tests = [val for name, val in vars().items()
if hasattr(val, '__call__')
and name.startswith('api_get_')]


@skipUnless(HAS_GEOS, "Geos is required.")
Expand Down
9 changes: 6 additions & 3 deletions django/contrib/gis/geos/tests/test_mutable_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ def __init__(self, i_list, *args, **kwargs):
self._list = self._mytype(i_list)
super(UserListA, self).__init__(*args, **kwargs)

def __len__(self): return len(self._list)
def __len__(self):
return len(self._list)

def __str__(self): return str(self._list)
def __str__(self):
return str(self._list)

def __repr__(self): return repr(self._list)
def __repr__(self):
return repr(self._list)

def _set_list(self, length, items):
# this would work:
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/maps/google/gmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, key=None, api_url=None, version=None,
# level and a center coordinate are provided with polygons/polylines,
# no automatic determination will occur.
self.calc_zoom = False
if self.polygons or self.polylines or self.markers:
if self.polygons or self.polylines or self.markers:
if center is None or zoom is None:
self.calc_zoom = True

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/tests/distapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_distance_geodetic(self):
self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol)
if postgis:
# PostGIS uses sphere-only distances by default, testing these as well.
qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)
qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)
for i, c in enumerate(qs):
self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol)

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/tests/geoapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def test_kml(self):
# The reference KML depends on the version of PostGIS used
# (the output stopped including altitude in 1.3.3).
if connection.ops.spatial_version >= (1, 3, 3):
ref_kml = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'
ref_kml = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'
else:
ref_kml = '<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>'

Expand Down
6 changes: 4 additions & 2 deletions django/contrib/gis/tests/layermap/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ def test_layermap_unique_multigeometry_fk(self):

# Passing in invalid ForeignKey mapping parameters -- must be a dictionary
# mapping for the model the ForeignKey points to.
bad_fk_map1 = copy(co_mapping); bad_fk_map1['state'] = 'name'
bad_fk_map2 = copy(co_mapping); bad_fk_map2['state'] = {'nombre' : 'State'}
bad_fk_map1 = copy(co_mapping)
bad_fk_map1['state'] = 'name'
bad_fk_map2 = copy(co_mapping)
bad_fk_map2['state'] = {'nombre' : 'State'}
self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)

Expand Down
14 changes: 7 additions & 7 deletions django/contrib/gis/tests/test_geoforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class PointForm(forms.Form):
self.assertFalse(invalid.is_valid())
self.assertTrue('Invalid geometry value' in str(invalid.errors))

for invalid in [geom for key, geom in self.geometries.items() if key!='point']:
for invalid in [geo for key, geo in self.geometries.items() if key!='point']:
self.assertFalse(PointForm(data={'p': invalid.wkt}).is_valid())

def test_multipointfield(self):
Expand All @@ -176,7 +176,7 @@ class PointForm(forms.Form):
self.assertMapWidget(form)
self.assertFalse(PointForm().is_valid())

for invalid in [geom for key, geom in self.geometries.items() if key!='multipoint']:
for invalid in [geo for key, geo in self.geometries.items() if key!='multipoint']:
self.assertFalse(PointForm(data={'p': invalid.wkt}).is_valid())

def test_linestringfield(self):
Expand All @@ -189,7 +189,7 @@ class LineStringForm(forms.Form):
self.assertMapWidget(form)
self.assertFalse(LineStringForm().is_valid())

for invalid in [geom for key, geom in self.geometries.items() if key!='linestring']:
for invalid in [geo for key, geo in self.geometries.items() if key!='linestring']:
self.assertFalse(LineStringForm(data={'p': invalid.wkt}).is_valid())

def test_multilinestringfield(self):
Expand All @@ -202,7 +202,7 @@ class LineStringForm(forms.Form):
self.assertMapWidget(form)
self.assertFalse(LineStringForm().is_valid())

for invalid in [geom for key, geom in self.geometries.items() if key!='multilinestring']:
for invalid in [geo for key, geo in self.geometries.items() if key!='multilinestring']:
self.assertFalse(LineStringForm(data={'p': invalid.wkt}).is_valid())

def test_polygonfield(self):
Expand All @@ -215,7 +215,7 @@ class PolygonForm(forms.Form):
self.assertMapWidget(form)
self.assertFalse(PolygonForm().is_valid())

for invalid in [geom for key, geom in self.geometries.items() if key!='polygon']:
for invalid in [geo for key, geo in self.geometries.items() if key!='polygon']:
self.assertFalse(PolygonForm(data={'p': invalid.wkt}).is_valid())

def test_multipolygonfield(self):
Expand All @@ -228,7 +228,7 @@ class PolygonForm(forms.Form):
self.assertMapWidget(form)
self.assertFalse(PolygonForm().is_valid())

for invalid in [geom for key, geom in self.geometries.items() if key!='multipolygon']:
for invalid in [geo for key, geo in self.geometries.items() if key!='multipolygon']:
self.assertFalse(PolygonForm(data={'p': invalid.wkt}).is_valid())

def test_geometrycollectionfield(self):
Expand All @@ -241,7 +241,7 @@ class GeometryForm(forms.Form):
self.assertMapWidget(form)
self.assertFalse(GeometryForm().is_valid())

for invalid in [geom for key, geom in self.geometries.items() if key!='geometrycollection']:
for invalid in [geo for key, geo in self.geometries.items() if key!='geometrycollection']:
self.assertFalse(GeometryForm(data={'g': invalid.wkt}).is_valid())

def test_osm_widget(self):
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/gis/utils/wkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ def precision_wkt(geom, prec):
integer or a string). If the precision is an integer, then the decimal
places of coordinates WKT will be truncated to that number:
>>> from django.contrib.gis.geos import Point
>>> pnt = Point(5, 23)
>>> pnt.wkt
'POINT (5.0000000000000000 23.0000000000000000)'
>>> precision(geom, 1)
>>> precision_wkt(pnt, 1)
'POINT (5.0 23.0)'
If the precision is a string, it must be valid Python format string
Expand Down
2 changes: 2 additions & 0 deletions django/core/files/uploadhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def load_handler(path, *args, **kwargs):
Given a path to a handler, return an instance of that handler.
E.g.::
>>> from django.http import HttpRequest
>>> request = HttpRequest()
>>> load_handler('django.core.files.uploadhandler.TemporaryFileUploadHandler', request)
<TemporaryFileUploadHandler object at 0x...>
Expand Down
2 changes: 1 addition & 1 deletion django/core/signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def unsign(self, value, max_age=None):
Retrieve original value and check it wasn't signed more
than max_age seconds ago.
"""
result = super(TimestampSigner, self).unsign(value)
result = super(TimestampSigner, self).unsign(value)
value, timestamp = result.rsplit(self.sep, 1)
timestamp = baseconv.base62.decode(timestamp)
if max_age is not None:
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def __new__(cls, name, bases, attrs):
# Basic setup for proxy models.
if is_proxy:
base = None
for parent in [cls for cls in parents if hasattr(cls, '_meta')]:
for parent in [kls for kls in parents if hasattr(kls, '_meta')]:
if parent._meta.abstract:
if parent._meta.fields:
raise TypeError("Abstract base class containing model fields not permitted for proxy model '%s'." % name)
Expand Down
5 changes: 4 additions & 1 deletion django/db/models/fields/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ class FileDescriptor(object):
The descriptor for the file attribute on the model instance. Returns a
FieldFile when accessed so you can do stuff like::
>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size
Assigns a file object on assignment so you can do::
>>> instance.file = File(...)
>>> with open('/tmp/hello.world', 'r') as f:
... instance.file = File(f)
"""
def __init__(self, field):
Expand Down
4 changes: 2 additions & 2 deletions django/dispatch/saferef.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def safeRef(target, onDelete = None):
if target.__self__ is not None:
# Turn a bound method into a BoundMethodWeakref instance.
# Keep track of these instances for lookup by disconnect().
assert hasattr(target, '__func__'), """safeRef target %r has __self__, but no __func__, don't know how to create reference"""%( target,)
assert hasattr(target, '__func__'), """safeRef target %r has __self__, but no __func__, don't know how to create reference""" % (target,)
reference = get_bound_method_weakref(
target=target,
onDelete=onDelete
Expand Down Expand Up @@ -144,7 +144,7 @@ def calculateKey( cls, target ):

def __str__(self):
"""Give a friendly representation of the object"""
return """%s( %s.%s )"""%(
return """%s( %s.%s )""" % (
self.__class__.__name__,
self.selfName,
self.funcName,
Expand Down
2 changes: 1 addition & 1 deletion django/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def to_python(self, data):
raise ValidationError(self.error_messages['invalid'], code='invalid')

if self.max_length is not None and len(file_name) > self.max_length:
params = {'max': self.max_length, 'length': len(file_name)}
params = {'max': self.max_length, 'length': len(file_name)}
raise ValidationError(self.error_messages['max_length'], code='max_length', params=params)
if not file_name:
raise ValidationError(self.error_messages['invalid'], code='invalid')
Expand Down
2 changes: 1 addition & 1 deletion django/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _media(self):
if definition:
extend = getattr(definition, 'extend', True)
if extend:
if extend == True:
if extend is True:
m = base
else:
m = Media()
Expand Down
2 changes: 1 addition & 1 deletion django/template/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# We need the CSRF processor no matter what the user has in their settings,
# because otherwise it is a security vulnerability, and we can't afford to leave
# this to human error or failure to read migration instructions.
_builtin_context_processors = ('django.core.context_processors.csrf',)
_builtin_context_processors = ('django.core.context_processors.csrf',)

class ContextPopException(Exception):
"pop() has been called more times than push()"
Expand Down
2 changes: 1 addition & 1 deletion django/templatetags/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ def do_cache(parser, token):
return CacheNode(nodelist,
parser.compile_filter(tokens[1]),
tokens[2], # fragment_name can't be a variable.
[parser.compile_filter(token) for token in tokens[3:]])
[parser.compile_filter(t) for t in tokens[3:]])
6 changes: 5 additions & 1 deletion django/utils/autoreload.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os, sys, time, signal, traceback
import os
import signal
import sys
import time
import traceback

try:
from django.utils.six.moves import _thread as thread
Expand Down
2 changes: 1 addition & 1 deletion extras/csrf_migration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_template_dirs():
from django.conf import settings
dirs = set()
if ('django.template.loaders.filesystem.load_template_source' in settings.TEMPLATE_LOADERS
or 'django.template.loaders.filesystem.Loader' in settings.TEMPLATE_LOADERS):
or 'django.template.loaders.filesystem.Loader' in settings.TEMPLATE_LOADERS):
dirs.update(map(unicode, settings.TEMPLATE_DIRS))

if ('django.template.loaders.app_directories.load_template_source' in settings.TEMPLATE_LOADERS
Expand Down
6 changes: 3 additions & 3 deletions tests/admin_changelist/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def check_results_order(ascending=False):
admin.site.register(UnorderedObject, UnorderedObjectAdmin)
model_admin = UnorderedObjectAdmin(UnorderedObject, admin.site)
counter = 0 if ascending else 51
for page in range (0, 5):
for page in range(0, 5):
request = self._mocked_authenticated_request('/unorderedobject/?p=%s' % page, superuser)
response = model_admin.changelist_view(request)
for result in response.context_data['cl'].result_list:
Expand Down Expand Up @@ -550,7 +550,7 @@ def check_results_order(ascending=False):
admin.site.register(OrderedObject, OrderedObjectAdmin)
model_admin = OrderedObjectAdmin(OrderedObject, admin.site)
counter = 0 if ascending else 51
for page in range (0, 5):
for page in range(0, 5):
request = self._mocked_authenticated_request('/orderedobject/?p=%s' % page, superuser)
response = model_admin.changelist_view(request)
for result in response.context_data['cl'].result_list:
Expand Down Expand Up @@ -588,7 +588,7 @@ def test_dynamic_list_filter(self):
user_parents = self._create_superuser('parents')

# Test with user 'noparents'
m = DynamicListFilterChildAdmin(Child, admin.site)
m = DynamicListFilterChildAdmin(Child, admin.site)
request = self._mocked_authenticated_request('/child/', user_noparents)
response = m.changelist_view(request)
self.assertEqual(response.context_data['cl'].list_filter, ['name', 'age'])
Expand Down
6 changes: 3 additions & 3 deletions tests/admin_inlines/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_localize_pk_shortcut(self):
holder = Holder.objects.create(pk=123456789, dummy=42)
inner = Inner.objects.create(pk=987654321, holder=holder, dummy=42, readonly='')
response = self.client.get('/admin/admin_inlines/holder/%i/' % holder.id)
inner_shortcut = 'r/%s/%s/'%(ContentType.objects.get_for_model(inner).pk, inner.pk)
inner_shortcut = 'r/%s/%s/' % (ContentType.objects.get_for_model(inner).pk, inner.pk)
self.assertContains(response, inner_shortcut)

def test_custom_pk_shortcut(self):
Expand All @@ -182,8 +182,8 @@ def test_custom_pk_shortcut(self):
child1 = ChildModel1.objects.create(my_own_pk="bar", name="Bar", parent=parent)
child2 = ChildModel2.objects.create(my_own_pk="baz", name="Baz", parent=parent)
response = self.client.get('/admin/admin_inlines/parentmodelwithcustompk/foo/')
child1_shortcut = 'r/%s/%s/'%(ContentType.objects.get_for_model(child1).pk, child1.pk)
child2_shortcut = 'r/%s/%s/'%(ContentType.objects.get_for_model(child2).pk, child2.pk)
child1_shortcut = 'r/%s/%s/' % (ContentType.objects.get_for_model(child1).pk, child1.pk)
child2_shortcut = 'r/%s/%s/' % (ContentType.objects.get_for_model(child2).pk, child2.pk)
self.assertContains(response, child1_shortcut)
self.assertContains(response, child2_shortcut)

Expand Down
2 changes: 1 addition & 1 deletion tests/admin_widgets/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf.urls import patterns, include

from . import widgetadmin
from . import widgetadmin


urlpatterns = patterns('',
Expand Down
Loading

0 comments on commit b67ab75

Please sign in to comment.