From eb214452c3b1dc399b629aabea926e27b5538c52 Mon Sep 17 00:00:00 2001
From: Alasdair Nicol <alasdair@memset.com>
Date: Thu, 17 Oct 2013 09:17:41 +0100
Subject: [PATCH] Fixed #21270 -- Fixed E701 pep8 warnings

---
 django/contrib/admin/views/main.py            |  6 +-
 django/contrib/admindocs/utils.py             | 12 ++--
 django/contrib/gis/admin/options.py           |  6 +-
 django/contrib/gis/admin/widgets.py           |  3 +-
 django/contrib/gis/db/backends/base.py        |  6 +-
 .../gis/db/backends/postgis/introspection.py  |  3 +-
 .../gis/db/backends/postgis/operations.py     |  6 +-
 .../gis/db/backends/spatialite/operations.py  |  9 ++-
 django/contrib/gis/db/models/proxy.py         |  3 +-
 django/contrib/gis/db/models/query.py         | 30 +++++---
 django/contrib/gis/db/models/sql/compiler.py  |  6 +-
 django/contrib/gis/db/models/sql/query.py     |  3 +-
 django/contrib/gis/feeds.py                   |  6 +-
 django/contrib/gis/gdal/base.py               |  6 +-
 django/contrib/gis/gdal/datasource.py         |  6 +-
 django/contrib/gis/gdal/driver.py             |  3 +-
 django/contrib/gis/gdal/error.py              | 12 +++-
 django/contrib/gis/gdal/feature.py            |  3 +-
 django/contrib/gis/gdal/field.py              | 26 +++++--
 django/contrib/gis/gdal/geometries.py         | 29 +++++---
 django/contrib/gis/gdal/geomtype.py           |  3 +-
 django/contrib/gis/gdal/layer.py              |  6 +-
 django/contrib/gis/gdal/libgdal.py            |  6 +-
 .../contrib/gis/gdal/prototypes/errcheck.py   | 15 ++--
 .../contrib/gis/gdal/prototypes/generation.py |  9 ++-
 django/contrib/gis/gdal/srs.py                | 18 +++--
 django/contrib/gis/gdal/tests/test_ds.py      |  3 +-
 django/contrib/gis/gdal/tests/test_geom.py    |  3 +-
 django/contrib/gis/geoip/base.py              | 15 ++--
 django/contrib/gis/geoip/libgeoip.py          |  8 ++-
 django/contrib/gis/geoip/prototypes.py        |  3 +-
 django/contrib/gis/geos/base.py               |  6 +-
 django/contrib/gis/geos/collections.py        |  3 +-
 django/contrib/gis/geos/coordseq.py           | 15 ++--
 django/contrib/gis/geos/geometry.py           | 24 ++++---
 django/contrib/gis/geos/libgeos.py            | 18 +++--
 django/contrib/gis/geos/linestring.py         | 42 ++++++++----
 django/contrib/gis/geos/mutable_list.py       |  6 +-
 django/contrib/gis/geos/point.py              | 12 ++--
 django/contrib/gis/geos/polygon.py            |  6 +-
 django/contrib/gis/geos/prepared.py           |  6 +-
 .../contrib/gis/geos/prototypes/errcheck.py   | 12 ++--
 django/contrib/gis/geos/prototypes/geom.py    |  3 +-
 django/contrib/gis/geos/prototypes/io.py      | 30 +++++---
 .../contrib/gis/geos/prototypes/predicates.py |  3 +-
 .../contrib/gis/geos/prototypes/threadsafe.py |  3 +-
 .../contrib/gis/geos/prototypes/topology.py   |  3 +-
 django/contrib/gis/geos/tests/test_geos.py    | 30 +++++---
 .../gis/geos/tests/test_geos_mutation.py      | 68 ++++++++++++++-----
 .../gis/geos/tests/test_mutable_list.py       | 36 ++++++----
 django/contrib/gis/maps/google/gmap.py        |  9 ++-
 django/contrib/gis/maps/google/overlays.py    | 27 +++++---
 django/contrib/gis/measure.py                 |  3 +-
 django/contrib/gis/sitemaps/georss.py         |  6 +-
 django/contrib/gis/sitemaps/kml.py            |  3 +-
 django/contrib/gis/tests/distapp/models.py    | 28 ++++++--
 django/contrib/gis/tests/distapp/tests.py     | 18 +++--
 django/contrib/gis/tests/geoadmin/models.py   |  4 +-
 django/contrib/gis/tests/geoapp/models.py     | 20 ++++--
 django/contrib/gis/tests/geoapp/tests.py      | 24 ++++---
 django/contrib/gis/tests/geogapp/models.py    | 12 +++-
 django/contrib/gis/tests/layermap/tests.py    |  3 +-
 django/contrib/gis/tests/relatedapp/models.py | 12 +++-
 django/contrib/gis/tests/relatedapp/tests.py  |  3 +-
 django/contrib/gis/tests/utils.py             | 15 ++--
 django/contrib/gis/utils/layermapping.py      | 43 ++++++++----
 django/contrib/gis/utils/ogrinspect.py        | 24 ++++---
 django/core/management/color.py               |  3 +-
 django/forms/utils.py                         |  9 ++-
 django/forms/widgets.py                       | 15 ++--
 django/utils/text.py                          |  6 +-
 django/utils/translation/trans_null.py        |  3 +-
 django/utils/xmlutils.py                      |  3 +-
 setup.cfg                                     |  2 +-
 tests/decorators/tests.py                     |  7 +-
 .../forms_tests/tests/test_error_messages.py  |  3 +-
 tests/forms_tests/tests/test_extra.py         |  3 +-
 tests/forms_tests/tests/test_util.py          |  3 +-
 78 files changed, 625 insertions(+), 285 deletions(-)

diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index cea0cba2b8..dbe59f831b 100644
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -198,8 +198,10 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):
             six.reraise(IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2])
 
     def get_query_string(self, new_params=None, remove=None):
-        if new_params is None: new_params = {}
-        if remove is None: remove = []
+        if new_params is None:
+            new_params = {}
+        if remove is None:
+            remove = []
         p = self.params.copy()
         for r in remove:
             for k in list(p):
diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
index f836253e71..cdb1064412 100644
--- a/django/contrib/admindocs/utils.py
+++ b/django/contrib/admindocs/utils.py
@@ -94,15 +94,19 @@ ROLES = {
 
 def create_reference_role(rolename, urlbase):
     def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
-        if options is None: options = {}
-        if content is None: content = []
+        if options is None:
+            options = {}
+        if content is None:
+            content = []
         node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text.lower())), **options)
         return [node], []
     docutils.parsers.rst.roles.register_canonical_role(rolename, _role)
 
 def default_reference_role(name, rawtext, text, lineno, inliner, options=None, content=None):
-    if options is None: options = {}
-    if content is None: content = []
+    if options is None:
+        options = {}
+    if content is None:
+        content = []
     context = inliner.document.settings.default_reference_context
     node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)
     return [node], []
diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py
index 6f88976819..c73c4224eb 100644
--- a/django/contrib/gis/admin/options.py
+++ b/django/contrib/gis/admin/options.py
@@ -70,8 +70,10 @@ class GeoModelAdmin(ModelAdmin):
         """
         is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
         if is_collection:
-            if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any'
-            else: collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
+            if db_field.geom_type == 'GEOMETRYCOLLECTION':
+                collection_type = 'Any'
+            else:
+                collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
         else:
             collection_type = 'None'
 
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py
index 056d25952a..0011223617 100644
--- a/django/contrib/gis/admin/widgets.py
+++ b/django/contrib/gis/admin/widgets.py
@@ -20,7 +20,8 @@ class OpenLayersWidget(Textarea):
     """
     def render(self, name, value, attrs=None):
         # Update the template parameters with any attributes passed in.
-        if attrs: self.params.update(attrs)
+        if attrs:
+            self.params.update(attrs)
 
         # Defaulting the WKT value to a blank string -- this
         # will be tested in the JavaScript and the appropriate
diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py
index 2d992cf36c..3162ed3d00 100644
--- a/django/contrib/gis/db/backends/base.py
+++ b/django/contrib/gis/db/backends/base.py
@@ -201,8 +201,10 @@ class SpatialRefSysMixin(object):
             return self.srs.ellipsoid
         else:
             m = self.spheroid_regex.match(self.wkt)
-            if m: return (float(m.group('major')), float(m.group('flattening')))
-            else: return None
+            if m:
+                return (float(m.group('major')), float(m.group('flattening')))
+            else:
+                return None
 
     @property
     def name(self):
diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py
index 0b179934b6..3189fa4553 100644
--- a/django/contrib/gis/db/backends/postgis/introspection.py
+++ b/django/contrib/gis/db/backends/postgis/introspection.py
@@ -72,7 +72,8 @@ class PostGISIntrospection(DatabaseIntrospection):
                                'WHERE "f_table_name"=%s AND "f_geometry_column"=%s',
                                (table_name, geo_col))
                 row = cursor.fetchone()
-                if not row: raise GeoIntrospectionError
+                if not row:
+                    raise GeoIntrospectionError
             except GeoIntrospectionError:
                 if self.connection.ops.geography:
                     cursor.execute('SELECT "coord_dimension", "srid", "type" '
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py
index 0bff02cd11..41644e377d 100644
--- a/django/contrib/gis/db/backends/postgis/operations.py
+++ b/django/contrib/gis/db/backends/postgis/operations.py
@@ -453,8 +453,10 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
         Helper routine that returns a boolean indicating whether the number of
         parameters is correct for the lookup type.
         """
-        def exactly_two(np): return np == 2
-        def two_to_three(np): return np >= 2 and np <=3
+        def exactly_two(np):
+            return np == 2
+        def two_to_three(np):
+            return np >= 2 and np <=3
         if (lookup_type in self.distance_functions and
             lookup_type != 'dwithin'):
             return two_to_three(num_param)
diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py
index 093ec39bae..d2bbc9f4b9 100644
--- a/django/contrib/gis/db/backends/spatialite/operations.py
+++ b/django/contrib/gis/db/backends/spatialite/operations.py
@@ -275,12 +275,14 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
             version = None
             try:
                 tmp = self._get_spatialite_func("X(GeomFromText('POINT(1 1)'))")
-                if tmp == 1.0: version = '2.3.0'
+                if tmp == 1.0:
+                    version = '2.3.0'
             except DatabaseError:
                 pass
             # If no version string defined, then just re-raise the original
             # exception.
-            if version is None: raise
+            if version is None:
+                raise
 
         m = self.version_regex.match(version)
         if m:
@@ -301,7 +303,8 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
         if not self.check_aggregate_support(agg):
             raise NotImplementedError('%s spatial aggregate is not implmented for this backend.' % agg_name)
         agg_name = agg_name.lower()
-        if agg_name == 'union': agg_name += 'agg'
+        if agg_name == 'union':
+            agg_name += 'agg'
         sql_template = self.select % '%(function)s(%(field)s)'
         sql_function = getattr(self, agg_name)
         return sql_template, sql_function
diff --git a/django/contrib/gis/db/models/proxy.py b/django/contrib/gis/db/models/proxy.py
index fa4f941e70..d55397fd44 100644
--- a/django/contrib/gis/db/models/proxy.py
+++ b/django/contrib/gis/db/models/proxy.py
@@ -54,7 +54,8 @@ class GeometryProxy(object):
         # general GeometryField is used.
         if isinstance(value, self._klass) and (str(value.geom_type).upper() == gtype or gtype == 'GEOMETRY'):
             # Assigning the SRID to the geometry.
-            if value.srid is None: value.srid = self._field.srid
+            if value.srid is None:
+                value.srid = self._field.srid
         elif value is None or isinstance(value, six.string_types + (memoryview,)):
             # Set with None, WKT, HEX, or WKB
             pass
diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py
index 593a6d7dc1..aac4e61ec4 100644
--- a/django/contrib/gis/db/models/query.py
+++ b/django/contrib/gis/db/models/query.py
@@ -156,14 +156,20 @@ class GeoQuerySet(QuerySet):
         # PostGIS we're using. SpatiaLite only uses the first group of options.
         if backend.spatial_version >= (1, 4, 0):
             options = 0
-            if crs and bbox: options = 3
-            elif bbox: options = 1
-            elif crs: options = 2
+            if crs and bbox:
+                options = 3
+            elif bbox:
+                options = 1
+            elif crs:
+                options = 2
         else:
             options = 0
-            if crs and bbox: options = 3
-            elif crs: options = 1
-            elif bbox: options = 2
+            if crs and bbox:
+                options = 3
+            elif crs:
+                options = 1
+            elif bbox:
+                options = 2
         s = {'desc' : 'GeoJSON',
              'procedure_args' : {'precision' : precision, 'options' : options},
              'procedure_fmt' : '%(geo_col)s,%(precision)s,%(options)s',
@@ -441,7 +447,8 @@ class GeoQuerySet(QuerySet):
         # Does the spatial backend support this?
         connection = connections[self.db]
         func = getattr(connection.ops, att, False)
-        if desc is None: desc = att
+        if desc is None:
+            desc = att
         if not func:
             raise NotImplementedError('%s stored procedure not available on '
                                       'the %s backend.' %
@@ -489,7 +496,8 @@ class GeoQuerySet(QuerySet):
         # Adding any keyword parameters for the Aggregate object. Oracle backends
         # in particular need an additional `tolerance` parameter.
         agg_kwargs = {}
-        if connections[self.db].ops.oracle: agg_kwargs['tolerance'] = tolerance
+        if connections[self.db].ops.oracle:
+            agg_kwargs['tolerance'] = tolerance
 
         # Calling the QuerySet.aggregate, and returning only the value of the aggregate.
         return self.aggregate(geoagg=aggregate(agg_col, **agg_kwargs))['geoagg']
@@ -533,12 +541,14 @@ class GeoQuerySet(QuerySet):
         if settings.get('setup', True):
             default_args, geo_field = self._spatial_setup(att, desc=settings['desc'], field_name=field_name,
                                                           geo_field_type=settings.get('geo_field_type', None))
-            for k, v in six.iteritems(default_args): settings['procedure_args'].setdefault(k, v)
+            for k, v in six.iteritems(default_args):
+                settings['procedure_args'].setdefault(k, v)
         else:
             geo_field = settings['geo_field']
 
         # The attribute to attach to the model.
-        if not isinstance(model_att, six.string_types): model_att = att
+        if not isinstance(model_att, six.string_types):
+            model_att = att
 
         # Special handling for any argument that is a geometry.
         for name in settings['geom_args']:
diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py
index 31249d0a00..4cf52207f3 100644
--- a/django/contrib/gis/db/models/sql/compiler.py
+++ b/django/contrib/gis/db/models/sql/compiler.py
@@ -166,7 +166,8 @@ class GeoSQLCompiler(compiler.SQLCompiler):
         # doing pagination with Oracle.
         rn_offset = 0
         if self.connection.ops.oracle:
-            if self.query.high_mark is not None or self.query.low_mark: rn_offset = 1
+            if self.query.high_mark is not None or self.query.low_mark:
+                rn_offset = 1
         index_start = rn_offset + len(aliases)
 
         # Converting any extra selection values (e.g., geometries and
@@ -243,7 +244,8 @@ class GeoSQLCompiler(compiler.SQLCompiler):
         used.  If `column` is specified, it will be used instead of the value
         in `field.column`.
         """
-        if table_alias is None: table_alias = self.query.get_meta().db_table
+        if table_alias is None:
+            table_alias = self.query.get_meta().db_table
         return "%s.%s" % (self.quote_name_unless_alias(table_alias),
                           self.connection.ops.quote_name(column or field.column))
 
diff --git a/django/contrib/gis/db/models/sql/query.py b/django/contrib/gis/db/models/sql/query.py
index 93a7642bbb..5714da3e30 100644
--- a/django/contrib/gis/db/models/sql/query.py
+++ b/django/contrib/gis/db/models/sql/query.py
@@ -113,7 +113,8 @@ class GeoQuery(sql.Query):
         if field_name is None:
             # Incrementing until the first geographic field is found.
             for fld in self.model._meta.fields:
-                if isinstance(fld, GeometryField): return fld
+                if isinstance(fld, GeometryField):
+                    return fld
             return False
         else:
             # Otherwise, check by the given field name -- which may be
diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py
index b1d00779c7..14976717ad 100644
--- a/django/contrib/gis/feeds.py
+++ b/django/contrib/gis/feeds.py
@@ -58,7 +58,8 @@ class GeoFeedMixin(object):
                         raise ValueError('Only should be 2 or 4 numeric elements.')
                 # If a GeoRSS box was given via tuple.
                 if not box_coords is None:
-                    if w3c_geo: raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')
+                    if w3c_geo:
+                        raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')
                     handler.addQuickElement('georss:box', self.georss_coords(box_coords))
             else:
                 # Getting the lower-case geometry type.
@@ -66,7 +67,8 @@ class GeoFeedMixin(object):
                 if gtype == 'point':
                     self.add_georss_point(handler, geom.coords, w3c_geo=w3c_geo)
                 else:
-                    if w3c_geo: raise ValueError('W3C Geo only supports Point geometries.')
+                    if w3c_geo:
+                        raise ValueError('W3C Geo only supports Point geometries.')
                     # For formatting consistent w/the GeoRSS simple standard:
                     # http://georss.org/1.0#simple
                     if gtype in ('linestring', 'linearring'):
diff --git a/django/contrib/gis/gdal/base.py b/django/contrib/gis/gdal/base.py
index 0ccaac0f2e..ac9b8c0a2a 100644
--- a/django/contrib/gis/gdal/base.py
+++ b/django/contrib/gis/gdal/base.py
@@ -19,8 +19,10 @@ class GDALBase(object):
         # Raise an exception if the pointer isn't valid don't
         # want to be passing NULL pointers to routines --
         # that's very bad.
-        if self._ptr: return self._ptr
-        else: raise GDALException('GDAL %s pointer no longer valid.' % self.__class__.__name__)
+        if self._ptr:
+            return self._ptr
+        else:
+            raise GDALException('GDAL %s pointer no longer valid.' % self.__class__.__name__)
 
     def _set_ptr(self, ptr):
         # Only allow the pointer to be set with pointers of the
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index c92b2e170b..53a185841b 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -95,7 +95,8 @@ class DataSource(GDALBase):
 
     def __del__(self):
         "Destroys this DataStructure object."
-        if self._ptr: capi.destroy_ds(self._ptr)
+        if self._ptr:
+            capi.destroy_ds(self._ptr)
 
     def __iter__(self):
         "Allows for iteration over the layers in a data source."
@@ -106,7 +107,8 @@ class DataSource(GDALBase):
         "Allows use of the index [] operator to get a layer at the index."
         if isinstance(index, six.string_types):
             l = capi.get_layer_by_name(self.ptr, force_bytes(index))
-            if not l: raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
+            if not l:
+                raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
         elif isinstance(index, int):
             if index < 0 or index >= self.layer_count:
                 raise OGRIndexError('index out of range')
diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py
index 55a5d77d66..cf5bb8bb58 100644
--- a/django/contrib/gis/gdal/driver.py
+++ b/django/contrib/gis/gdal/driver.py
@@ -59,7 +59,8 @@ class Driver(GDALBase):
         "Attempts to register all the data source drivers."
         # Only register all if the driver count is 0 (or else all drivers
         # will be registered over and over again)
-        if not self.driver_count: capi.register_all()
+        if not self.driver_count:
+            capi.register_all()
 
     # Driver properties
     @property
diff --git a/django/contrib/gis/gdal/error.py b/django/contrib/gis/gdal/error.py
index b121258ac8..968b7f74aa 100644
--- a/django/contrib/gis/gdal/error.py
+++ b/django/contrib/gis/gdal/error.py
@@ -4,9 +4,15 @@
  OGR methods.
 """
 #### OGR & SRS Exceptions ####
-class GDALException(Exception): pass
-class OGRException(Exception): pass
-class SRSException(Exception): pass
+class GDALException(Exception):
+    pass
+
+class OGRException(Exception):
+    pass
+
+class SRSException(Exception):
+    pass
+
 class OGRIndexError(OGRException, KeyError):
     """
     This exception is raised when an invalid index is encountered, and has
diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py
index a11a6873c5..a664be1598 100644
--- a/django/contrib/gis/gdal/feature.py
+++ b/django/contrib/gis/gdal/feature.py
@@ -33,7 +33,8 @@ class Feature(GDALBase):
 
     def __del__(self):
         "Releases a reference to this object."
-        if self._ptr: capi.destroy_feature(self._ptr)
+        if self._ptr:
+            capi.destroy_feature(self._ptr)
 
     def __getitem__(self, index):
         """
diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py
index 287942e595..7c46226ad6 100644
--- a/django/contrib/gis/gdal/field.py
+++ b/django/contrib/gis/gdal/field.py
@@ -132,9 +132,14 @@ class OFTReal(Field):
         return self.as_double()
 
 # String & Binary fields, just subclasses
-class OFTString(Field): pass
-class OFTWideString(Field): pass
-class OFTBinary(Field): pass
+class OFTString(Field):
+    pass
+
+class OFTWideString(Field):
+    pass
+
+class OFTBinary(Field):
+    pass
 
 # OFTDate, OFTTime, OFTDateTime fields.
 class OFTDate(Field):
@@ -172,10 +177,17 @@ class OFTTime(Field):
             return None
 
 # List fields are also just subclasses
-class OFTIntegerList(Field): pass
-class OFTRealList(Field): pass
-class OFTStringList(Field): pass
-class OFTWideStringList(Field): pass
+class OFTIntegerList(Field):
+    pass
+
+class OFTRealList(Field):
+    pass
+
+class OFTStringList(Field):
+    pass
+
+class OFTWideStringList(Field):
+    pass
 
 # Class mapping dictionary for OFT Types and reverse mapping.
 OGRFieldTypes = {
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index 2b051cdca8..139cebefac 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -122,14 +122,16 @@ class OGRGeometry(GDALBase):
         self.ptr = g
 
         # Assigning the SpatialReference object to the geometry, if valid.
-        if bool(srs): self.srs = srs
+        if bool(srs):
+            self.srs = srs
 
         # Setting the class depending upon the OGR Geometry Type
         self.__class__ = GEO_CLASSES[self.geom_type.num]
 
     def __del__(self):
         "Deletes this Geometry."
-        if self._ptr: capi.destroy_geom(self._ptr)
+        if self._ptr:
+            capi.destroy_geom(self._ptr)
 
     # Pickle routines
     def __getstate__(self):
@@ -143,7 +145,8 @@ class OGRGeometry(GDALBase):
     def __setstate__(self, state):
         wkb, srs = state
         ptr = capi.from_wkb(wkb, None, byref(c_void_p()), len(wkb))
-        if not ptr: raise OGRException('Invalid OGRGeometry loaded from pickled state.')
+        if not ptr:
+            raise OGRException('Invalid OGRGeometry loaded from pickled state.')
         self.ptr = ptr
         self.srs = srs
 
@@ -285,7 +288,8 @@ class OGRGeometry(GDALBase):
     # The SRID property
     def _get_srid(self):
         srs = self.srs
-        if srs: return srs.srid
+        if srs:
+            return srs.srid
         return None
 
     def _set_srid(self, srid):
@@ -602,7 +606,8 @@ class LineString(OGRGeometry):
             return self._listarr(capi.getz)
 
 # LinearRings are used in Polygons.
-class LinearRing(LineString): pass
+class LinearRing(LineString):
+    pass
 
 class Polygon(OGRGeometry):
 
@@ -673,7 +678,8 @@ class GeometryCollection(OGRGeometry):
         "Add the geometry to this Geometry Collection."
         if isinstance(geom, OGRGeometry):
             if isinstance(geom, self.__class__):
-                for g in geom: capi.add_geom(self.ptr, g.ptr)
+                for g in geom:
+                    capi.add_geom(self.ptr, g.ptr)
             else:
                 capi.add_geom(self.ptr, geom.ptr)
         elif isinstance(geom, six.string_types):
@@ -695,9 +701,14 @@ class GeometryCollection(OGRGeometry):
     coords = tuple
 
 # Multiple Geometry types.
-class MultiPoint(GeometryCollection): pass
-class MultiLineString(GeometryCollection): pass
-class MultiPolygon(GeometryCollection): pass
+class MultiPoint(GeometryCollection):
+    pass
+
+class MultiLineString(GeometryCollection):
+    pass
+
+class MultiPolygon(GeometryCollection):
+    pass
 
 # Class mapping dictionary (using the OGRwkbGeometryType as the key)
 GEO_CLASSES = {1 : Point,
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index a287033192..8a1ce5e544 100644
--- a/django/contrib/gis/gdal/geomtype.py
+++ b/django/contrib/gis/gdal/geomtype.py
@@ -36,7 +36,8 @@ class OGRGeomType(object):
             num = type_input.num
         elif isinstance(type_input, six.string_types):
             type_input = type_input.lower()
-            if type_input == 'geometry': type_input='unknown'
+            if type_input == 'geometry':
+                type_input='unknown'
             num = self._str_types.get(type_input, None)
             if num is None:
                 raise OGRException('Invalid OGR String Type "%s"' % type_input)
diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py
index 7f935cd114..226013540c 100644
--- a/django/contrib/gis/gdal/layer.py
+++ b/django/contrib/gis/gdal/layer.py
@@ -47,7 +47,8 @@ class Layer(GDALBase):
             # An integer index was given -- we cannot do a check based on the
             # number of features because the beginning and ending feature IDs
             # are not guaranteed to be 0 and len(layer)-1, respectively.
-            if index < 0: raise OGRIndexError('Negative indices are not allowed on OGR Layers.')
+            if index < 0:
+                raise OGRIndexError('Negative indices are not allowed on OGR Layers.')
             return self._make_feature(index)
         elif isinstance(index, slice):
             # A slice was given
@@ -88,7 +89,8 @@ class Layer(GDALBase):
             # Random access isn't supported, have to increment through
             # each feature until the given feature ID is encountered.
             for feat in self:
-                if feat.fid == feat_id: return feat
+                if feat.fid == feat_id:
+                    return feat
         # Should have returned a Feature, raise an OGRIndexError.
         raise OGRIndexError('Invalid feature id: %s.' % feat_id)
 
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index af295fd619..77487bbf0e 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -36,7 +36,8 @@ else:
 if lib_names:
     for lib_name in lib_names:
         lib_path = find_library(lib_name)
-        if not lib_path is None: break
+        if not lib_path is None:
+            break
 
 if lib_path is None:
     raise OGRException('Could not find the GDAL library (tried "%s"). '
@@ -83,7 +84,8 @@ version_regex = re.compile(r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+)
 def gdal_version_info():
     ver = gdal_version().decode()
     m = version_regex.match(ver)
-    if not m: raise OGRException('Could not parse GDAL version string "%s"' % ver)
+    if not m:
+        raise OGRException('Could not parse GDAL version string "%s"' % ver)
     return dict((key, m.group(key)) for key in ('major', 'minor', 'subminor'))
 
 _verinfo = gdal_version_info()
diff --git a/django/contrib/gis/gdal/prototypes/errcheck.py b/django/contrib/gis/gdal/prototypes/errcheck.py
index 2d2791124c..5d2963402a 100644
--- a/django/contrib/gis/gdal/prototypes/errcheck.py
+++ b/django/contrib/gis/gdal/prototypes/errcheck.py
@@ -19,8 +19,10 @@ def ptr_byref(args, offset=-1):
 
 def check_bool(result, func, cargs):
     "Returns the boolean evaluation of the value."
-    if bool(result): return True
-    else: return False
+    if bool(result):
+        return True
+    else:
+        return False
 
 ### String checking Routines ###
 def check_const_string(result, func, cargs, offset=None):
@@ -46,8 +48,10 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
     if str_result:
         # For routines that return a string.
         ptr = result
-        if not ptr: s = None
-        else: s = string_at(result)
+        if not ptr:
+            s = None
+        else:
+            s = string_at(result)
     else:
         # Error-code return specified.
         check_err(result)
@@ -56,7 +60,8 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
         s = ptr.value
     # Correctly freeing the allocated memory beind GDAL pointer
     # w/the VSIFree routine.
-    if ptr: lgdal.VSIFree(ptr)
+    if ptr:
+        lgdal.VSIFree(ptr)
     return s
 
 ### DataSource, Layer error-checking ###
diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py
index 229733e168..a14e38354c 100644
--- a/django/contrib/gis/gdal/prototypes/generation.py
+++ b/django/contrib/gis/gdal/prototypes/generation.py
@@ -15,8 +15,10 @@ def double_output(func, argtypes, errcheck=False, strarg=False):
     "Generates a ctypes function that returns a double value."
     func.argtypes = argtypes
     func.restype = c_double
-    if errcheck: func.errcheck = check_arg_errcode
-    if strarg: func.errcheck = check_str_arg
+    if errcheck:
+        func.errcheck = check_arg_errcode
+    if strarg:
+        func.errcheck = check_str_arg
     return func
 
 def geom_output(func, argtypes, offset=None):
@@ -106,7 +108,8 @@ def void_output(func, argtypes, errcheck=True):
     For functions that don't only return an error code that needs to
     be examined.
     """
-    if argtypes: func.argtypes = argtypes
+    if argtypes:
+        func.argtypes = argtypes
     if errcheck:
         # `errcheck` keyword may be set to False for routines that
         # return void, rather than a status code.
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 36a5e73d07..0e5767967a 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -97,7 +97,8 @@ class SpatialReference(GDALBase):
 
     def __del__(self):
         "Destroys this spatial reference."
-        if self._ptr: capi.release_srs(self._ptr)
+        if self._ptr:
+            capi.release_srs(self._ptr)
 
     def __getitem__(self, target):
         """
@@ -176,10 +177,14 @@ class SpatialReference(GDALBase):
     @property
     def name(self):
         "Returns the name of this Spatial Reference."
-        if self.projected: return self.attr_value('PROJCS')
-        elif self.geographic: return self.attr_value('GEOGCS')
-        elif self.local: return self.attr_value('LOCAL_CS')
-        else: return None
+        if self.projected:
+            return self.attr_value('PROJCS')
+        elif self.geographic:
+            return self.attr_value('GEOGCS')
+        elif self.local:
+            return self.attr_value('LOCAL_CS')
+        else:
+            return None
 
     @property
     def srid(self):
@@ -336,7 +341,8 @@ class CoordTransform(GDALBase):
 
     def __del__(self):
         "Deletes this Coordinate Transformation object."
-        if self._ptr: capi.destroy_ct(self._ptr)
+        if self._ptr:
+            capi.destroy_ct(self._ptr)
 
     def __str__(self):
         return 'Transform from "%s" to "%s"' % (self._srs1_name, self._srs2_name)
diff --git a/django/contrib/gis/gdal/tests/test_ds.py b/django/contrib/gis/gdal/tests/test_ds.py
index 3ac2370fb7..c25bdfae02 100644
--- a/django/contrib/gis/gdal/tests/test_ds.py
+++ b/django/contrib/gis/gdal/tests/test_ds.py
@@ -93,7 +93,8 @@ class DataSourceTest(unittest.TestCase):
 
                 # Now checking the field names.
                 flds = layer.fields
-                for f in flds: self.assertEqual(True, f in source.fields)
+                for f in flds:
+                    self.assertEqual(True, f in source.fields)
 
                 # Negative FIDs are not allowed.
                 self.assertRaises(OGRIndexError, layer.__getitem__, -1)
diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py
index f041e8cc58..c547135b17 100644
--- a/django/contrib/gis/gdal/tests/test_geom.py
+++ b/django/contrib/gis/gdal/tests/test_geom.py
@@ -418,7 +418,8 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
                 mp1.add(poly) # Adding a geometry at a time
                 mp2.add(poly.wkt) # Adding WKT
             mp3.add(mpoly) # Adding a MultiPolygon's entire contents at once.
-            for tmp in (mp1, mp2, mp3): self.assertEqual(mpoly, tmp)
+            for tmp in (mp1, mp2, mp3):
+                self.assertEqual(mpoly, tmp)
 
     def test15_extent(self):
         "Testing `extent` property."
diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py
index c6e27866db..c31cdb47e7 100644
--- a/django/contrib/gis/geoip/base.py
+++ b/django/contrib/gis/geoip/base.py
@@ -89,7 +89,8 @@ class GeoIP(object):
         # Getting the GeoIP data path.
         if not path:
             path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
-            if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
+            if not path:
+                raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
         if not isinstance(path, six.string_types):
             raise TypeError('Invalid path type: %s' % type(path).__name__)
 
@@ -129,8 +130,10 @@ class GeoIP(object):
         # Cleaning any GeoIP file handles lying around.
         if GeoIP_delete is None:
             return
-        if self._country: GeoIP_delete(self._country)
-        if self._city: GeoIP_delete(self._city)
+        if self._country:
+            GeoIP_delete(self._country)
+        if self._city:
+            GeoIP_delete(self._city)
 
     def _check_query(self, query, country=False, city=False, city_or_country=False):
         "Helper routine for checking the query and database availability."
@@ -199,8 +202,10 @@ class GeoIP(object):
     #### Coordinate retrieval routines ####
     def coords(self, query, ordering=('longitude', 'latitude')):
         cdict = self.city(query)
-        if cdict is None: return None
-        else: return tuple(cdict[o] for o in ordering)
+        if cdict is None:
+            return None
+        else:
+            return tuple(cdict[o] for o in ordering)
 
     def lon_lat(self, query):
         "Returns a tuple of the (longitude, latitude) for the given query."
diff --git a/django/contrib/gis/geoip/libgeoip.py b/django/contrib/gis/geoip/libgeoip.py
index e9e7cd7fe9..73aa5fc9bf 100644
--- a/django/contrib/gis/geoip/libgeoip.py
+++ b/django/contrib/gis/geoip/libgeoip.py
@@ -18,9 +18,11 @@ else:
     lib_name = 'GeoIP'
 
 # Getting the path to the GeoIP library.
-if lib_name: lib_path = find_library(lib_name)
-if lib_path is None: raise RuntimeError('Could not find the GeoIP library (tried "%s"). '
-                                        'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
+if lib_name:
+    lib_path = find_library(lib_name)
+if lib_path is None:
+    raise RuntimeError('Could not find the GeoIP library (tried "%s"). '
+                       'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
 lgeoip = CDLL(lib_path)
 
 # Getting the C `free` for the platform.
diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py
index fd7c802426..b6d5fe9c50 100644
--- a/django/contrib/gis/geoip/prototypes.py
+++ b/django/contrib/gis/geoip/prototypes.py
@@ -27,7 +27,8 @@ geoip_encodings = {
     1: 'utf8',
 }
 
-class GeoIPTag(Structure): pass
+class GeoIPTag(Structure):
+    pass
 
 RECTYPE = POINTER(GeoIPRecord)
 DBTYPE = POINTER(GeoIPTag)
diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py
index fd2693ed59..1d44e0a8b6 100644
--- a/django/contrib/gis/geos/base.py
+++ b/django/contrib/gis/geos/base.py
@@ -34,8 +34,10 @@ class GEOSBase(object):
         # Raise an exception if the pointer isn't valid don't
         # want to be passing NULL pointers to routines --
         # that's very bad.
-        if self._ptr: return self._ptr
-        else: raise GEOSException('NULL GEOS %s pointer encountered.' % self.__class__.__name__)
+        if self._ptr:
+            return self._ptr
+        else:
+            raise GEOSException('NULL GEOS %s pointer encountered.' % self.__class__.__name__)
 
     def _set_ptr(self, ptr):
         # Only allow the pointer to be set with pointers of the
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
index 70cb4e1391..5a7dcf56ae 100644
--- a/django/contrib/gis/geos/collections.py
+++ b/django/contrib/gis/geos/collections.py
@@ -73,7 +73,8 @@ class GeometryCollection(GEOSGeometry):
         prev_ptr = self.ptr
         srid = self.srid
         self.ptr = self._create_collection(length, items)
-        if srid: self.srid = srid
+        if srid:
+            self.srid = srid
         capi.destroy_geom(prev_ptr)
 
     _set_single = GEOSGeometry._set_single_rebuild
diff --git a/django/contrib/gis/geos/coordseq.py b/django/contrib/gis/geos/coordseq.py
index b28fb0c524..436d39d411 100644
--- a/django/contrib/gis/geos/coordseq.py
+++ b/django/contrib/gis/geos/coordseq.py
@@ -64,7 +64,8 @@ class GEOSCoordSeq(GEOSBase):
         # Setting the X, Y, Z
         self.setX(index, value[0])
         self.setY(index, value[1])
-        if set_3d: self.setZ(index, value[2])
+        if set_3d:
+            self.setZ(index, value[2])
 
     #### Internal Routines ####
     def _checkindex(self, index):
@@ -144,8 +145,10 @@ class GEOSCoordSeq(GEOSBase):
         "Returns the KML representation for the coordinates."
         # Getting the substitution string depending on whether the coordinates have
         #  a Z dimension.
-        if self.hasz: substr = '%s,%s,%s '
-        else: substr = '%s,%s,0 '
+        if self.hasz:
+            substr = '%s,%s,%s '
+        else:
+            substr = '%s,%s,0 '
         return '<coordinates>%s</coordinates>' % \
             ''.join(substr % self[i] for i in xrange(len(self))).strip()
 
@@ -153,5 +156,7 @@ class GEOSCoordSeq(GEOSBase):
     def tuple(self):
         "Returns a tuple version of this coordinate sequence."
         n = self.size
-        if n == 1: return self[0]
-        else: return tuple(self[i] for i in xrange(n))
+        if n == 1:
+            return self[0]
+        else:
+            return tuple(self[i] for i in xrange(n))
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 7021ed1866..2b31b08d38 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -66,7 +66,8 @@ class GEOSGeometry(GEOSBase, ListMixin):
             wkt_m = wkt_regex.match(geo_input)
             if wkt_m:
                 # Handling WKT input.
-                if wkt_m.group('srid'): srid = int(wkt_m.group('srid'))
+                if wkt_m.group('srid'):
+                    srid = int(wkt_m.group('srid'))
                 g = wkt_r().read(force_bytes(wkt_m.group('wkt')))
             elif hex_regex.match(geo_input):
                 # Handling HEXEWKB input.
@@ -100,7 +101,8 @@ class GEOSGeometry(GEOSBase, ListMixin):
     def _post_init(self, srid):
         "Helper routine for performing post-initialization setup."
         # Setting the SRID, if given.
-        if srid and isinstance(srid, int): self.srid = srid
+        if srid and isinstance(srid, int):
+            self.srid = srid
 
         # Setting the class type (e.g., Point, Polygon, etc.)
         self.__class__ = GEOS_CLASSES[self.geom_typeid]
@@ -114,7 +116,8 @@ class GEOSGeometry(GEOSBase, ListMixin):
         Destroys this Geometry; in other words, frees the memory used by the
         GEOS C++ object.
         """
-        if self._ptr: capi.destroy_geom(self._ptr)
+        if self._ptr:
+            capi.destroy_geom(self._ptr)
 
     def __copy__(self):
         """
@@ -149,7 +152,8 @@ class GEOSGeometry(GEOSBase, ListMixin):
         # Instantiating from the tuple state that was pickled.
         wkb, srid = state
         ptr = wkb_r().read(memoryview(wkb))
-        if not ptr: raise GEOSException('Invalid Geometry loaded from pickled state.')
+        if not ptr:
+            raise GEOSException('Invalid Geometry loaded from pickled state.')
         self.ptr = ptr
         self._post_init(srid)
 
@@ -361,8 +365,10 @@ class GEOSGeometry(GEOSBase, ListMixin):
     def get_srid(self):
         "Gets the SRID for the geometry, returns None if no SRID is set."
         s = capi.geos_get_srid(self.ptr)
-        if s == 0: return None
-        else: return s
+        if s == 0:
+            return None
+        else:
+            return s
 
     def set_srid(self, srid):
         "Sets the SRID for the geometry."
@@ -377,8 +383,10 @@ class GEOSGeometry(GEOSBase, ListMixin):
         are *not* included in this representation because GEOS does not yet
         support serializing them.
         """
-        if self.get_srid(): return 'SRID=%s;%s' % (self.srid, self.wkt)
-        else: return self.wkt
+        if self.get_srid():
+            return 'SRID=%s;%s' % (self.srid, self.wkt)
+        else:
+            return self.wkt
 
     @property
     def wkt(self):
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index c3f30b3f14..00880e3f34 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -43,7 +43,8 @@ else:
 if lib_names:
     for lib_name in lib_names:
         lib_path = find_library(lib_name)
-        if not lib_path is None: break
+        if not lib_path is None:
+            break
 
 # No GEOS library could be found.
 if lib_path is None:
@@ -83,10 +84,17 @@ error_h = ERRORFUNC(error_h)
 #### GEOS Geometry C data structures, and utility functions. ####
 
 # Opaque GEOS geometry structures, used for GEOM_PTR and CS_PTR
-class GEOSGeom_t(Structure): pass
-class GEOSPrepGeom_t(Structure): pass
-class GEOSCoordSeq_t(Structure): pass
-class GEOSContextHandle_t(Structure): pass
+class GEOSGeom_t(Structure):
+    pass
+
+class GEOSPrepGeom_t(Structure):
+    pass
+
+class GEOSCoordSeq_t(Structure):
+    pass
+
+class GEOSContextHandle_t(Structure):
+    pass
 
 # Pointers to opaque GEOS geometry structures.
 GEOM_PTR = POINTER(GEOSGeom_t)
diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py
index 4784ea7c2d..5346ee6cec 100644
--- a/django/contrib/gis/geos/linestring.py
+++ b/django/contrib/gis/geos/linestring.py
@@ -24,25 +24,31 @@ class LineString(GEOSGeometry):
          ls = LineString(Point(1, 1), Point(2, 2))
         """
         # If only one argument provided, set the coords array appropriately
-        if len(args) == 1: coords = args[0]
-        else: coords = args
+        if len(args) == 1:
+            coords = args[0]
+        else:
+            coords = args
 
         if isinstance(coords, (tuple, list)):
             # Getting the number of coords and the number of dimensions -- which
             #  must stay the same, e.g., no LineString((1, 2), (1, 2, 3)).
             ncoords = len(coords)
-            if coords: ndim = len(coords[0])
-            else: raise TypeError('Cannot initialize on empty sequence.')
+            if coords:
+                ndim = len(coords[0])
+            else:
+                raise TypeError('Cannot initialize on empty sequence.')
             self._checkdim(ndim)
             # Incrementing through each of the coordinates and verifying
             for i in xrange(1, ncoords):
                 if not isinstance(coords[i], (tuple, list, Point)):
                     raise TypeError('each coordinate should be a sequence (list or tuple)')
-                if len(coords[i]) != ndim: raise TypeError('Dimension mismatch.')
+                if len(coords[i]) != ndim:
+                    raise TypeError('Dimension mismatch.')
             numpy_coords = False
         elif numpy and isinstance(coords, numpy.ndarray):
             shape = coords.shape # Using numpy's shape.
-            if len(shape) != 2: raise TypeError('Too many dimensions.')
+            if len(shape) != 2:
+                raise TypeError('Too many dimensions.')
             self._checkdim(shape[1])
             ncoords = shape[0]
             ndim = shape[1]
@@ -55,9 +61,12 @@ class LineString(GEOSGeometry):
         cs = GEOSCoordSeq(capi.create_cs(ncoords, ndim), z=bool(ndim==3))
 
         for i in xrange(ncoords):
-            if numpy_coords: cs[i] = coords[i,:]
-            elif isinstance(coords[i], Point): cs[i] = coords[i].tuple
-            else: cs[i] = coords[i]
+            if numpy_coords:
+                cs[i] = coords[i,:]
+            elif isinstance(coords[i], Point):
+                cs[i] = coords[i].tuple
+            else:
+                cs[i] = coords[i]
 
         # If SRID was passed in with the keyword arguments
         srid = kwargs.get('srid', None)
@@ -103,7 +112,8 @@ class LineString(GEOSGeometry):
         self._cs[index] = value
 
     def _checkdim(self, dim):
-        if dim not in (2, 3): raise TypeError('Dimension mismatch.')
+        if dim not in (2, 3):
+            raise TypeError('Dimension mismatch.')
 
     #### Sequence Properties ####
     @property
@@ -118,8 +128,10 @@ class LineString(GEOSGeometry):
         the given function.  Will return a numpy array if possible.
         """
         lst = [func(i) for i in xrange(len(self))]
-        if numpy: return numpy.array(lst) # ARRRR!
-        else: return lst
+        if numpy:
+            return numpy.array(lst) # ARRRR!
+        else:
+            return lst
 
     @property
     def array(self):
@@ -144,8 +156,10 @@ class LineString(GEOSGeometry):
     @property
     def z(self):
         "Returns a list or numpy array of the Z variable."
-        if not self.hasz: return None
-        else: return self._listarr(self._cs.getZ)
+        if not self.hasz:
+            return None
+        else:
+            return self._listarr(self._cs.getZ)
 
 # LinearRings are LineStrings used within Polygons.
 class LinearRing(LineString):
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py
index 7184f78f84..592d1e6242 100644
--- a/django/contrib/gis/geos/mutable_list.py
+++ b/django/contrib/gis/geos/mutable_list.py
@@ -180,13 +180,15 @@ class ListMixin(object):
         "Standard list count method"
         count = 0
         for i in self:
-            if val == i: count += 1
+            if val == i:
+                count += 1
         return count
 
     def index(self, val):
         "Standard list index method"
         for i in xrange(0, len(self)):
-            if self[i] == val: return i
+            if self[i] == val:
+                return i
         raise ValueError('%s not found in object' % str(val))
 
     ## Mutating ##
diff --git a/django/contrib/gis/geos/point.py b/django/contrib/gis/geos/point.py
index 907347dbf8..c097ccef88 100644
--- a/django/contrib/gis/geos/point.py
+++ b/django/contrib/gis/geos/point.py
@@ -50,7 +50,8 @@ class Point(GEOSGeometry):
         i = iter(coords)
         capi.cs_setx(cs, 0, next(i))
         capi.cs_sety(cs, 0, next(i))
-        if ndim == 3: capi.cs_setz(cs, 0, next(i))
+        if ndim == 3:
+            capi.cs_setz(cs, 0, next(i))
 
         return capi.create_point(cs)
 
@@ -74,9 +75,12 @@ class Point(GEOSGeometry):
 
     def __len__(self):
         "Returns the number of dimensions for this Point (either 0, 2 or 3)."
-        if self.empty: return 0
-        if self.hasz: return 3
-        else: return 2
+        if self.empty:
+            return 0
+        if self.hasz:
+            return 3
+        else:
+            return 2
 
     def _get_single_external(self, index):
         if index == 0:
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index 3273aa4a1a..8e38f7b167 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -99,7 +99,8 @@ class Polygon(GEOSGeometry):
 
     def _construct_ring(self, param, msg='Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings'):
         "Helper routine for trying to construct a ring from the given parameter."
-        if isinstance(param, LinearRing): return param
+        if isinstance(param, LinearRing):
+            return param
         try:
             ring = LinearRing(param)
             return ring
@@ -112,7 +113,8 @@ class Polygon(GEOSGeometry):
         prev_ptr = self.ptr
         srid = self.srid
         self.ptr = self._create_polygon(length, items)
-        if srid: self.srid = srid
+        if srid:
+            self.srid = srid
         capi.destroy_geom(prev_ptr)
 
     def _get_single_internal(self, index):
diff --git a/django/contrib/gis/geos/prepared.py b/django/contrib/gis/geos/prepared.py
index 68b812df8a..d414d8ddf6 100644
--- a/django/contrib/gis/geos/prepared.py
+++ b/django/contrib/gis/geos/prepared.py
@@ -11,11 +11,13 @@ class PreparedGeometry(GEOSBase):
     ptr_type = capi.PREPGEOM_PTR
 
     def __init__(self, geom):
-        if not isinstance(geom, GEOSGeometry): raise TypeError
+        if not isinstance(geom, GEOSGeometry):
+            raise TypeError
         self.ptr = capi.geos_prepare(geom.ptr)
 
     def __del__(self):
-        if self._ptr: capi.prepared_destroy(self._ptr)
+        if self._ptr:
+            capi.prepared_destroy(self._ptr)
 
     def contains(self, other):
         return capi.prepared_contains(self.ptr, other.ptr)
diff --git a/django/contrib/gis/geos/prototypes/errcheck.py b/django/contrib/gis/geos/prototypes/errcheck.py
index 97fcd21388..40ae37eb2f 100644
--- a/django/contrib/gis/geos/prototypes/errcheck.py
+++ b/django/contrib/gis/geos/prototypes/errcheck.py
@@ -33,7 +33,8 @@ def last_arg_byref(args):
 def check_dbl(result, func, cargs):
     "Checks the status code and returns the double value passed in by reference."
     # Checking the status code
-    if result != 1: return None
+    if result != 1:
+        return None
     # Double passed in by reference, return its value.
     return last_arg_byref(cargs)
 
@@ -53,8 +54,10 @@ def check_minus_one(result, func, cargs):
 def check_predicate(result, func, cargs):
     "Error checking for unary/binary predicate functions."
     val = ord(result) # getting the ordinal from the character
-    if val == 1: return True
-    elif val == 0: return False
+    if val == 1:
+        return True
+    elif val == 0:
+        return False
     else:
         raise GEOSException('Error encountered on GEOS C predicate function "%s".' % func.__name__)
 
@@ -80,7 +83,8 @@ def check_string(result, func, cargs):
 
     This frees the memory allocated by GEOS at the result pointer.
     """
-    if not result: raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__)
+    if not result:
+        raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__)
     # Getting the string value at the pointer address.
     s = string_at(result)
     # Freeing the memory allocated within GEOS
diff --git a/django/contrib/gis/geos/prototypes/geom.py b/django/contrib/gis/geos/prototypes/geom.py
index 2683c2e25d..7ca2f89aed 100644
--- a/django/contrib/gis/geos/prototypes/geom.py
+++ b/django/contrib/gis/geos/prototypes/geom.py
@@ -35,7 +35,8 @@ def bin_output(func):
 
 def geom_output(func, argtypes):
     "For GEOS routines that return a geometry."
-    if argtypes: func.argtypes = argtypes
+    if argtypes:
+        func.argtypes = argtypes
     func.restype = GEOM_PTR
     func.errcheck = check_geom
     return func
diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py
index 6799b377a5..ecc0e42e21 100644
--- a/django/contrib/gis/geos/prototypes/io.py
+++ b/django/contrib/gis/geos/prototypes/io.py
@@ -11,10 +11,17 @@ from django.utils import six
 from django.utils.encoding import force_bytes
 
 ### The WKB/WKT Reader/Writer structures and pointers ###
-class WKTReader_st(Structure): pass
-class WKTWriter_st(Structure): pass
-class WKBReader_st(Structure): pass
-class WKBWriter_st(Structure): pass
+class WKTReader_st(Structure):
+    pass
+
+class WKTWriter_st(Structure):
+    pass
+
+class WKBReader_st(Structure):
+    pass
+
+class WKBWriter_st(Structure):
+    pass
 
 WKT_READ_PTR  = POINTER(WKTReader_st)
 WKT_WRITE_PTR = POINTER(WKTWriter_st)
@@ -121,7 +128,8 @@ class IOBase(GEOSBase):
 
     def __del__(self):
         # Cleaning up with the appropriate destructor.
-        if self._ptr: self._destructor(self._ptr)
+        if self._ptr:
+            self._destructor(self._ptr)
 
 ### Base WKB/WKT Reading and Writing objects ###
 
@@ -194,7 +202,8 @@ class WKBWriter(IOBase):
         return wkb_writer_get_byteorder(self.ptr)
 
     def _set_byteorder(self, order):
-        if not order in (0, 1): raise ValueError('Byte order parameter must be 0 (Big Endian) or 1 (Little Endian).')
+        if not order in (0, 1):
+            raise ValueError('Byte order parameter must be 0 (Big Endian) or 1 (Little Endian).')
         wkb_writer_set_byteorder(self.ptr, order)
 
     byteorder = property(_get_byteorder, _set_byteorder)
@@ -204,7 +213,8 @@ class WKBWriter(IOBase):
         return wkb_writer_get_outdim(self.ptr)
 
     def _set_outdim(self, new_dim):
-        if not new_dim in (2, 3): raise ValueError('WKB output dimension must be 2 or 3')
+        if not new_dim in (2, 3):
+            raise ValueError('WKB output dimension must be 2 or 3')
         wkb_writer_set_outdim(self.ptr, new_dim)
 
     outdim = property(_get_outdim, _set_outdim)
@@ -214,8 +224,10 @@ class WKBWriter(IOBase):
         return bool(ord(wkb_writer_get_include_srid(self.ptr)))
 
     def _set_include_srid(self, include):
-        if bool(include): flag = b'\x01'
-        else: flag = b'\x00'
+        if bool(include):
+            flag = b'\x01'
+        else:
+            flag = b'\x00'
         wkb_writer_set_include_srid(self.ptr, flag)
 
     srid = property(_get_include_srid, _set_include_srid)
diff --git a/django/contrib/gis/geos/prototypes/predicates.py b/django/contrib/gis/geos/prototypes/predicates.py
index bf69bb140b..04739903f3 100644
--- a/django/contrib/gis/geos/prototypes/predicates.py
+++ b/django/contrib/gis/geos/prototypes/predicates.py
@@ -11,7 +11,8 @@ from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
 def binary_predicate(func, *args):
     "For GEOS binary predicate functions."
     argtypes = [GEOM_PTR, GEOM_PTR]
-    if args: argtypes += args
+    if args:
+        argtypes += args
     func.argtypes = argtypes
     func.restype = c_char
     func.errcheck = check_predicate
diff --git a/django/contrib/gis/geos/prototypes/threadsafe.py b/django/contrib/gis/geos/prototypes/threadsafe.py
index 2c9d25ee9f..facb306ad4 100644
--- a/django/contrib/gis/geos/prototypes/threadsafe.py
+++ b/django/contrib/gis/geos/prototypes/threadsafe.py
@@ -11,7 +11,8 @@ class GEOSContextHandle(object):
         self.ptr = lgeos.initGEOS_r(notice_h, error_h)
 
     def __del__(self):
-        if self.ptr: lgeos.finishGEOS_r(self.ptr)
+        if self.ptr:
+            lgeos.finishGEOS_r(self.ptr)
 
 # Defining a thread-local object and creating an instance
 # to hold a reference to GEOSContextHandle for this thread.
diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py
index 8bd5dc08cc..a7098ee6e7 100644
--- a/django/contrib/gis/geos/prototypes/topology.py
+++ b/django/contrib/gis/geos/prototypes/topology.py
@@ -16,7 +16,8 @@ from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
 def topology(func, *args, **kwargs):
     "For GEOS unary topology functions."
     argtypes = [GEOM_PTR]
-    if args: argtypes += args
+    if args:
+        argtypes += args
     func.argtypes = argtypes
     func.restype = kwargs.get('restype', GEOM_PTR)
     func.errcheck = kwargs.get('errcheck', check_geom)
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index 4b0af7496f..9c2e953a8e 100644
--- a/django/contrib/gis/geos/tests/test_geos.py
+++ b/django/contrib/gis/geos/tests/test_geos.py
@@ -143,7 +143,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
         for tg in self.geometries.wkt_out:
             geom = fromstr(tg.wkt)
             kml = getattr(tg, 'kml', False)
-            if kml: self.assertEqual(kml, geom.kml)
+            if kml:
+                self.assertEqual(kml, geom.kml)
 
     def test_errors(self):
         "Testing the Error handlers."
@@ -338,7 +339,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
             self.assertEqual(ls, LineString(*ls.tuple)) # as individual arguments
             self.assertEqual(ls, LineString([list(tup) for tup in ls.tuple])) # as list
             self.assertEqual(ls.wkt, LineString(*tuple(Point(tup) for tup in ls.tuple)).wkt) # Point individual arguments
-            if numpy: self.assertEqual(ls, LineString(numpy.array(ls.tuple))) # as numpy array
+            if numpy:
+                self.assertEqual(ls, LineString(numpy.array(ls.tuple))) # as numpy array
 
     def test_multilinestring(self):
         "Testing MultiLineString objects."
@@ -378,7 +380,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
             self.assertEqual(lr, LinearRing(lr.tuple))
             self.assertEqual(lr, LinearRing(*lr.tuple))
             self.assertEqual(lr, LinearRing([list(tup) for tup in lr.tuple]))
-            if numpy: self.assertEqual(lr, LinearRing(numpy.array(lr.tuple)))
+            if numpy:
+                self.assertEqual(lr, LinearRing(numpy.array(lr.tuple)))
 
     def test_polygons_from_bbox(self):
         "Testing `from_bbox` class method."
@@ -528,8 +531,10 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
                     self.assertEqual(c1, c2)
 
                     # Constructing the test value to set the coordinate sequence with
-                    if len(c1) == 2: tset = (5, 23)
-                    else: tset = (5, 23, 8)
+                    if len(c1) == 2:
+                        tset = (5, 23)
+                    else:
+                        tset = (5, 23, 8)
                     cs[i] = tset
 
                     # Making sure every set point matches what we expect
@@ -636,14 +641,16 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
         # Testing SRID keyword on fromstr(), and on Polygon rings.
         poly = fromstr(self.geometries.polygons[1].wkt, srid=4269)
         self.assertEqual(4269, poly.srid)
-        for ring in poly: self.assertEqual(4269, ring.srid)
+        for ring in poly:
+            self.assertEqual(4269, ring.srid)
         poly.srid = 4326
         self.assertEqual(4326, poly.shell.srid)
 
         # Testing SRID keyword on GeometryCollection
         gc = GeometryCollection(Point(5, 23), LineString((0, 0), (1.5, 1.5), (3, 3)), srid=32021)
         self.assertEqual(32021, gc.srid)
-        for i in range(len(gc)): self.assertEqual(32021, gc[i].srid)
+        for i in range(len(gc)):
+            self.assertEqual(32021, gc[i].srid)
 
         # GEOS may get the SRID from HEXEWKB
         # 'POINT(5 23)' at SRID=4326 in hex form -- obtained from PostGIS
@@ -691,7 +698,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
             # Constructing the new shell by adding 500 to every point in the old shell.
             shell_tup = poly.shell.tuple
             new_coords = []
-            for point in shell_tup: new_coords.append((point[0] + 500., point[1] + 500.))
+            for point in shell_tup:
+                new_coords.append((point[0] + 500., point[1] + 500.))
             new_shell = LinearRing(*tuple(new_coords))
 
             # Assigning polygon's exterior ring w/the new shell
@@ -724,7 +732,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
                 # Offsetting the each ring in the polygon by 500.
                 for j in xrange(len(poly)):
                     r = poly[j]
-                    for k in xrange(len(r)): r[k] = (r[k][0] + 500., r[k][1] + 500.)
+                    for k in xrange(len(r)):
+                        r[k] = (r[k][0] + 500., r[k][1] + 500.)
                     poly[j] = r
 
                 self.assertNotEqual(mpoly[i], poly)
@@ -1017,7 +1026,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
             g1, g2 = cPickle.loads(s1), pickle.loads(s2)
             for tmpg in (g1, g2):
                 self.assertEqual(geom, tmpg)
-                if not no_srid: self.assertEqual(geom.srid, tmpg.srid)
+                if not no_srid:
+                    self.assertEqual(geom.srid, tmpg.srid)
 
     @skipUnless(HAS_GEOS and GEOS_PREPARE, "geos >= 3.1.0 is required")
     def test_prepared(self):
diff --git a/django/contrib/gis/geos/tests/test_geos_mutation.py b/django/contrib/gis/geos/tests/test_geos_mutation.py
index 38c80e3bdd..1aa9a1db32 100644
--- a/django/contrib/gis/geos/tests/test_geos_mutation.py
+++ b/django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -12,26 +12,57 @@ if HAS_GEOS:
     from ..error import GEOSIndexError
 
 
-def getItem(o,i): return o[i]
-def delItem(o,i): del o[i]
-def setItem(o,i,v): o[i] = v
+def getItem(o,i):
+    return o[i]
+
+def delItem(o,i):
+    del o[i]
+
+def setItem(o,i,v):
+    o[i] = v
 
 if HAS_GEOS:
-    def api_get_distance(x): return x.distance(Point(-200,-200))
+    def api_get_distance(x):
+        return x.distance(Point(-200,-200))
 
-def api_get_buffer(x): return x.buffer(10)
-def api_get_geom_typeid(x): return x.geom_typeid
-def api_get_num_coords(x): return x.num_coords
-def api_get_centroid(x): return x.centroid
-def api_get_empty(x): return x.empty
-def api_get_valid(x): return x.valid
-def api_get_simple(x): return x.simple
-def api_get_ring(x): return x.ring
-def api_get_boundary(x): return x.boundary
-def api_get_convex_hull(x): return x.convex_hull
-def api_get_extent(x): return x.extent
-def api_get_area(x): return x.area
-def api_get_length(x): return x.length
+def api_get_buffer(x):
+    return x.buffer(10)
+
+def api_get_geom_typeid(x):
+    return x.geom_typeid
+
+def api_get_num_coords(x):
+    return x.num_coords
+
+def api_get_centroid(x):
+    return x.centroid
+
+def api_get_empty(x):
+    return x.empty
+
+def api_get_valid(x):
+    return x.valid
+
+def api_get_simple(x):
+    return x.simple
+
+def api_get_ring(x):
+    return x.ring
+
+def api_get_boundary(x):
+    return x.boundary
+
+def api_get_convex_hull(x):
+    return x.convex_hull
+
+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__')
@@ -48,7 +79,8 @@ class GEOSMutationTest(unittest.TestCase):
     def test00_GEOSIndexException(self):
         'Testing Geometry GEOSIndexError'
         p = Point(1,2)
-        for i in range(-2,2): p._checkindex(i)
+        for i in range(-2,2):
+            p._checkindex(i)
         self.assertRaises(GEOSIndexError, p._checkindex, 2)
         self.assertRaises(GEOSIndexError, p._checkindex, -3)
 
diff --git a/django/contrib/gis/geos/tests/test_mutable_list.py b/django/contrib/gis/geos/tests/test_mutable_list.py
index 1a3bc16d30..3cf1daf12a 100644
--- a/django/contrib/gis/geos/tests/test_mutable_list.py
+++ b/django/contrib/gis/geos/tests/test_mutable_list.py
@@ -59,7 +59,8 @@ class ListMixinTest(unittest.TestCase):
     listType = UserListA
 
     def lists_of_len(self, length=None):
-        if length is None: length = self.limit
+        if length is None:
+            length = self.limit
         pl = list(range(length))
         return pl, self.listType(pl)
 
@@ -90,7 +91,8 @@ class ListMixinTest(unittest.TestCase):
 
     def test02_setslice(self):
         'Slice assignment'
-        def setfcn(x,i,j,k,L): x[i:j:k] = range(L)
+        def setfcn(x,i,j,k,L):
+            x[i:j:k] = range(L)
         pl, ul = self.lists_of_len()
         for slen in range(self.limit + 1):
             ssl = nextRange(slen)
@@ -208,9 +210,12 @@ class ListMixinTest(unittest.TestCase):
 
     def test05_out_of_range_exceptions(self):
         'Out of range exceptions'
-        def setfcn(x, i): x[i] = 20
-        def getfcn(x, i): return x[i]
-        def delfcn(x, i): del x[i]
+        def setfcn(x, i):
+            x[i] = 20
+        def getfcn(x, i):
+            return x[i]
+        def delfcn(x, i):
+            del x[i]
         pl, ul = self.lists_of_len()
         for i in (-1 - self.limit, self.limit):
             self.assertRaises(IndexError, setfcn, ul, i) # 'set index %d' % i)
@@ -248,7 +253,8 @@ class ListMixinTest(unittest.TestCase):
         self.assertEqual(pl[:], ul[:], 'after pop')
 
         pl, ul = self.lists_of_len()
-        def popfcn(x, i): x.pop(i)
+        def popfcn(x, i):
+            x.pop(i)
         self.assertRaises(IndexError, popfcn, ul, self.limit)
         self.assertRaises(IndexError, popfcn, ul, -1 - self.limit)
 
@@ -265,8 +271,10 @@ class ListMixinTest(unittest.TestCase):
             ul.remove(val)
             self.assertEqual(pl[:], ul[:], 'after remove val %d' % val)
 
-        def indexfcn(x, v): return x.index(v)
-        def removefcn(x, v): return x.remove(v)
+        def indexfcn(x, v):
+            return x.index(v)
+        def removefcn(x, v):
+            return x.remove(v)
         self.assertRaises(ValueError, indexfcn, ul, 40)
         self.assertRaises(ValueError, removefcn, ul, 40)
 
@@ -276,7 +284,8 @@ class ListMixinTest(unittest.TestCase):
         ul._allowed = six.integer_types
         ul[1] = 50
         ul[:2] = [60, 70, 80]
-        def setfcn(x, i, v): x[i] = v
+        def setfcn(x, i, v):
+            x[i] = v
         self.assertRaises(TypeError, setfcn, ul, 2, 'hello')
         self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), ('hello','goodbye'))
 
@@ -284,8 +293,10 @@ class ListMixinTest(unittest.TestCase):
         'Length limits'
         pl, ul = self.lists_of_len()
         ul._minlength = 1
-        def delfcn(x,i): del x[:i]
-        def setfcn(x,i): x[:i] = []
+        def delfcn(x,i):
+            del x[:i]
+        def setfcn(x,i):
+            x[:i] = []
         for i in range(self.limit - ul._minlength + 1, self.limit + 1):
             self.assertRaises(ValueError, delfcn, ul, i)
             self.assertRaises(ValueError, setfcn, ul, i)
@@ -299,7 +310,8 @@ class ListMixinTest(unittest.TestCase):
     def test09_iterable_check(self):
         'Error on assigning non-iterable to slice'
         pl, ul = self.lists_of_len(self.limit + 1)
-        def setfcn(x, i, v): x[i] = v
+        def setfcn(x, i, v):
+            x[i] = v
         self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), 2)
 
     def test10_checkindex(self):
diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py
index 39c0c5516b..0128581da4 100644
--- a/django/contrib/gis/maps/google/gmap.py
+++ b/django/contrib/gis/maps/google/gmap.py
@@ -87,9 +87,11 @@ class GoogleMap(object):
 
         # Defaults for the zoom level and center coordinates if the zoom
         # is not automatically calculated.
-        if zoom is None: zoom = 4
+        if zoom is None:
+            zoom = 4
         self.zoom = zoom
-        if center is None: center = (0, 0)
+        if center is None:
+            center = (0, 0)
         self.center = center
 
     def render(self):
@@ -229,5 +231,6 @@ class GoogleMapSet(GoogleMap):
     def icons(self):
         "Returns a sequence of all icons in each map of the set."
         icons = set()
-        for map in self.maps: icons |= map.icons
+        for map in self.maps:
+            icons |= map.icons
         return icons
diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py
index 674f02d85f..0869f657a9 100644
--- a/django/contrib/gis/maps/google/overlays.py
+++ b/django/contrib/gis/maps/google/overlays.py
@@ -102,8 +102,10 @@ class GPolygon(GOverlayBase):
           fill_opacity:
             The opacity of the polygon fill.  Defaults to 0.4.
         """
-        if isinstance(poly, six.string_types): poly = fromstr(poly)
-        if isinstance(poly, (tuple, list)): poly = Polygon(poly)
+        if isinstance(poly, six.string_types):
+            poly = fromstr(poly)
+        if isinstance(poly, (tuple, list)):
+            poly = Polygon(poly)
         if not isinstance(poly, Polygon):
             raise TypeError('GPolygon may only initialize on GEOS Polygons.')
 
@@ -152,8 +154,10 @@ class GPolyline(GOverlayBase):
             The opacity of the polyline, between 0 and 1.  Defaults to 1.
         """
         # If a GEOS geometry isn't passed in, try to contsruct one.
-        if isinstance(geom, six.string_types): geom = fromstr(geom)
-        if isinstance(geom, (tuple, list)): geom = Polygon(geom)
+        if isinstance(geom, six.string_types):
+            geom = fromstr(geom)
+        if isinstance(geom, (tuple, list)):
+            geom = Polygon(geom)
         # Generating the lat/lng coordinate pairs.
         if isinstance(geom, (LineString, LinearRing)):
             self.latlngs = self.latlng_from_coords(geom.coords)
@@ -282,8 +286,10 @@ class GMarker(GOverlayBase):
            Draggable option for GMarker, disabled by default.
         """
         # If a GEOS geometry isn't passed in, try to construct one.
-        if isinstance(geom, six.string_types): geom = fromstr(geom)
-        if isinstance(geom, (tuple, list)): geom = Point(geom)
+        if isinstance(geom, six.string_types):
+            geom = fromstr(geom)
+        if isinstance(geom, (tuple, list)):
+            geom = Point(geom)
         if isinstance(geom, Point):
             self.latlng = self.latlng_from_coords(geom.coords)
         else:
@@ -301,9 +307,12 @@ class GMarker(GOverlayBase):
 
     def options(self):
         result = []
-        if self.title: result.append('title: "%s"' % self.title)
-        if self.icon: result.append('icon: %s' % self.icon.varname)
-        if self.draggable: result.append('draggable: true')
+        if self.title:
+            result.append('title: "%s"' % self.title)
+        if self.icon:
+            result.append('icon: %s' % self.icon.varname)
+        if self.draggable:
+            result.append('draggable: true')
         return '{%s}' % ','.join(result)
 
     @property
diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py
index 9f4e968732..c9bc86a26b 100644
--- a/django/contrib/gis/measure.py
+++ b/django/contrib/gis/measure.py
@@ -179,7 +179,8 @@ class MeasureBase(object):
         val = 0.0
         default_unit = self.STANDARD_UNIT
         for unit, value in six.iteritems(kwargs):
-            if not isinstance(value, float): value = float(value)
+            if not isinstance(value, float):
+                value = float(value)
             if unit in self.UNITS:
                 val += self.UNITS[unit] * value
                 default_unit = unit
diff --git a/django/contrib/gis/sitemaps/georss.py b/django/contrib/gis/sitemaps/georss.py
index 7dd2701221..5201de913b 100644
--- a/django/contrib/gis/sitemaps/georss.py
+++ b/django/contrib/gis/sitemaps/georss.py
@@ -27,7 +27,8 @@ class GeoRSSSitemap(Sitemap):
         # Setting up.
         self.feed_dict = feed_dict
         self.locations = []
-        if slug_dict is None: slug_dict = {}
+        if slug_dict is None:
+            slug_dict = {}
         # Getting the feed locations.
         for section in feed_dict.keys():
             if slug_dict.get(section, False):
@@ -42,7 +43,8 @@ class GeoRSSSitemap(Sitemap):
         is placed on each URL element.
         """
         urls = Sitemap.get_urls(self, page=page, site=site)
-        for url in urls: url['geo_format'] = 'georss'
+        for url in urls:
+            url['geo_format'] = 'georss'
         return urls
 
     def items(self):
diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py
index dd12429ed6..1f3a567025 100644
--- a/django/contrib/gis/sitemaps/kml.py
+++ b/django/contrib/gis/sitemaps/kml.py
@@ -46,7 +46,8 @@ class KMLSitemap(Sitemap):
         is placed on each URL element.
         """
         urls = Sitemap.get_urls(self, page=page, site=site)
-        for url in urls: url['geo_format'] = self.geo_format
+        for url in urls:
+            url['geo_format'] = self.geo_format
         return urls
 
     def items(self):
diff --git a/django/contrib/gis/tests/distapp/models.py b/django/contrib/gis/tests/distapp/models.py
index bf08829eae..cc98d9b556 100644
--- a/django/contrib/gis/tests/distapp/models.py
+++ b/django/contrib/gis/tests/distapp/models.py
@@ -7,7 +7,9 @@ class SouthTexasCity(models.Model):
     name = models.CharField(max_length=30)
     point = models.PointField(srid=32140)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class SouthTexasCityFt(models.Model):
@@ -15,7 +17,9 @@ class SouthTexasCityFt(models.Model):
     name = models.CharField(max_length=30)
     point = models.PointField(srid=2278)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class AustraliaCity(models.Model):
@@ -23,7 +27,9 @@ class AustraliaCity(models.Model):
     name = models.CharField(max_length=30)
     point = models.PointField()
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class CensusZipcode(models.Model):
@@ -31,7 +37,9 @@ class CensusZipcode(models.Model):
     name = models.CharField(max_length=5)
     poly = models.PolygonField(srid=4269)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class SouthTexasZipcode(models.Model):
@@ -39,7 +47,9 @@ class SouthTexasZipcode(models.Model):
     name = models.CharField(max_length=5)
     poly = models.PolygonField(srid=32140, null=True)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class Interstate(models.Model):
@@ -47,7 +57,9 @@ class Interstate(models.Model):
     name = models.CharField(max_length=10)
     path = models.LineStringField()
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class SouthTexasInterstate(models.Model):
@@ -55,4 +67,6 @@ class SouthTexasInterstate(models.Model):
     name = models.CharField(max_length=10)
     path = models.LineStringField(srid=32140)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py
index e9298b97e1..8db977e025 100644
--- a/django/contrib/gis/tests/distapp/tests.py
+++ b/django/contrib/gis/tests/distapp/tests.py
@@ -66,8 +66,10 @@ class DistanceTest(TestCase):
         # Performing distance queries on two projected coordinate systems one
         # with units in meters and the other in units of U.S. survey feet.
         for dist in tx_dists:
-            if isinstance(dist, tuple): dist1, dist2 = dist
-            else: dist1 = dist2 = dist
+            if isinstance(dist, tuple):
+                dist1, dist2 = dist
+            else:
+                dist1 = dist2 = dist
             qs1 = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist1))
             qs2 = SouthTexasCityFt.objects.filter(point__dwithin=(self.stx_pnt, dist2))
             for qs in qs1, qs2:
@@ -75,12 +77,16 @@ class DistanceTest(TestCase):
 
         # Now performing the `dwithin` queries on a geodetic coordinate system.
         for dist in au_dists:
-            if isinstance(dist, D) and not oracle: type_error = True
-            else: type_error = False
+            if isinstance(dist, D) and not oracle:
+                type_error = True
+            else:
+                type_error = False
 
             if isinstance(dist, tuple):
-                if oracle: dist = dist[1]
-                else: dist = dist[0]
+                if oracle:
+                    dist = dist[1]
+                else:
+                    dist = dist[0]
 
             # Creating the query set.
             qs = AustraliaCity.objects.order_by('name')
diff --git a/django/contrib/gis/tests/geoadmin/models.py b/django/contrib/gis/tests/geoadmin/models.py
index af0898823d..f995bbf5c5 100644
--- a/django/contrib/gis/tests/geoadmin/models.py
+++ b/django/contrib/gis/tests/geoadmin/models.py
@@ -7,6 +7,8 @@ class City(models.Model):
     name = models.CharField(max_length=30)
     point = models.PointField()
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 admin.site.register(City, admin.OSMGeoAdmin)
diff --git a/django/contrib/gis/tests/geoapp/models.py b/django/contrib/gis/tests/geoapp/models.py
index fa83859063..90ece4d96c 100644
--- a/django/contrib/gis/tests/geoapp/models.py
+++ b/django/contrib/gis/tests/geoapp/models.py
@@ -10,14 +10,18 @@ class Country(models.Model):
     name = models.CharField(max_length=30)
     mpoly = models.MultiPolygonField() # SRID, by default, is 4326
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class City(models.Model):
     name = models.CharField(max_length=30)
     point = models.PointField()
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 # This is an inherited model from City
 class PennsylvaniaCity(City):
@@ -30,14 +34,18 @@ class State(models.Model):
     name = models.CharField(max_length=30)
     poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class Track(models.Model):
     name = models.CharField(max_length=30)
     line = models.LineStringField()
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 class Truth(models.Model):
     val = models.BooleanField(default=False)
@@ -49,7 +57,9 @@ if not spatialite:
         name = models.CharField(max_length=20)
         geom = models.GeometryField()
         objects = models.GeoManager()
-        def __str__(self): return self.name
+
+        def __str__(self):
+            return self.name
 
     class MinusOneSRID(models.Model):
         geom = models.PointField(srid=-1) # Minus one SRID.
diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py
index 2ef8a5349c..15f5936dd6 100644
--- a/django/contrib/gis/tests/geoapp/tests.py
+++ b/django/contrib/gis/tests/geoapp/tests.py
@@ -190,7 +190,8 @@ class GeoModelTest(TestCase):
         qs = PennsylvaniaCity.objects.transform(32128)
 
         self.assertEqual(1, qs.count())
-        for pc in qs: self.assertEqual(32128, pc.point.srid)
+        for pc in qs:
+            self.assertEqual(32128, pc.point.srid)
 
     def test_raw_sql_query(self):
         "Testing raw SQL query."
@@ -229,7 +230,8 @@ class GeoLookupTest(TestCase):
             qs = City.objects.filter(point__contained=texas.mpoly)
             self.assertEqual(3, qs.count())
             cities = ['Houston', 'Dallas', 'Oklahoma City']
-            for c in qs: self.assertEqual(True, c.name in cities)
+            for c in qs:
+                self.assertEqual(True, c.name in cities)
 
         # Pulling out some cities.
         houston = City.objects.get(name='Houston')
@@ -284,13 +286,15 @@ class GeoLookupTest(TestCase):
                   'Lawrence', 'Chicago', 'Wellington']
         qs = City.objects.filter(point__right=co_border)
         self.assertEqual(6, len(qs))
-        for c in qs: self.assertEqual(True, c.name in cities)
+        for c in qs:
+            self.assertEqual(True, c.name in cities)
 
         # These cities should be strictly to the right of the KS border.
         cities = ['Chicago', 'Wellington']
         qs = City.objects.filter(point__right=ks_border)
         self.assertEqual(2, len(qs))
-        for c in qs: self.assertEqual(True, c.name in cities)
+        for c in qs:
+            self.assertEqual(True, c.name in cities)
 
         # Note: Wellington has an 'X' value of 174, so it will not be considered
         #  to the left of CO.
@@ -300,7 +304,8 @@ class GeoLookupTest(TestCase):
         cities = ['Pueblo', 'Victoria']
         qs = City.objects.filter(point__left=ks_border)
         self.assertEqual(2, len(qs))
-        for c in qs: self.assertEqual(True, c.name in cities)
+        for c in qs:
+            self.assertEqual(True, c.name in cities)
 
     # The left/right lookup tests are known failures on PostGIS 2.0/2.0.1
     # http://trac.osgeo.org/postgis/ticket/2035
@@ -313,7 +318,8 @@ class GeoLookupTest(TestCase):
         c1 = City.objects.get(point=pnt)
         c2 = City.objects.get(point__same_as=pnt)
         c3 = City.objects.get(point__equals=pnt)
-        for c in [c1, c2, c3]: self.assertEqual('Houston', c.name)
+        for c in [c1, c2, c3]:
+            self.assertEqual('Houston', c.name)
 
     @no_mysql
     def test_null_geometries(self):
@@ -476,7 +482,8 @@ class GeoQuerySetTest(TestCase):
     @no_spatialite
     def test_geohash(self):
         "Testing GeoQuerySet.geohash()."
-        if not connection.ops.geohash: return
+        if not connection.ops.geohash:
+            return
         # Reference query:
         # SELECT ST_GeoHash(point) FROM geoapp_city WHERE name='Houston';
         # SELECT ST_GeoHash(point, 5) FROM geoapp_city WHERE name='Houston';
@@ -619,7 +626,8 @@ class GeoQuerySetTest(TestCase):
 
         if not oracle:
             # Oracle cannot count vertices in Point geometries.
-            for c in City.objects.num_points(): self.assertEqual(1, c.num_points)
+            for c in City.objects.num_points():
+                self.assertEqual(1, c.num_points)
 
     @no_mysql
     def test_point_on_surface(self):
diff --git a/django/contrib/gis/tests/geogapp/models.py b/django/contrib/gis/tests/geogapp/models.py
index 7e802f9321..3b7efeebd3 100644
--- a/django/contrib/gis/tests/geogapp/models.py
+++ b/django/contrib/gis/tests/geogapp/models.py
@@ -6,14 +6,18 @@ class City(models.Model):
     name = models.CharField(max_length=30)
     point = models.PointField(geography=True)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 @python_2_unicode_compatible
 class Zipcode(models.Model):
     code = models.CharField(max_length=10)
     poly = models.PolygonField(geography=True)
     objects = models.GeoManager()
-    def __str__(self): return self.code
+
+    def __str__(self):
+        return self.code
 
 @python_2_unicode_compatible
 class County(models.Model):
@@ -21,4 +25,6 @@ class County(models.Model):
     state = models.CharField(max_length=20)
     mpoly = models.MultiPolygonField(geography=True)
     objects = models.GeoManager()
-    def __str__(self): return ' County, '.join([self.name, self.state])
+
+    def __str__(self):
+        return ' County, '.join([self.name, self.state])
diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
index c2101ba8c7..a77a3841fc 100644
--- a/django/contrib/gis/tests/layermap/tests.py
+++ b/django/contrib/gis/tests/layermap/tests.py
@@ -208,7 +208,8 @@ class LayerMapTest(TestCase):
     def test_test_fid_range_step(self):
         "Tests the `fid_range` keyword and the `step` keyword of .save()."
         # Function for clearing out all the counties before testing.
-        def clear_counties(): County.objects.all().delete()
+        def clear_counties():
+            County.objects.all().delete()
 
         State.objects.bulk_create([
             State(name='Colorado'), State(name='Hawaii'), State(name='Texas')
diff --git a/django/contrib/gis/tests/relatedapp/models.py b/django/contrib/gis/tests/relatedapp/models.py
index 5fc5e1377d..8c4112f38a 100644
--- a/django/contrib/gis/tests/relatedapp/models.py
+++ b/django/contrib/gis/tests/relatedapp/models.py
@@ -5,7 +5,9 @@ from django.utils.encoding import python_2_unicode_compatible
 class Location(models.Model):
     point = models.PointField()
     objects = models.GeoManager()
-    def __str__(self): return self.point.wkt
+
+    def __str__(self):
+        return self.point.wkt
 
 @python_2_unicode_compatible
 class City(models.Model):
@@ -13,7 +15,9 @@ class City(models.Model):
     state = models.CharField(max_length=2)
     location = models.ForeignKey(Location)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 class AugmentedLocation(Location):
     extra_text = models.TextField(blank=True)
@@ -34,7 +38,9 @@ class Parcel(models.Model):
     border1 = models.PolygonField()
     border2 = models.PolygonField(srid=2276)
     objects = models.GeoManager()
-    def __str__(self): return self.name
+
+    def __str__(self):
+        return self.name
 
 # These use the GeoManager but do not have any geographic fields.
 class Author(models.Model):
diff --git a/django/contrib/gis/tests/relatedapp/tests.py b/django/contrib/gis/tests/relatedapp/tests.py
index 341165d602..b165699e22 100644
--- a/django/contrib/gis/tests/relatedapp/tests.py
+++ b/django/contrib/gis/tests/relatedapp/tests.py
@@ -79,7 +79,8 @@ class RelatedGeoModelTest(TestCase):
         # between the Oracle and PostGIS spatial backends on the extent calculation.
         tol = 4
         for ref, e in [(all_extent, e1), (txpa_extent, e2), (all_extent, e3)]:
-            for ref_val, e_val in zip(ref, e): self.assertAlmostEqual(ref_val, e_val, tol)
+            for ref_val, e_val in zip(ref, e):
+                self.assertAlmostEqual(ref_val, e_val, tol)
 
     @no_mysql
     def test04b_related_union_aggregate(self):
diff --git a/django/contrib/gis/tests/utils.py b/django/contrib/gis/tests/utils.py
index 62d83cf9e3..1868b30b68 100644
--- a/django/contrib/gis/tests/utils.py
+++ b/django/contrib/gis/tests/utils.py
@@ -16,10 +16,17 @@ def no_backend(test_func, backend):
 
 # Decorators to disable entire test functions for specific
 # spatial backends.
-def no_oracle(func): return no_backend(func, 'oracle')
-def no_postgis(func): return no_backend(func, 'postgis')
-def no_mysql(func): return no_backend(func, 'mysql')
-def no_spatialite(func): return no_backend(func, 'spatialite')
+def no_oracle(func):
+    return no_backend(func, 'oracle')
+
+def no_postgis(func):
+    return no_backend(func, 'postgis')
+
+def no_mysql(func):
+    return no_backend(func, 'mysql')
+
+def no_spatialite(func):
+    return no_backend(func, 'spatialite')
 
 # Shortcut booleans to omit only portions of tests.
 _default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1]
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index 8b7b451e51..4c11f9dbfa 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -21,11 +21,20 @@ from django.utils.encoding import force_text
 
 
 # LayerMapping exceptions.
-class LayerMapError(Exception): pass
-class InvalidString(LayerMapError): pass
-class InvalidDecimal(LayerMapError): pass
-class InvalidInteger(LayerMapError): pass
-class MissingForeignKey(LayerMapError): pass
+class LayerMapError(Exception):
+    pass
+
+class InvalidString(LayerMapError):
+    pass
+
+class InvalidDecimal(LayerMapError):
+    pass
+
+class InvalidInteger(LayerMapError):
+    pass
+
+class MissingForeignKey(LayerMapError):
+    pass
 
 class LayerMapping(object):
     "A class that maps OGR Layers to GeoDjango Models."
@@ -263,10 +272,12 @@ class LayerMapping(object):
         if isinstance(unique, (list, tuple)):
             # List of fields to determine uniqueness with
             for attr in unique:
-                if not attr in self.mapping: raise ValueError
+                if not attr in self.mapping:
+                    raise ValueError
         elif isinstance(unique, six.string_types):
             # Only a single field passed in.
-            if unique not in self.mapping: raise ValueError
+            if unique not in self.mapping:
+                raise ValueError
         else:
             raise TypeError('Unique keyword argument must be set with a tuple, list, or string.')
 
@@ -413,7 +424,8 @@ class LayerMapping(object):
         # Transforming the geometry with our Coordinate Transformation object,
         # but only if the class variable `transform` is set w/a CoordTransform
         # object.
-        if self.transform: g.transform(self.transform)
+        if self.transform:
+            g.transform(self.transform)
 
         # Returning the WKT of the geometry.
         return g.wkt
@@ -512,7 +524,8 @@ class LayerMapping(object):
                     kwargs = self.feature_kwargs(feat)
                 except LayerMapError as msg:
                     # Something borked the validation
-                    if strict: raise
+                    if strict:
+                        raise
                     elif not silent:
                         stream.write('Ignoring Feature ID %s because: %s\n' % (feat.fid, msg))
                 else:
@@ -534,7 +547,8 @@ class LayerMapping(object):
                             # just-updated geometry WKT.
                             geom = getattr(m, self.geom_field).ogr
                             new = OGRGeometry(kwargs[self.geom_field])
-                            for g in new: geom.add(g)
+                            for g in new:
+                                geom.add(g)
                             setattr(m, self.geom_field, geom.wkt)
                         except ObjectDoesNotExist:
                             # No unique model exists yet, create.
@@ -546,7 +560,8 @@ class LayerMapping(object):
                         # Attempting to save.
                         m.save(using=self.using)
                         num_saved += 1
-                        if verbose: stream.write('%s: %s\n' % ('Updated' if is_update else 'Saved', m))
+                        if verbose:
+                            stream.write('%s: %s\n' % ('Updated' if is_update else 'Saved', m))
                     except Exception as msg:
                         if strict:
                             # Bailing out if the `strict` keyword is set.
@@ -580,8 +595,10 @@ class LayerMapping(object):
             for i, end in enumerate(indices):
                 # Constructing the slice to use for this step; the last slice is
                 # special (e.g, [100:] instead of [90:100]).
-                if i+1 == n_i: step_slice = slice(beg, None)
-                else: step_slice = slice(beg, end)
+                if i+1 == n_i:
+                    step_slice = slice(beg, None)
+                else:
+                    step_slice = slice(beg, end)
 
                 try:
                     num_feat, num_saved = _save(step_slice, num_feat, num_saved)
diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py
index b7cfafd49d..565bb70645 100644
--- a/django/contrib/gis/utils/ogrinspect.py
+++ b/django/contrib/gis/utils/ogrinspect.py
@@ -37,11 +37,14 @@ def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
     # Generating the field name for each field in the layer.
     for field in data_source[layer_key].fields:
         mfield = field.lower()
-        if mfield[-1:] == '_': mfield += 'field'
+        if mfield[-1:] == '_':
+            mfield += 'field'
         _mapping[mfield] = field
     gtype = data_source[layer_key].geom_type
-    if multi_geom and gtype.num in (1, 2, 3): prefix = 'MULTI'
-    else: prefix = ''
+    if multi_geom and gtype.num in (1, 2, 3):
+        prefix = 'MULTI'
+    else:
+        prefix = ''
     _mapping[geom_name] = prefix + str(gtype).upper()
     return _mapping
 
@@ -151,10 +154,14 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
     # Gets the `null` and `blank` keywords for the given field name.
     def get_kwargs_str(field_name):
         kwlist = []
-        if field_name.lower() in null_fields: kwlist.append('null=True')
-        if field_name.lower() in blank_fields: kwlist.append('blank=True')
-        if kwlist: return ', ' + ', '.join(kwlist)
-        else: return ''
+        if field_name.lower() in null_fields:
+            kwlist.append('null=True')
+        if field_name.lower() in blank_fields:
+            kwlist.append('blank=True')
+        if kwlist:
+            return ', ' + ', '.join(kwlist)
+        else:
+            return ''
 
     # For those wishing to disable the imports.
     if imports:
@@ -167,7 +174,8 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
     for field_name, width, precision, field_type in zip(ogr_fields, layer.field_widths, layer.field_precisions, layer.field_types):
         # The model field name.
         mfield = field_name.lower()
-        if mfield[-1:] == '_': mfield += 'field'
+        if mfield[-1:] == '_':
+            mfield += 'field'
 
         # Getting the keyword args string.
         kwargs_str = get_kwargs_str(field_name)
diff --git a/django/core/management/color.py b/django/core/management/color.py
index 708823705b..21826c6b68 100644
--- a/django/core/management/color.py
+++ b/django/core/management/color.py
@@ -27,7 +27,8 @@ def color_style():
         DJANGO_COLORS = os.environ.get('DJANGO_COLORS', '')
         color_settings = termcolors.parse_color_setting(DJANGO_COLORS)
         if color_settings:
-            class dummy: pass
+            class dummy:
+                pass
             style = dummy()
             # The nocolor palette has all available roles.
             # Use that palette as the basis for populating
diff --git a/django/forms/utils.py b/django/forms/utils.py
index bb5bb8c2e4..106074be5c 100644
--- a/django/forms/utils.py
+++ b/django/forms/utils.py
@@ -48,7 +48,8 @@ class ErrorDict(dict):
         return self.as_ul()
 
     def as_ul(self):
-        if not self: return ''
+        if not self:
+            return ''
         return format_html('<ul class="errorlist">{0}</ul>',
                            format_html_join('', '<li>{0}{1}</li>',
                                             ((k, force_text(v))
@@ -67,7 +68,8 @@ class ErrorList(list):
         return self.as_ul()
 
     def as_ul(self):
-        if not self: return ''
+        if not self:
+            return ''
         return format_html('<ul class="errorlist">{0}</ul>',
                            format_html_join('', '<li>{0}</li>',
                                             ((force_text(e),) for e in self)
@@ -75,7 +77,8 @@ class ErrorList(list):
                            )
 
     def as_text(self):
-        if not self: return ''
+        if not self:
+            return ''
         return '\n'.join('* %s' % force_text(e) for e in self)
 
     def __repr__(self):
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index e80584a5c7..2878a369e0 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -273,7 +273,8 @@ class PasswordInput(TextInput):
         self.render_value = render_value
 
     def render(self, name, value, attrs=None):
-        if not self.render_value: value=None
+        if not self.render_value:
+            value=None
         return super(PasswordInput, self).render(name, value, attrs)
 
 class HiddenInput(Input):
@@ -291,7 +292,8 @@ class MultipleHiddenInput(HiddenInput):
         self.choices = choices
 
     def render(self, name, value, attrs=None, choices=()):
-        if value is None: value = []
+        if value is None:
+            value = []
         final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
         id_ = final_attrs.get('id', None)
         inputs = []
@@ -394,7 +396,8 @@ class Textarea(Widget):
         super(Textarea, self).__init__(default_attrs)
 
     def render(self, name, value, attrs=None):
-        if value is None: value = ''
+        if value is None:
+            value = ''
         final_attrs = self.build_attrs(attrs, name=name)
         return format_html('<textarea{0}>\r\n{1}</textarea>',
                            flatatt(final_attrs),
@@ -469,7 +472,8 @@ class Select(Widget):
         self.choices = list(choices)
 
     def render(self, name, value, attrs=None, choices=()):
-        if value is None: value = ''
+        if value is None:
+            value = ''
         final_attrs = self.build_attrs(attrs, name=name)
         output = [format_html('<select{0}>', flatatt(final_attrs))]
         options = self.render_options(choices, [value])
@@ -539,7 +543,8 @@ class SelectMultiple(Select):
     allow_multiple_selected = True
 
     def render(self, name, value, attrs=None, choices=()):
-        if value is None: value = []
+        if value is None:
+            value = []
         final_attrs = self.build_attrs(attrs, name=name)
         output = [format_html('<select multiple="multiple"{0}>', flatatt(final_attrs))]
         options = self.render_options(choices, value)
diff --git a/django/utils/text.py b/django/utils/text.py
index 50713193dd..66a18b75d6 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -234,8 +234,10 @@ def get_text_list(list_, last_word=ugettext_lazy('or')):
     >>> get_text_list([])
     ''
     """
-    if len(list_) == 0: return ''
-    if len(list_) == 1: return force_text(list_[0])
+    if len(list_) == 0:
+        return ''
+    if len(list_) == 1:
+        return force_text(list_[0])
     return '%s %s %s' % (
         # Translators: This string is used as a separator between list elements
         _(', ').join(force_text(i) for i in list_[:-1]),
diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
index 7746392097..88c77a5110 100644
--- a/django/utils/translation/trans_null.py
+++ b/django/utils/translation/trans_null.py
@@ -7,7 +7,8 @@ from django.utils.encoding import force_text
 from django.utils.safestring import mark_safe, SafeData
 
 def ngettext(singular, plural, number):
-    if number == 1: return singular
+    if number == 1:
+        return singular
     return plural
 ngettext_lazy = ngettext
 
diff --git a/django/utils/xmlutils.py b/django/utils/xmlutils.py
index a1eb5fb753..a09fcb0f6b 100644
--- a/django/utils/xmlutils.py
+++ b/django/utils/xmlutils.py
@@ -7,7 +7,8 @@ from xml.sax.saxutils import XMLGenerator
 class SimplerXMLGenerator(XMLGenerator):
     def addQuickElement(self, name, contents=None, attrs=None):
         "Convenience method for adding an element with no children"
-        if attrs is None: attrs = {}
+        if attrs is None:
+            attrs = {}
         self.startElement(name, attrs)
         if contents is not None:
             self.characters(contents)
diff --git a/setup.cfg b/setup.cfg
index 1eebbb21c6..9cbc9d1ce2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
 
 [flake8]
 exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py
-ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E121,E122,E203,E221,E227,E231,E261,E301,E303,E502,E701,F401,F403,F841,W601
+ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E121,E122,E203,E221,E227,E231,E261,E301,E303,E502,F401,F403,F841,W601
 
 [metadata]
 license-file = LICENSE
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py
index 2aaea49500..66a98faaf6 100644
--- a/tests/decorators/tests.py
+++ b/tests/decorators/tests.py
@@ -94,8 +94,11 @@ class DecoratorsTest(TestCase):
         callback = user_passes_test(test1)(callback)
         callback = user_passes_test(test2)(callback)
 
-        class DummyUser(object): pass
-        class DummyRequest(object): pass
+        class DummyUser(object):
+            pass
+
+        class DummyRequest(object):
+            pass
 
         request = DummyRequest()
         request.user = DummyUser()
diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py
index 2cfe6f3e36..818556ce7f 100644
--- a/tests/forms_tests/tests/test_error_messages.py
+++ b/tests/forms_tests/tests/test_error_messages.py
@@ -224,7 +224,8 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
                 return self.as_divs()
 
             def as_divs(self):
-                if not self: return ''
+                if not self:
+                    return ''
                 return mark_safe('<div class="error">%s</div>' % ''.join('<p>%s</p>' % e for e in self))
 
         # This form should print errors the default way.
diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py
index 136d11383f..f66241c7da 100644
--- a/tests/forms_tests/tests/test_extra.py
+++ b/tests/forms_tests/tests/test_extra.py
@@ -727,7 +727,8 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
                 return self.as_divs()
 
             def as_divs(self):
-                if not self: return ''
+                if not self:
+                    return ''
                 return '<div class="errorlist">%s</div>' % ''.join('<div class="error">%s</div>' % force_text(e) for e in self)
 
         class CommentForm(Form):
diff --git a/tests/forms_tests/tests/test_util.py b/tests/forms_tests/tests/test_util.py
index 87f9f0d048..5f0b549bdb 100644
--- a/tests/forms_tests/tests/test_util.py
+++ b/tests/forms_tests/tests/test_util.py
@@ -49,7 +49,8 @@ class FormsUtilTestCase(TestCase):
 
         @python_2_unicode_compatible
         class VeryBadError:
-            def __str__(self): return "A very bad error."
+            def __str__(self):
+                return "A very bad error."
 
         # Can take a non-string.
         self.assertHTMLEqual(str(ErrorList(ValidationError(VeryBadError()).messages)),