Ticket #20989: 0001-Fixed-20989-Removed-useless-explicit-list-comprehens.patch

File 0001-Fixed-20989-Removed-useless-explicit-list-comprehens.patch, 79.5 KB (added by Simon Charette, 11 years ago)
  • django/contrib/admin/filters.py

    From 2654119fd9604f480e09bbd77e1d780a8de9d85f Mon Sep 17 00:00:00 2001
    From: Simon Charette <charette.s@gmail.com>
    Date: Thu, 29 Aug 2013 19:20:00 -0400
    Subject: [PATCH] Fixed #20989 -- Removed useless explicit list comprehensions.
    
    ---
     django/contrib/admin/filters.py                    |  4 ++--
     django/contrib/admin/helpers.py                    |  2 +-
     django/contrib/admin/options.py                    |  6 ++---
     django/contrib/admin/widgets.py                    |  6 ++---
     django/contrib/admindocs/utils.py                  |  2 +-
     django/contrib/auth/backends.py                    |  4 ++--
     django/contrib/auth/forms.py                       |  4 ++--
     django/contrib/contenttypes/management.py          |  4 ++--
     django/contrib/gis/db/models/sql/aggregates.py     |  2 +-
     django/contrib/gis/feeds.py                        |  2 +-
     django/contrib/gis/gdal/geometries.py              | 10 ++++----
     django/contrib/gis/geos/collections.py             |  2 +-
     django/contrib/gis/geos/coordseq.py                |  4 ++--
     django/contrib/gis/geos/polygon.py                 |  6 ++---
     django/contrib/gis/geos/tests/test_geos.py         |  6 ++---
     .../contrib/gis/management/commands/ogrinspect.py  |  4 ++--
     django/contrib/gis/maps/google/gmap.py             |  2 +-
     django/contrib/gis/maps/google/overlays.py         |  2 +-
     django/contrib/gis/tests/geoadmin/tests.py         |  2 +-
     django/contrib/gis/tests/geoapp/test_feeds.py      |  2 +-
     django/contrib/gis/tests/geoapp/test_sitemaps.py   |  2 +-
     django/contrib/gis/utils/wkt.py                    | 10 ++++----
     django/contrib/messages/storage/cookie.py          |  4 ++--
     django/contrib/webdesign/lorem_ipsum.py            |  2 +-
     django/core/cache/utils.py                         |  2 +-
     django/core/management/__init__.py                 |  6 ++---
     django/core/management/commands/migrate.py         |  2 +-
     django/core/management/sql.py                      |  2 +-
     django/core/management/utils.py                    |  2 +-
     django/core/management/validation.py               |  2 +-
     django/core/urlresolvers.py                        |  6 ++---
     django/db/backends/__init__.py                     |  2 +-
     django/db/backends/mysql/compiler.py               |  2 +-
     django/db/backends/mysql/introspection.py          |  4 ++--
     django/db/backends/oracle/base.py                  |  8 +++----
     django/db/backends/oracle/introspection.py         |  2 +-
     django/db/backends/sqlite3/schema.py               |  4 ++--
     django/db/migrations/autodetector.py               |  4 ++--
     django/db/migrations/writer.py                     |  2 +-
     django/db/models/base.py                           |  4 ++--
     django/db/models/deletion.py                       |  4 ++--
     django/db/models/options.py                        |  2 +-
     django/db/models/query.py                          |  2 +-
     django/db/models/sql/aggregates.py                 |  2 +-
     django/db/models/sql/compiler.py                   |  8 +++----
     django/db/models/sql/query.py                      | 14 +++++------
     django/forms/fields.py                             |  4 ++--
     django/forms/formsets.py                           |  6 ++---
     django/forms/models.py                             |  6 ++---
     django/forms/util.py                               |  4 ++--
     django/template/base.py                            |  6 ++---
     django/template/defaulttags.py                     | 10 ++++----
     django/template/loader_tags.py                     |  8 +++----
     django/test/_doctest.py                            |  6 ++---
     django/utils/cache.py                              | 10 ++++----
     django/utils/checksums.py                          |  4 ++--
     django/utils/crypto.py                             |  2 +-
     django/utils/datastructures.py                     |  2 +-
     django/utils/html.py                               |  6 ++---
     django/utils/termcolors.py                         |  4 ++--
     django/utils/text.py                               |  2 +-
     django/utils/translation/__init__.py               |  2 +-
     tests/backends/tests.py                            |  2 +-
     tests/file_uploads/views.py                        |  4 ++--
     tests/forms_tests/tests/test_error_messages.py     |  2 +-
     tests/forms_tests/tests/test_extra.py              |  2 +-
     tests/forms_tests/tests/test_forms.py              |  6 ++---
     tests/forms_tests/tests/test_formsets.py           |  2 +-
     tests/forms_tests/tests/test_widgets.py            |  8 +++----
     tests/proxy_models/tests.py                        |  2 +-
     tests/schema/tests.py                              |  4 ++--
     tests/servers/views.py                             |  4 ++--
     tests/syndication/tests.py                         |  2 +-
     tests/template_tests/templatetags/custom.py        | 28 +++++++++++-----------
     tests/template_tests/tests.py                      |  2 +-
     75 files changed, 165 insertions(+), 165 deletions(-)
    
    diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
    index 3a37de2..2a9fb2a 100644
    a b FieldListFilter.register(lambda f: bool(f.choices), ChoicesFieldListFilter)  
    287287class DateFieldListFilter(FieldListFilter):
    288288    def __init__(self, field, request, params, model, model_admin, field_path):
    289289        self.field_generic = '%s__' % field_path
    290         self.date_params = dict([(k, v) for k, v in params.items()
    291                                  if k.startswith(self.field_generic)])
     290        self.date_params = dict((k, v) for k, v in params.items()
     291                                if k.startswith(self.field_generic))
    292292
    293293        now = timezone.now()
    294294        # When time zone support is enabled, convert "now" to the user's time
  • django/contrib/admin/helpers.py

    diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
    index b6d5bde..af1df5e 100644
    a b class Fieldline(object):  
    112112                yield AdminField(self.form, field, is_first=(i == 0))
    113113
    114114    def errors(self):
    115         return mark_safe('\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\n'))
     115        return mark_safe('\n'.join(self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields).strip('\n'))
    116116
    117117class AdminField(object):
    118118    def __init__(self, form, field, is_first):
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 8058683..d435675 100644
    a b class ModelAdmin(BaseModelAdmin):  
    698698            # Avoid trying to iterate over None
    699699            if not class_actions:
    700700                continue
    701             actions.extend([self.get_action(action) for action in class_actions])
     701            actions.extend(self.get_action(action) for action in class_actions)
    702702
    703703        # get_action might have returned None, so filter any of those out.
    704704        actions = filter(None, actions)
    705705
    706706        # Convert the actions into an OrderedDict keyed by name.
    707         actions = OrderedDict([
     707        actions = OrderedDict(
    708708            (name, (func, name, desc))
    709709            for func, name, desc in actions
    710         ])
     710        )
    711711
    712712        return actions
    713713
  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index 5773db6..e5b590e 100644
    a b def url_params_from_lookup_dict(lookups):  
    119119            if callable(v):
    120120                v = v()
    121121            if isinstance(v, (tuple, list)):
    122                 v = ','.join([str(x) for x in v])
     122                v = ','.join(str(x) for x in v)
    123123            elif isinstance(v, bool):
    124124                # See django.db.fields.BooleanField.get_prep_lookup
    125125                v = ('0', '1')[v]
    class ForeignKeyRawIdWidget(forms.TextInput):  
    154154
    155155            params = self.url_parameters()
    156156            if params:
    157                 url = '?' + '&amp;'.join(['%s=%s' % (k, v) for k, v in params.items()])
     157                url = '?' + '&amp;'.join('%s=%s' % (k, v) for k, v in params.items())
    158158            else:
    159159                url = ''
    160160            if "class" not in attrs:
    class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):  
    199199            # The related object is registered with the same AdminSite
    200200            attrs['class'] = 'vManyToManyRawIdAdminField'
    201201        if value:
    202             value = ','.join([force_text(v) for v in value])
     202            value = ','.join(force_text(v) for v in value)
    203203        else:
    204204            value = ''
    205205        return super(ManyToManyRawIdWidget, self).render(name, value, attrs)
  • django/contrib/admindocs/utils.py

    diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
    index 9be0093..c97d588 100644
    a b def trim_docstring(docstring):  
    2626        return ''
    2727    # Convert tabs to spaces and split into lines
    2828    lines = docstring.expandtabs().splitlines()
    29     indent = min([len(line) - len(line.lstrip()) for line in lines if line.lstrip()])
     29    indent = min(len(line) - len(line.lstrip()) for line in lines if line.lstrip())
    3030    trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]]
    3131    return "\n".join(trimmed).strip()
    3232
  • django/contrib/auth/backends.py

    diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
    index cb79291..7304ccd 100644
    a b class ModelBackend(object):  
    3636                user_groups_query = 'group__%s' % user_groups_field.related_query_name()
    3737                perms = Permission.objects.filter(**{user_groups_query: user_obj})
    3838            perms = perms.values_list('content_type__app_label', 'codename').order_by()
    39             user_obj._group_perm_cache = set(["%s.%s" % (ct, name) for ct, name in perms])
     39            user_obj._group_perm_cache = set("%s.%s" % (ct, name) for ct, name in perms)
    4040        return user_obj._group_perm_cache
    4141
    4242    def get_all_permissions(self, user_obj, obj=None):
    4343        if user_obj.is_anonymous() or obj is not None:
    4444            return set()
    4545        if not hasattr(user_obj, '_perm_cache'):
    46             user_obj._perm_cache = set(["%s.%s" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])
     46            user_obj._perm_cache = set("%s.%s" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related())
    4747            user_obj._perm_cache.update(self.get_group_permissions(user_obj))
    4848        return user_obj._perm_cache
    4949
  • django/contrib/auth/forms.py

    diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
    index 3eba8ab..474bade 100644
    a b class PasswordChangeForm(SetPasswordForm):  
    330330            )
    331331        return old_password
    332332
    333 PasswordChangeForm.base_fields = OrderedDict([
     333PasswordChangeForm.base_fields = OrderedDict(
    334334    (k, PasswordChangeForm.base_fields[k])
    335335    for k in ['old_password', 'new_password1', 'new_password2']
    336 ])
     336)
    337337
    338338
    339339class AdminPasswordChangeForm(forms.Form):
  • django/contrib/contenttypes/management.py

    diff --git a/django/contrib/contenttypes/management.py b/django/contrib/contenttypes/management.py
    index 4278bbd..3d2fc4b 100644
    a b def update_contenttypes(app, created_models, verbosity=2, db=DEFAULT_DB_ALIAS, *  
    5858    # Confirm that the content type is stale before deletion.
    5959    if to_remove:
    6060        if kwargs.get('interactive', False):
    61             content_type_display = '\n'.join([
     61            content_type_display = '\n'.join(
    6262                '    %s | %s' % (ct.app_label, ct.model)
    6363                for ct in to_remove
    64             ])
     64            )
    6565            ok_to_delete = input("""The following content types are stale and need to be deleted:
    6666
    6767%s
  • django/contrib/gis/db/models/sql/aggregates.py

    diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py
    index ae848c0..a3a8f12 100644
    a b class GeoAggregate(Aggregate):  
    3232        if hasattr(self.col, 'as_sql'):
    3333            field_name, params = self.col.as_sql(qn, connection)
    3434        elif isinstance(self.col, (list, tuple)):
    35             field_name = '.'.join([qn(c) for c in self.col])
     35            field_name = '.'.join(qn(c) for c in self.col)
    3636        else:
    3737            field_name = self.col
    3838
  • django/contrib/gis/feeds.py

    diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py
    index d7c52bf..89bc8c5 100644
    a b class GeoFeedMixin(object):  
    1515        a single white space.  Given a tuple of coordinates, this will return
    1616        a unicode GeoRSS representation.
    1717        """
    18         return ' '.join(['%f %f' % (coord[1], coord[0]) for coord in coords])
     18        return ' '.join('%f %f' % (coord[1], coord[0]) for coord in coords)
    1919
    2020    def add_georss_point(self, handler, coords, w3c_geo=False):
    2121        """
  • django/contrib/gis/gdal/geometries.py

    diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
    index c5a87f4..6f8c830 100644
    a b class LineString(OGRGeometry):  
    575575    @property
    576576    def tuple(self):
    577577        "Returns the tuple representation of this LineString."
    578         return tuple([self[i] for i in xrange(len(self))])
     578        return tuple(self[i] for i in xrange(len(self)))
    579579    coords = tuple
    580580
    581581    def _listarr(self, func):
    class Polygon(OGRGeometry):  
    632632    @property
    633633    def tuple(self):
    634634        "Returns a tuple of LinearRing coordinate tuples."
    635         return tuple([self[i].tuple for i in xrange(self.geom_count)])
     635        return tuple(self[i].tuple for i in xrange(self.geom_count))
    636636    coords = tuple
    637637
    638638    @property
    639639    def point_count(self):
    640640        "The number of Points in this Polygon."
    641641        # Summing up the number of points in each ring of the Polygon.
    642         return sum([self[i].point_count for i in xrange(self.geom_count)])
     642        return sum(self[i].point_count for i in xrange(self.geom_count))
    643643
    644644    @property
    645645    def centroid(self):
    class GeometryCollection(OGRGeometry):  
    686686    def point_count(self):
    687687        "The number of Points in this Geometry Collection."
    688688        # Summing up the number of points in each geometry in this collection
    689         return sum([self[i].point_count for i in xrange(self.geom_count)])
     689        return sum(self[i].point_count for i in xrange(self.geom_count))
    690690
    691691    @property
    692692    def tuple(self):
    693693        "Returns a tuple representation of this Geometry Collection."
    694         return tuple([self[i].tuple for i in xrange(self.geom_count)])
     694        return tuple(self[i].tuple for i in xrange(self.geom_count))
    695695    coords = tuple
    696696
    697697# Multiple Geometry types.
  • django/contrib/gis/geos/collections.py

    diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
    index 83153f8..70cb4e1 100644
    a b class GeometryCollection(GEOSGeometry):  
    8282    @property
    8383    def kml(self):
    8484        "Returns the KML for this Geometry Collection."
    85         return '<MultiGeometry>%s</MultiGeometry>' % ''.join([g.kml for g in self])
     85        return '<MultiGeometry>%s</MultiGeometry>' % ''.join(g.kml for g in self)
    8686
    8787    @property
    8888    def tuple(self):
  • django/contrib/gis/geos/coordseq.py

    diff --git a/django/contrib/gis/geos/coordseq.py b/django/contrib/gis/geos/coordseq.py
    index acf34f7..b28fb0c 100644
    a b class GEOSCoordSeq(GEOSBase):  
    147147        if self.hasz: substr = '%s,%s,%s '
    148148        else: substr = '%s,%s,0 '
    149149        return '<coordinates>%s</coordinates>' % \
    150             ''.join([substr % self[i] for i in xrange(len(self))]).strip()
     150            ''.join(substr % self[i] for i in xrange(len(self))).strip()
    151151
    152152    @property
    153153    def tuple(self):
    154154        "Returns a tuple version of this coordinate sequence."
    155155        n = self.size
    156156        if n == 1: return self[0]
    157         else: return tuple([self[i] for i in xrange(n)])
     157        else: return tuple(self[i] for i in xrange(n))
  • django/contrib/gis/geos/polygon.py

    diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
    index c50f549..53dfd67 100644
    a b class Polygon(GEOSGeometry):  
    159159    @property
    160160    def tuple(self):
    161161        "Gets the tuple for each ring in this Polygon."
    162         return tuple([self[i].tuple for i in xrange(len(self))])
     162        return tuple(self[i].tuple for i in xrange(len(self)))
    163163    coords = tuple
    164164
    165165    @property
    166166    def kml(self):
    167167        "Returns the KML representation of this Polygon."
    168         inner_kml = ''.join(["<innerBoundaryIs>%s</innerBoundaryIs>" % self[i+1].kml
    169                              for i in xrange(self.num_interior_rings)])
     168        inner_kml = ''.join("<innerBoundaryIs>%s</innerBoundaryIs>" % self[i+1].kml
     169                             for i in xrange(self.num_interior_rings))
    170170        return "<Polygon><outerBoundaryIs>%s</outerBoundaryIs>%s</Polygon>" % (self[0].kml, inner_kml)
  • django/contrib/gis/geos/tests/test_geos.py

    diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
    index 87aba72..f3a96cc 100644
    a b class GEOSTest(unittest.TestCase, TestDataMixin):  
    838838        # Creating a GeometryCollection WKT string composed of other
    839839        # collections and polygons.
    840840        coll = [mp.wkt for mp in self.geometries.multipolygons if mp.valid]
    841         coll.extend([mls.wkt for mls in self.geometries.multilinestrings])
    842         coll.extend([p.wkt for p in self.geometries.polygons])
    843         coll.extend([mp.wkt for mp in self.geometries.multipoints])
     841        coll.extend(mls.wkt for mls in self.geometries.multilinestrings)
     842        coll.extend(p.wkt for p in self.geometries.polygons)
     843        coll.extend(mp.wkt for mp in self.geometries.multipoints)
    844844        gc_wkt = 'GEOMETRYCOLLECTION(%s)' % ','.join(coll)
    845845
    846846        # Should construct ok from WKT
  • django/contrib/gis/management/commands/ogrinspect.py

    diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py
    index 85118e3..1270432 100644
    a b class Command(LabelCommand):  
    113113            rev_mapping = dict((v, k) for k, v in mapping_dict.items())
    114114            output.extend(['', '# Auto-generated `LayerMapping` dictionary for %s model' % model_name,
    115115                           '%s_mapping = {' % model_name.lower()])
    116             output.extend(["    '%s' : '%s'," % (rev_mapping[ogr_fld], ogr_fld) for ogr_fld in ds[options['layer_key']].fields])
    117             output.extend(["    '%s' : '%s'," % (options['geom_name'], mapping_dict[options['geom_name']]), '}'])
     116            output.extend("    '%s' : '%s'," % (rev_mapping[ogr_fld], ogr_fld) for ogr_fld in ds[options['layer_key']].fields)
     117            output.extend("    '%s' : '%s'," % (options['geom_name'], mapping_dict[options['geom_name']]), '}')
    118118        return '\n'.join(output) + '\n'
  • django/contrib/gis/maps/google/gmap.py

    diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py
    index ff65626..95cf2c9 100644
    a b class GoogleMap(object):  
    150150    @property
    151151    def icons(self):
    152152        "Returns a sequence of GIcon objects in this map."
    153         return set([marker.icon for marker in self.markers if marker.icon])
     153        return set(marker.icon for marker in self.markers if marker.icon)
    154154
    155155class GoogleMapSet(GoogleMap):
    156156
  • django/contrib/gis/maps/google/overlays.py

    diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py
    index b82d967..674f02d 100644
    a b class GOverlayBase(object):  
    6161
    6262    def latlng_from_coords(self, coords):
    6363        "Generates a JavaScript array of GLatLng objects for the given coordinates."
    64         return '[%s]' % ','.join(['new GLatLng(%s,%s)' % (y, x) for x, y in coords])
     64        return '[%s]' % ','.join('new GLatLng(%s,%s)' % (y, x) for x, y in coords)
    6565
    6666    def add_event(self, event):
    6767        "Attaches a GEvent to the overlay object."
  • django/contrib/gis/tests/geoadmin/tests.py

    diff --git a/django/contrib/gis/tests/geoadmin/tests.py b/django/contrib/gis/tests/geoadmin/tests.py
    index 295c1de..ebeb223 100644
    a b class GeoAdminTest(TestCase):  
    2323    def test_ensure_geographic_media(self):
    2424        geoadmin = admin.site._registry[City]
    2525        admin_js = geoadmin.media.render_js()
    26         self.assertTrue(any([geoadmin.openlayers_url in js for js in admin_js]))
     26        self.assertTrue(any(geoadmin.openlayers_url in js for js in admin_js))
    2727
    2828    def test_olmap_OSM_rendering(self):
    2929        geoadmin = admin.site._registry[City]
  • django/contrib/gis/tests/geoapp/test_feeds.py

    diff --git a/django/contrib/gis/tests/geoapp/test_feeds.py b/django/contrib/gis/tests/geoapp/test_feeds.py
    index 9c7b572..fac8161 100644
    a b class GeoFeedTest(TestCase):  
    2828
    2929    def assertChildNodes(self, elem, expected):
    3030        "Taken from syndication/tests.py."
    31         actual = set([n.nodeName for n in elem.childNodes])
     31        actual = set(n.nodeName for n in elem.childNodes)
    3232        expected = set(expected)
    3333        self.assertEqual(actual, expected)
    3434
  • django/contrib/gis/tests/geoapp/test_sitemaps.py

    diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py
    index bb68039..92d70e1 100644
    a b class GeoSitemapTest(TestCase):  
    3232
    3333    def assertChildNodes(self, elem, expected):
    3434        "Taken from syndication/tests.py."
    35         actual = set([n.nodeName for n in elem.childNodes])
     35        actual = set(n.nodeName for n in elem.childNodes)
    3636        expected = set(expected)
    3737        self.assertEqual(actual, expected)
    3838
  • django/contrib/gis/utils/wkt.py

    diff --git a/django/contrib/gis/utils/wkt.py b/django/contrib/gis/utils/wkt.py
    index d60eed3..bd85591 100644
    a b def precision_wkt(geom, prec):  
    3030    coord_fmt = ' '.join([num_fmt, num_fmt])
    3131
    3232    def formatted_coords(coords):
    33         return ','.join([coord_fmt % c[:2] for c in coords])
     33        return ','.join(coord_fmt % c[:2] for c in coords)
    3434
    3535    def formatted_poly(poly):
    36         return ','.join(['(%s)' % formatted_coords(r) for r in poly])
     36        return ','.join('(%s)' % formatted_coords(r) for r in poly)
    3737
    3838    def formatted_geom(g):
    3939        gtype = str(g.geom_type).upper()
    def precision_wkt(geom, prec):  
    4747        elif gtype == 'MULTIPOINT':
    4848            yield formatted_coords(g.coords)
    4949        elif gtype == 'MULTIPOLYGON':
    50             yield ','.join(['(%s)' % formatted_poly(p) for p in g])
     50            yield ','.join('(%s)' % formatted_poly(p) for p in g)
    5151        elif gtype == 'GEOMETRYCOLLECTION':
    52             yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])
     52            yield ','.join(''.join(wkt for wkt in formatted_geom(child)) for child in g)
    5353        else:
    5454            raise TypeError
    5555        yield ')'
    5656
    57     return ''.join([wkt for wkt in formatted_geom(geom)])
     57    return ''.join(wkt for wkt in formatted_geom(geom))
  • django/contrib/messages/storage/cookie.py

    diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
    index 8c394d2..b6c3384 100644
    a b class MessageDecoder(json.JSONDecoder):  
    3838                return Message(*obj[2:])
    3939            return [self.process_messages(item) for item in obj]
    4040        if isinstance(obj, dict):
    41             return dict([(key, self.process_messages(value))
    42                          for key, value in six.iteritems(obj)])
     41            return dict((key, self.process_messages(value))
     42                         for key, value in six.iteritems(obj))
    4343        return obj
    4444
    4545    def decode(self, s, **kwargs):
  • django/contrib/webdesign/lorem_ipsum.py

    diff --git a/django/contrib/webdesign/lorem_ipsum.py b/django/contrib/webdesign/lorem_ipsum.py
    index 01d8f22..36680c8 100644
    a b def paragraph():  
    6262
    6363    The paragraph consists of between 1 and 4 sentences, inclusive.
    6464    """
    65     return ' '.join([sentence() for i in range(random.randint(1, 4))])
     65    return ' '.join(sentence() for i in range(random.randint(1, 4)))
    6666
    6767def paragraphs(count, common=True):
    6868    """
  • django/core/cache/utils.py

    diff --git a/django/core/cache/utils.py b/django/core/cache/utils.py
    index b9806cc..dd9ad4a 100644
    a b TEMPLATE_FRAGMENT_KEY_TEMPLATE = 'template.cache.%s.%s'  
    1010def make_template_fragment_key(fragment_name, vary_on=None):
    1111    if vary_on is None:
    1212        vary_on = ()
    13     key = ':'.join([urlquote(var) for var in vary_on])
     13    key = ':'.join(urlquote(var) for var in vary_on)
    1414    args = hashlib.md5(force_bytes(key))
    1515    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
  • django/core/management/__init__.py

    diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
    index 708cfc2..7a7a7bb 100644
    a b def get_commands():  
    114114        for app_name in apps:
    115115            try:
    116116                path = find_management_module(app_name)
    117                 _commands.update(dict([(name, app_name)
    118                                        for name in find_commands(path)]))
     117                _commands.update(dict((name, app_name)
     118                                       for name in find_commands(path)))
    119119            except ImportError:
    120120                pass # No management module - ignore this app
    121121
    class ManagementUtility(object):  
    336336            options = [opt for opt in options if opt[0] not in prev_opts]
    337337
    338338            # filter options by current input
    339             options = sorted([(k, v) for k, v in options if k.startswith(curr)])
     339            options = sorted((k, v) for k, v in options if k.startswith(curr))
    340340            for option in options:
    341341                opt_label = option[0]
    342342                # append '=' to options which require args
  • django/core/management/commands/migrate.py

    diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py
    index dbec389..9899be7 100644
    a b class Command(BaseCommand):  
    164164            for app_name, model_list in all_models
    165165        )
    166166
    167         create_models = set([x for x in itertools.chain(*manifest.values())])
     167        create_models = set(itertools.chain(*manifest.values()))
    168168        emit_pre_migrate_signal(create_models, self.verbosity, self.interactive, connection.alias)
    169169
    170170        # Create the tables for each model
  • django/core/management/sql.py

    diff --git a/django/core/management/sql.py b/django/core/management/sql.py
    index 2e977c0..379def2 100644
    a b def sql_create(app, style, connection):  
    2929    app_models = models.get_models(app, include_auto_created=True)
    3030    final_output = []
    3131    tables = connection.introspection.table_names()
    32     known_models = set([model for model in connection.introspection.installed_models(tables) if model not in app_models])
     32    known_models = set(model for model in connection.introspection.installed_models(tables) if model not in app_models)
    3333    pending_references = {}
    3434
    3535    for model in app_models:
  • django/core/management/utils.py

    diff --git a/django/core/management/utils.py b/django/core/management/utils.py
    index d1052d5..bc00720 100644
    a b def handle_extensions(extensions=('html',), ignored=('py',)):  
    5252    for i, ext in enumerate(ext_list):
    5353        if not ext.startswith('.'):
    5454            ext_list[i] = '.%s' % ext_list[i]
    55     return set([x for x in ext_list if x.strip('.') not in ignored])
     55    return set(x for x in ext_list if x.strip('.') not in ignored)
    5656
    5757def find_command(cmd, path=None, pathext=None):
    5858    if path is None:
  • django/core/management/validation.py

    diff --git a/django/core/management/validation.py b/django/core/management/validation.py
    index 10f6621..1c23871 100644
    a b def get_validation_errors(outfile, app=None):  
    161161                        for rel_field in f.foreign_related_fields:
    162162                            has_unique_field = has_unique_field or rel_field.unique
    163163                        if not has_unique_field:
    164                             e.add(opts, "Field combination '%s' under model '%s' must have a unique=True constraint" % (','.join([rel_field.name for rel_field in f.foreign_related_fields]), f.rel.to.__name__))
     164                            e.add(opts, "Field combination '%s' under model '%s' must have a unique=True constraint" % (','.join(rel_field.name for rel_field in f.foreign_related_fields), f.rel.to.__name__))
    165165                    else:
    166166                        if not f.foreign_related_fields[0].unique:
    167167                            e.add(opts, "Field '%s' under model '%s' must have a unique=True constraint." % (f.foreign_related_fields[0].name, f.rel.to.__name__))
  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index 9e086a4..1422bf7 100644
    a b class ResolverMatch(object):  
    6262
    6363    @property
    6464    def view_name(self):
    65         return ':'.join([ x for x in [ self.namespace, self.url_name ]  if x ])
     65        return ':'.join(filter(bool, (self.namespace, self.url_name)))
    6666
    6767    def __getitem__(self, index):
    6868        return (self.func, self.args, self.kwargs)[index]
    class RegexURLResolver(LocaleRegexProvider):  
    274274                        for matches, pat, defaults in pattern.reverse_dict.getlist(name):
    275275                            new_matches = []
    276276                            for piece, p_args in parent:
    277                                 new_matches.extend([(piece + suffix, p_args + args) for (suffix, args) in matches])
     277                                new_matches.extend((piece + suffix, p_args + args) for (suffix, args) in matches)
    278278                            lookups.appendlist(name, (new_matches, p_pattern + pat, dict(defaults, **pattern.default_kwargs)))
    279279                    for namespace, (prefix, sub_pattern) in pattern.namespace_dict.items():
    280280                        namespaces[namespace] = (p_pattern + prefix, sub_pattern)
    class RegexURLResolver(LocaleRegexProvider):  
    321321                except Resolver404 as e:
    322322                    sub_tried = e.args[0].get('tried')
    323323                    if sub_tried is not None:
    324                         tried.extend([[pattern] + t for t in sub_tried])
     324                        tried.extend([pattern] + t for t in sub_tried)
    325325                    else:
    326326                        tried.append([pattern])
    327327                else:
  • django/db/backends/__init__.py

    diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
    index 6274d5b..0c1c329 100644
    a b class BaseDatabaseIntrospection(object):  
    12551255                if not router.allow_migrate(self.connection.alias, model):
    12561256                    continue
    12571257                tables.add(model._meta.db_table)
    1258                 tables.update([f.m2m_db_table() for f in model._meta.local_many_to_many])
     1258                tables.update(f.m2m_db_table() for f in model._meta.local_many_to_many)
    12591259        tables = list(tables)
    12601260        if only_existing:
    12611261            existing_tables = self.table_names()
  • django/db/backends/mysql/compiler.py

    diff --git a/django/db/backends/mysql/compiler.py b/django/db/backends/mysql/compiler.py
    index b7d1d7b..ee7fbe2 100644
    a b class SQLCompiler(compiler.SQLCompiler):  
    2020    def as_subquery_condition(self, alias, columns, qn):
    2121        qn2 = self.connection.ops.quote_name
    2222        sql, params = self.as_sql()
    23         return '(%s) IN (%s)' % (', '.join(['%s.%s' % (qn(alias), qn2(column)) for column in columns]), sql), params
     23        return '(%s) IN (%s)' % (', '.join('%s.%s' % (qn(alias), qn2(column)) for column in columns), sql), params
    2424
    2525
    2626class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler):
  • django/db/backends/mysql/introspection.py

    diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py
    index d7a2905..6e3b8d4 100644
    a b class DatabaseIntrospection(BaseDatabaseIntrospection):  
    5454            SELECT column_name, numeric_precision, numeric_scale FROM information_schema.columns
    5555            WHERE table_name = %s AND table_schema = DATABASE()
    5656                AND data_type='decimal'""", [table_name])
    57         numeric_map = dict([(line[0], tuple([int(n) for n in line[1:]])) for line in cursor.fetchall()])
     57        numeric_map = dict((line[0], tuple(int(n) for n in line[1:])) for line in cursor.fetchall())
    5858
    5959        cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
    6060        return [FieldInfo(*((force_text(line[0]),)
    class DatabaseIntrospection(BaseDatabaseIntrospection):  
    6969        Returns a dictionary of {field_name: field_index} for the given table.
    7070        Indexes are 0-based.
    7171        """
    72         return dict([(d[0], i) for i, d in enumerate(self.get_table_description(cursor, table_name))])
     72        return dict((d[0], i) for i, d in enumerate(self.get_table_description(cursor, table_name)))
    7373
    7474    def get_relations(self, cursor, table_name):
    7575        """
  • django/db/backends/oracle/base.py

    diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
    index a842199..a6ff26d 100644
    a b class FormatStylePlaceholderCursor(object):  
    860860    def fetchmany(self, size=None):
    861861        if size is None:
    862862            size = self.arraysize
    863         return tuple([_rowfactory(r, self.cursor)
    864                       for r in self.cursor.fetchmany(size)])
     863        return tuple(_rowfactory(r, self.cursor)
     864                      for r in self.cursor.fetchmany(size))
    865865
    866866    def fetchall(self):
    867         return tuple([_rowfactory(r, self.cursor)
    868                       for r in self.cursor.fetchall()])
     867        return tuple(_rowfactory(r, self.cursor)
     868                      for r in self.cursor.fetchall())
    869869
    870870    def var(self, *args):
    871871        return VariableWrapper(self.cursor.var(*args))
  • django/db/backends/oracle/introspection.py

    diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
    index 70c38c8..9e6e29d 100644
    a b class DatabaseIntrospection(BaseDatabaseIntrospection):  
    6666        Returns a dictionary of {field_name: field_index} for the given table.
    6767        Indexes are 0-based.
    6868        """
    69         return dict([(d[0], i) for i, d in enumerate(self.get_table_description(cursor, table_name))])
     69        return dict((d[0], i) for i, d in enumerate(self.get_table_description(cursor, table_name)))
    7070
    7171    def get_relations(self, cursor, table_name):
    7272        """
  • django/db/backends/sqlite3/schema.py

    diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py
    index 19bffc7..d5c8d10 100644
    a b class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):  
    5757        field_maps = list(mapping.items())
    5858        self.execute("INSERT INTO %s (%s) SELECT %s FROM %s;" % (
    5959            self.quote_name(temp_model._meta.db_table),
    60             ', '.join([x for x, y in field_maps]),
    61             ', '.join([y for x, y in field_maps]),
     60            ', '.join(x for x, y in field_maps),
     61            ', '.join(y for x, y in field_maps),
    6262            self.quote_name(model._meta.db_table),
    6363        ))
    6464        # Delete the old table
  • django/db/migrations/autodetector.py

    diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
    index 334c26d..294f801 100644
    a b class MigrationAutodetector(object):  
    145145            old_model_state = self.from_state.models[app_label, model_name]
    146146            new_model_state = self.to_state.models[app_label, model_name]
    147147            # New fields
    148             old_field_names = set([x for x, y in old_model_state.fields])
    149             new_field_names = set([x for x, y in new_model_state.fields])
     148            old_field_names = set(x for x, y in old_model_state.fields)
     149            new_field_names = set(x for x, y in new_model_state.fields)
    150150            for field_name in new_field_names - old_field_names:
    151151                field = new_model_state.get_field_by_name(field_name)
    152152                # Scan to see if this is actually a rename!
  • django/db/migrations/writer.py

    diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py
    index 753aeac..75a44a8 100644
    a b class MigrationWriter(object):  
    104104                imports.update(k_imports)
    105105                imports.update(v_imports)
    106106                strings.append((k_string, v_string))
    107             return "{%s}" % (", ".join(["%s: %s" % (k, v) for k, v in strings])), imports
     107            return "{%s}" % (", ".join("%s: %s" % (k, v) for k, v in strings)), imports
    108108        # Datetimes
    109109        elif isinstance(value, (datetime.datetime, datetime.date)):
    110110            return repr(value), set(["import datetime"])
  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index d63017c..aaf525f 100644
    a b class ModelBase(type):  
    159159        new_fields = new_class._meta.local_fields + \
    160160                     new_class._meta.local_many_to_many + \
    161161                     new_class._meta.virtual_fields
    162         field_names = set([f.name for f in new_fields])
     162        field_names = set(f.name for f in new_fields)
    163163
    164164        # Basic setup for proxy models.
    165165        if is_proxy:
    class ModelBase(type):  
    321321
    322322        # Give the class a docstring -- its definition.
    323323        if cls.__doc__ is None:
    324             cls.__doc__ = "%s(%s)" % (cls.__name__, ", ".join([f.attname for f in opts.fields]))
     324            cls.__doc__ = "%s(%s)" % (cls.__name__, ", ".join(f.attname for f in opts.fields))
    325325
    326326        if hasattr(cls, 'get_absolute_url'):
    327327            cls.get_absolute_url = update_wrapper(curry(get_absolute_url, opts, cls.get_absolute_url),
  • django/db/models/deletion.py

    diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
    index f4c64f7..769e5b9 100644
    a b class Collector(object):  
    234234                    found = True
    235235            if not found:
    236236                return
    237         self.data = OrderedDict([(model, self.data[model])
    238                                 for model in sorted_models])
     237        self.data = OrderedDict((model, self.data[model])
     238                                for model in sorted_models)
    239239
    240240    def delete(self):
    241241        # sort instance collections
  • django/db/models/options.py

    diff --git a/django/db/models/options.py b/django/db/models/options.py
    index 14f73c3..fbbddff 100644
    a b class Options(object):  
    318318                    cache.append((field, model))
    319319                else:
    320320                    cache.append((field, parent))
    321         cache.extend([(f, None) for f in self.local_fields])
     321        cache.extend((f, None) for f in self.local_fields)
    322322        self._field_cache = tuple(cache)
    323323        self._field_name_cache = [x for x, _ in cache]
    324324
  • django/db/models/query.py

    diff --git a/django/db/models/query.py b/django/db/models/query.py
    index 5947a85..5fb7ede 100644
    a b class ValuesListQuerySet(ValuesQuerySet):  
    12061206
    12071207            for row in self.query.get_compiler(self.db).results_iter():
    12081208                data = dict(zip(names, row))
    1209                 yield tuple([data[f] for f in fields])
     1209                yield tuple(data[f] for f in fields)
    12101210
    12111211    def _clone(self, *args, **kwargs):
    12121212        clone = super(ValuesListQuerySet, self)._clone(*args, **kwargs)
  • django/db/models/sql/aggregates.py

    diff --git a/django/db/models/sql/aggregates.py b/django/db/models/sql/aggregates.py
    index 9fc5fe8..3cda4d2 100644
    a b class Aggregate(object):  
    7777        if hasattr(self.col, 'as_sql'):
    7878            field_name, params = self.col.as_sql(qn, connection)
    7979        elif isinstance(self.col, (list, tuple)):
    80             field_name = '.'.join([qn(c) for c in self.col])
     80            field_name = '.'.join(qn(c) for c in self.col)
    8181        else:
    8282            field_name = self.col
    8383
  • django/db/models/sql/compiler.py

    diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
    index 5dda379..1c6e80b 100644
    a b class SQLCompiler(object):  
    718718                    loaded_fields = self.query.get_loaded_field_names().get(self.query.model, set()) or self.query.select
    719719                    aggregate_start = len(self.query.extra_select) + len(loaded_fields)
    720720                    aggregate_end = aggregate_start + len(self.query.aggregate_select)
    721                     row = tuple(row[:aggregate_start]) + tuple([
     721                    row = tuple(row[:aggregate_start]) + tuple(
    722722                        self.query.resolve_aggregate(value, aggregate, self.connection)
    723723                        for (alias, aggregate), value
    724724                        in zip(self.query.aggregate_select.items(), row[aggregate_start:aggregate_end])
    725                     ]) + tuple(row[aggregate_end:])
     725                    ) + tuple(row[aggregate_end:])
    726726
    727727                yield row
    728728
    class SQLInsertCompiler(SQLCompiler):  
    827827
    828828        has_fields = bool(self.query.fields)
    829829        fields = self.query.fields if has_fields else [opts.pk]
    830         result.append('(%s)' % ', '.join([qn(f.column) for f in fields]))
     830        result.append('(%s)' % ', '.join(qn(f.column) for f in fields))
    831831
    832832        if has_fields:
    833833            params = values = [
    class SQLUpdateCompiler(SQLCompiler):  
    10071007            # selecting from the updating table (e.g. MySQL).
    10081008            idents = []
    10091009            for rows in query.get_compiler(self.using).execute_sql(MULTI):
    1010                 idents.extend([r[0] for r in rows])
     1010                idents.extend(r[0] for r in rows)
    10111011            self.query.add_filter(('pk__in', idents))
    10121012            self.query.related_ids = idents
    10131013        else:
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index ae67b6f..d8f2a8a 100644
    a b class Query(object):  
    371371        if result is None:
    372372            result = [None for q in query.aggregate_select.items()]
    373373
    374         return dict([
     374        return dict(
    375375            (alias, self.resolve_aggregate(val, aggregate, connection=connections[using]))
    376376            for (alias, aggregate), val
    377377            in zip(query.aggregate_select.items(), result)
    378         ])
     378        )
    379379
    380380    def get_count(self, using):
    381381        """
    class Query(object):  
    17571757        """
    17581758        Callback used by get_deferred_field_names().
    17591759        """
    1760         target[model] = set([f.name for f in fields])
     1760        target[model] = set(f.name for f in fields)
    17611761
    17621762    def set_aggregate_mask(self, names):
    17631763        "Set the mask of aggregates that will actually be returned by the SELECT"
    class Query(object):  
    17921792        if self._aggregate_select_cache is not None:
    17931793            return self._aggregate_select_cache
    17941794        elif self.aggregate_select_mask is not None:
    1795             self._aggregate_select_cache = OrderedDict([
     1795            self._aggregate_select_cache = OrderedDict(
    17961796                (k, v) for k, v in self.aggregates.items()
    17971797                if k in self.aggregate_select_mask
    1798             ])
     1798            )
    17991799            return self._aggregate_select_cache
    18001800        else:
    18011801            return self.aggregates
    class Query(object):  
    18051805        if self._extra_select_cache is not None:
    18061806            return self._extra_select_cache
    18071807        elif self.extra_select_mask is not None:
    1808             self._extra_select_cache = OrderedDict([
     1808            self._extra_select_cache = OrderedDict(
    18091809                (k, v) for k, v in self.extra.items()
    18101810                if k in self.extra_select_mask
    1811             ])
     1811            )
    18121812            return self._extra_select_cache
    18131813        else:
    18141814            return self.extra
  • django/forms/fields.py

    diff --git a/django/forms/fields.py b/django/forms/fields.py
    index e995187..8abb1b3 100644
    a b class MultipleChoiceField(ChoiceField):  
    874874            data = []
    875875        if len(initial) != len(data):
    876876            return True
    877         initial_set = set([force_text(value) for value in initial])
    878         data_set = set([force_text(value) for value in data])
     877        initial_set = set(force_text(value) for value in initial)
     878        data_set = set(force_text(value) for value in data)
    879879        return data_set != initial_set
    880880
    881881
  • django/forms/formsets.py

    diff --git a/django/forms/formsets.py b/django/forms/formsets.py
    index 8a379ff..e46a440 100644
    a b class BaseFormSet(object):  
    380380        # XXX: there is no semantic division between forms here, there
    381381        # probably should be. It might make sense to render each form as a
    382382        # table row with each field as a td.
    383         forms = ' '.join([form.as_table() for form in self])
     383        forms = ' '.join(form.as_table() for form in self)
    384384        return mark_safe('\n'.join([six.text_type(self.management_form), forms]))
    385385
    386386    def as_p(self):
    387387        "Returns this formset rendered as HTML <p>s."
    388         forms = ' '.join([form.as_p() for form in self])
     388        forms = ' '.join(form.as_p() for form in self)
    389389        return mark_safe('\n'.join([six.text_type(self.management_form), forms]))
    390390
    391391    def as_ul(self):
    392392        "Returns this formset rendered as HTML <li>s."
    393         forms = ' '.join([form.as_ul() for form in self])
     393        forms = ' '.join(form.as_ul() for form in self)
    394394        return mark_safe('\n'.join([six.text_type(self.management_form), forms]))
    395395
    396396def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index 9df97d6..f292606 100644
    a b class ModelMultipleChoiceField(ModelChoiceField):  
    11811181                    params={'pk': pk},
    11821182                )
    11831183        qs = self.queryset.filter(**{'%s__in' % key: value})
    1184         pks = set([force_text(getattr(o, key)) for o in qs])
     1184        pks = set(force_text(getattr(o, key)) for o in qs)
    11851185        for val in value:
    11861186            if force_text(val) not in pks:
    11871187                raise ValidationError(
    class ModelMultipleChoiceField(ModelChoiceField):  
    12081208            data = []
    12091209        if len(initial) != len(data):
    12101210            return True
    1211         initial_set = set([force_text(value) for value in self.prepare_value(initial)])
    1212         data_set = set([force_text(value) for value in data])
     1211        initial_set = set(force_text(value) for value in self.prepare_value(initial))
     1212        data_set = set(force_text(value) for value in data)
    12131213        return data_set != initial_set
    12141214
    12151215
  • django/forms/util.py

    diff --git a/django/forms/util.py b/django/forms/util.py
    index 3c77249..320a74e 100644
    a b class ErrorDict(dict):  
    4949                           ))
    5050
    5151    def as_text(self):
    52         return '\n'.join(['* %s\n%s' % (k, '\n'.join(['  * %s' % force_text(i) for i in v])) for k, v in self.items()])
     52        return '\n'.join('* %s\n%s' % (k, '\n'.join('  * %s' % force_text(i) for i in v)) for k, v in self.items())
    5353
    5454@python_2_unicode_compatible
    5555class ErrorList(list):
    class ErrorList(list):  
    6969
    7070    def as_text(self):
    7171        if not self: return ''
    72         return '\n'.join(['* %s' % force_text(e) for e in self])
     72        return '\n'.join('* %s' % force_text(e) for e in self)
    7373
    7474    def __repr__(self):
    7575        return repr([force_text(e) for e in self])
  • django/template/base.py

    diff --git a/django/template/base.py b/django/template/base.py
    index 382b85a..67af5b1 100644
    a b class VariableDoesNotExist(Exception):  
    8888        self.params = params
    8989
    9090    def __str__(self):
    91         return self.msg % tuple([force_text(p, errors='replace')
    92                                  for p in self.params])
     91        return self.msg % tuple(force_text(p, errors='replace')
     92                                 for p in self.params)
    9393
    9494class InvalidTemplateLibrary(Exception):
    9595    pass
    def parse_bits(parser, bits, params, varargs, varkw, defaults,  
    10121012        # Some positional arguments were not supplied
    10131013        raise TemplateSyntaxError(
    10141014            "'%s' did not receive value(s) for the argument(s): %s" %
    1015             (name, ", ".join(["'%s'" % p for p in unhandled_params])))
     1015            (name, ", ".join("'%s'" % p for p in unhandled_params)))
    10161016    return args, kwargs
    10171017
    10181018def generic_tag_compiler(parser, token, params, varargs, varkw, defaults,
  • django/template/defaulttags.py

    diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
    index 2a3af9b..a7af7d7 100644
    a b class ForNode(Node):  
    205205                    # don't want to leave any vars from the previous loop on the
    206206                    # context.
    207207                    context.pop()
    208         return mark_safe(''.join([force_text(n) for n in nodelist]))
     208        return mark_safe(''.join(force_text(n) for n in nodelist))
    209209
    210210class IfChangedNode(Node):
    211211    child_nodelists = ('nodelist_true', 'nodelist_false')
    class URLNode(Node):  
    410410    def render(self, context):
    411411        from django.core.urlresolvers import reverse, NoReverseMatch
    412412        args = [arg.resolve(context) for arg in self.args]
    413         kwargs = dict([(smart_text(k, 'ascii'), v.resolve(context))
    414                        for k, v in self.kwargs.items()])
     413        kwargs = dict((smart_text(k, 'ascii'), v.resolve(context))
     414                       for k, v in self.kwargs.items())
    415415
    416416        view_name = self.view_name.resolve(context)
    417417
    class WithNode(Node):  
    502502        return "<WithNode>"
    503503
    504504    def render(self, context):
    505         values = dict([(key, val.resolve(context)) for key, val in
    506                        six.iteritems(self.extra_context)])
     505        values = dict((key, val.resolve(context)) for key, val in
     506                       six.iteritems(self.extra_context))
    507507        with context.push(**values):
    508508            return self.nodelist.render(context)
    509509
  • django/template/loader_tags.py

    diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
    index d7908ac..d104d69 100644
    a b class ExtendsNode(Node):  
    112112            # The ExtendsNode has to be the first non-text node.
    113113            if not isinstance(node, TextNode):
    114114                if not isinstance(node, ExtendsNode):
    115                     blocks = dict([(n.name, n) for n in
    116                                    compiled_parent.nodelist.get_nodes_by_type(BlockNode)])
     115                    blocks = dict((n.name, n) for n in
     116                                   compiled_parent.nodelist.get_nodes_by_type(BlockNode))
    117117                    block_context.add_blocks(blocks)
    118118                break
    119119
    class BaseIncludeNode(Node):  
    128128        super(BaseIncludeNode, self).__init__(*args, **kwargs)
    129129
    130130    def render_template(self, template, context):
    131         values = dict([(name, var.resolve(context)) for name, var
    132                        in six.iteritems(self.extra_context)])
     131        values = dict((name, var.resolve(context)) for name, var
     132                       in six.iteritems(self.extra_context))
    133133        if self.isolated_context:
    134134            return template.render(context.new(values))
    135135        with context.push(**values):
  • django/test/_doctest.py

    diff --git a/django/test/_doctest.py b/django/test/_doctest.py
    index 50d772c..6e8662a 100644
    a b class DocTestParser:  
    598598        # If all lines begin with the same indentation, then strip it.
    599599        min_indent = self._min_indent(string)
    600600        if min_indent > 0:
    601             string = '\n'.join([l[min_indent:] for l in string.split('\n')])
     601            string = '\n'.join(l[min_indent:] for l in string.split('\n'))
    602602
    603603        output = []
    604604        charno, lineno = 0, 0
    class DocTestParser:  
    670670        source_lines = m.group('source').split('\n')
    671671        self._check_prompt_blank(source_lines, indent, name, lineno)
    672672        self._check_prefix(source_lines[1:], ' '*indent + '.', name, lineno)
    673         source = '\n'.join([sl[indent+4:] for sl in source_lines])
     673        source = '\n'.join(sl[indent+4:] for sl in source_lines)
    674674
    675675        # Divide want into lines; check that it's properly indented; and
    676676        # then strip the indentation.  Spaces before the last newline should
    class DocTestParser:  
    681681            del want_lines[-1]  # forget final newline & spaces after it
    682682        self._check_prefix(want_lines, ' '*indent, name,
    683683                           lineno + len(source_lines))
    684         want = '\n'.join([wl[indent:] for wl in want_lines])
     684        want = '\n'.join(wl[indent:] for wl in want_lines)
    685685
    686686        # If `want` contains a traceback message, then extract it.
    687687        m = self._EXCEPTION_RE.match(want)
  • django/utils/cache.py

    diff --git a/django/utils/cache.py b/django/utils/cache.py
    index 45f93b9..7a77f91 100644
    a b def patch_cache_control(response, **kwargs):  
    7676
    7777    for (k, v) in kwargs.items():
    7878        cc[k.replace('_', '-')] = v
    79     cc = ', '.join([dictvalue(el) for el in cc.items()])
     79    cc = ', '.join(dictvalue(el) for el in cc.items())
    8080    response['Cache-Control'] = cc
    8181
    8282def get_max_age(response):
    def get_max_age(response):  
    8686    """
    8787    if not response.has_header('Cache-Control'):
    8888        return
    89     cc = dict([_to_tuple(el) for el in
    90         cc_delim_re.split(response['Cache-Control'])])
     89    cc = dict(_to_tuple(el) for el in
     90        cc_delim_re.split(response['Cache-Control']))
    9191    if 'max-age' in cc:
    9292        try:
    9393            return int(cc['max-age'])
    def patch_vary_headers(response, newheaders):  
    144144    else:
    145145        vary_headers = []
    146146    # Use .lower() here so we treat headers as case-insensitive.
    147     existing_headers = set([header.lower() for header in vary_headers])
     147    existing_headers = set(header.lower() for header in vary_headers)
    148148    additional_headers = [newheader for newheader in newheaders
    149149                          if newheader.lower() not in existing_headers]
    150150    response['Vary'] = ', '.join(vary_headers + additional_headers)
    def has_vary_header(response, header_query):  
    156156    if not response.has_header('Vary'):
    157157        return False
    158158    vary_headers = cc_delim_re.split(response['Vary'])
    159     existing_headers = set([header.lower() for header in vary_headers])
     159    existing_headers = set(header.lower() for header in vary_headers)
    160160    return header_query.lower() in existing_headers
    161161
    162162def _i18n_cache_key_suffix(request, cache_key):
  • django/utils/checksums.py

    diff --git a/django/utils/checksums.py b/django/utils/checksums.py
    index 8617e22..94c0029 100644
    a b def luhn(candidate):  
    1717    if not isinstance(candidate, six.string_types):
    1818        candidate = str(candidate)
    1919    try:
    20         evens = sum([int(c) for c in candidate[-1::-2]])
    21         odds = sum([LUHN_ODD_LOOKUP[int(c)] for c in candidate[-2::-2]])
     20        evens = sum(int(c) for c in candidate[-1::-2])
     21        odds = sum(LUHN_ODD_LOOKUP[int(c)] for c in candidate[-2::-2])
    2222        return ((evens + odds) % 10 == 0)
    2323    except ValueError:  # Raised if an int conversion fails
    2424        return False
  • django/utils/crypto.py

    diff --git a/django/utils/crypto.py b/django/utils/crypto.py
    index 15db972..3c15b8b 100644
    a b def get_random_string(length=12,  
    7373                    time.time(),
    7474                    settings.SECRET_KEY)).encode('utf-8')
    7575                ).digest())
    76     return ''.join([random.choice(allowed_chars) for i in range(length)])
     76    return ''.join(random.choice(allowed_chars) for i in range(length))
    7777
    7878
    7979def constant_time_compare(val1, val2):
  • django/utils/datastructures.py

    diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
    index 29228bd..f4f694f 100644
    a b class SortedDict(dict):  
    231231        Replaces the normal dict.__repr__ with a version that returns the keys
    232232        in their sorted order.
    233233        """
    234         return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in six.iteritems(self)])
     234        return '{%s}' % ', '.join('%r: %r' % (k, v) for k, v in six.iteritems(self))
    235235
    236236    def clear(self):
    237237        super(SortedDict, self).clear()
  • django/utils/html.py

    diff --git a/django/utils/html.py b/django/utils/html.py
    index 89e790d..46750d9 100644
    a b simple_url_2_re = re.compile(r'^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net  
    3232simple_email_re = re.compile(r'^\S+@\S+\.\S+$')
    3333link_target_attribute_re = re.compile(r'(<a [^>]*?)target=[^\s>]+')
    3434html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE)
    35 hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL)
     35hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join(re.escape(x) for x in DOTS), re.DOTALL)
    3636trailing_empty_content_re = re.compile(r'(?:<p>(?:&nbsp;|\s|<br \/>)*?</p>\s*)+\Z')
    3737
    3838
    def format_html(format_string, *args, **kwargs):  
    8181    of str.format or % interpolation to build up small HTML fragments.
    8282    """
    8383    args_safe = map(conditional_escape, args)
    84     kwargs_safe = dict([(k, conditional_escape(v)) for (k, v) in
    85                         six.iteritems(kwargs)])
     84    kwargs_safe = dict((k, conditional_escape(v)) for (k, v) in
     85                        six.iteritems(kwargs))
    8686    return mark_safe(format_string.format(*args_safe, **kwargs_safe))
    8787
    8888def format_html_join(sep, format_string, args_generator):
  • django/utils/termcolors.py

    diff --git a/django/utils/termcolors.py b/django/utils/termcolors.py
    index 95d0d17..8c66e33 100644
    a b termcolors.py  
    55from django.utils import six
    66
    77color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
    8 foreground = dict([(color_names[x], '3%s' % x) for x in range(8)])
    9 background = dict([(color_names[x], '4%s' % x) for x in range(8)])
     8foreground = dict((color_names[x], '3%s' % x) for x in range(8))
     9background = dict((color_names[x], '4%s' % x) for x in range(8))
    1010
    1111RESET = '0'
    1212opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
  • django/utils/text.py

    diff --git a/django/utils/text.py b/django/utils/text.py
    index 7bb8e7e..e89f7df 100644
    a b def get_text_list(list_, last_word=ugettext_lazy('or')):  
    238238    if len(list_) == 1: return force_text(list_[0])
    239239    return '%s %s %s' % (
    240240        # Translators: This string is used as a separator between list elements
    241         _(', ').join([force_text(i) for i in list_][:-1]),
     241        _(', ').join(force_text(i) for i in list_[:-1]),
    242242        force_text(last_word), force_text(list_[-1]))
    243243get_text_list = allow_lazy(get_text_list, six.text_type)
    244244
  • django/utils/translation/__init__.py

    diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
    index 10a6cd6..ba9baab 100644
    a b def _string_concat(*strings):  
    179179    Lazy variant of string concatenation, needed for translations that are
    180180    constructed from multiple parts.
    181181    """
    182     return ''.join([force_text(s) for s in strings])
     182    return ''.join(force_text(s) for s in strings)
    183183string_concat = lazy(_string_concat, six.text_type)
    184184
    185185def get_language_info(lang_code):
  • tests/backends/tests.py

    diff --git a/tests/backends/tests.py b/tests/backends/tests.py
    index d6e3f5c..64f9099 100644
    a b class OracleChecks(unittest.TestCase):  
    7979        # than 4000 chars and read it properly
    8080        c = connection.cursor()
    8181        c.execute('CREATE TABLE ltext ("TEXT" NCLOB)')
    82         long_str = ''.join([six.text_type(x) for x in xrange(4000)])
     82        long_str = ''.join(six.text_type(x) for x in xrange(4000))
    8383        c.execute('INSERT INTO ltext VALUES (%s)', [long_str])
    8484        c.execute('SELECT text FROM ltext')
    8585        row = c.fetchone()
  • tests/file_uploads/views.py

    diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py
    index 8d20a9c..1940987 100644
    a b def file_upload_echo(request):  
    8989    """
    9090    Simple view to echo back info about uploaded files for tests.
    9191    """
    92     r = dict([(k, f.name) for k, f in request.FILES.items()])
     92    r = dict((k, f.name) for k, f in request.FILES.items())
    9393    return HttpResponse(json.dumps(r))
    9494
    9595def file_upload_echo_content(request):
    9696    """
    9797    Simple view to echo back the content of uploaded files for tests.
    9898    """
    99     r = dict([(k, f.read().decode('utf-8')) for k, f in request.FILES.items()])
     99    r = dict((k, f.read().decode('utf-8')) for k, f in request.FILES.items())
    100100    return HttpResponse(json.dumps(r))
    101101
    102102def file_upload_quota(request):
  • tests/forms_tests/tests/test_error_messages.py

    diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py
    index f063829..2b1bec1 100644
    a b class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):  
    221221
    222222            def as_divs(self):
    223223                if not self: return ''
    224                 return mark_safe('<div class="error">%s</div>' % ''.join(['<p>%s</p>' % e for e in self]))
     224                return mark_safe('<div class="error">%s</div>' % ''.join('<p>%s</p>' % e for e in self))
    225225
    226226        # This form should print errors the default way.
    227227        form1 = TestForm({'first_name': 'John'})
  • tests/forms_tests/tests/test_extra.py

    diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py
    index b86245a..2118668 100644
    a b class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):  
    723723
    724724            def as_divs(self):
    725725                if not self: return ''
    726                 return '<div class="errorlist">%s</div>' % ''.join(['<div class="error">%s</div>' % force_text(e) for e in self])
     726                return '<div class="errorlist">%s</div>' % ''.join('<div class="error">%s</div>' % force_text(e) for e in self)
    727727
    728728        class CommentForm(Form):
    729729            name = CharField(max_length=50, required=False)
  • tests/forms_tests/tests/test_forms.py

    diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
    index 1c72d17..06ee321 100644
    a b class FormsTestCase(TestCase):  
    437437            name = ChoiceField(choices=[('john', 'John'), ('paul', 'Paul'), ('george', 'George'), ('ringo', 'Ringo')], widget=RadioSelect)
    438438
    439439        f = BeatleForm(auto_id=False)
    440         self.assertHTMLEqual('\n'.join([str(bf) for bf in f['name']]), """<label><input type="radio" name="name" value="john" /> John</label>
     440        self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), """<label><input type="radio" name="name" value="john" /> John</label>
    441441<label><input type="radio" name="name" value="paul" /> Paul</label>
    442442<label><input type="radio" name="name" value="george" /> George</label>
    443443<label><input type="radio" name="name" value="ringo" /> Ringo</label>""")
    444         self.assertHTMLEqual('\n'.join(['<div>%s</div>' % bf for bf in f['name']]), """<div><label><input type="radio" name="name" value="john" /> John</label></div>
     444        self.assertHTMLEqual('\n'.join('<div>%s</div>' % bf for bf in f['name']), """<div><label><input type="radio" name="name" value="john" /> John</label></div>
    445445<div><label><input type="radio" name="name" value="paul" /> Paul</label></div>
    446446<div><label><input type="radio" name="name" value="george" /> George</label></div>
    447447<div><label><input type="radio" name="name" value="ringo" /> Ringo</label></div>""")
    class FormsTestCase(TestCase):  
    452452            name = CharField()
    453453
    454454        f = BeatleForm(auto_id=False)
    455         self.assertHTMLEqual('\n'.join([str(bf) for bf in f['name']]), '<input type="text" name="name" />')
     455        self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), '<input type="text" name="name" />')
    456456
    457457    def test_forms_with_multiple_choice(self):
    458458        # MultipleChoiceField is a special case, as its data is required to be a list:
  • tests/forms_tests/tests/test_formsets.py

    diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
    index 41577e6..6372f2a 100644
    a b class FormsFormsetTestCase(TestCase):  
    900900        }
    901901        formset = AnotherChoiceFormSet(data, auto_id=False, prefix='choices')
    902902        self.assertTrue(formset.is_valid())
    903         self.assertTrue(all([form.is_valid_called for form in formset.forms]))
     903        self.assertTrue(all(form.is_valid_called for form in formset.forms))
    904904
    905905    def test_hard_limit_on_instantiated_forms(self):
    906906        """A formset has a hard limit on the number of forms instantiated."""
  • tests/forms_tests/tests/test_widgets.py

    diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py
    index 3f11771..7f23b1a 100644
    a b beatle J R Ringo False""")  
    640640        # You can create your own custom renderers for RadioSelect to use.
    641641        class MyRenderer(RadioFieldRenderer):
    642642           def render(self):
    643                return '<br />\n'.join([six.text_type(choice) for choice in self])
     643               return '<br />\n'.join(six.text_type(choice) for choice in self)
    644644        w = RadioSelect(renderer=MyRenderer)
    645645        self.assertHTMLEqual(w.render('beatle', 'G', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))), """<label><input type="radio" name="beatle" value="J" /> John</label><br />
    646646<label><input type="radio" name="beatle" value="P" /> Paul</label><br />
    beatle J R Ringo False""")  
    835835
    836836    def test_subwidget(self):
    837837        # Each subwidget tag gets a separate ID when the widget has an ID specified
    838         self.assertHTMLEqual("\n".join([c.tag() for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))]), """<input checked="checked" type="checkbox" name="letters" value="a" id="abc_0" />
     838        self.assertHTMLEqual("\n".join(c.tag() for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))), """<input checked="checked" type="checkbox" name="letters" value="a" id="abc_0" />
    839839<input type="checkbox" name="letters" value="b" id="abc_1" />
    840840<input checked="checked" type="checkbox" name="letters" value="c" id="abc_2" />""")
    841841
    842842        # Each subwidget tag does not get an ID if the widget does not have an ID specified
    843         self.assertHTMLEqual("\n".join([c.tag() for c in CheckboxSelectMultiple().subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))]), """<input checked="checked" type="checkbox" name="letters" value="a" />
     843        self.assertHTMLEqual("\n".join(c.tag() for c in CheckboxSelectMultiple().subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))), """<input checked="checked" type="checkbox" name="letters" value="a" />
    844844<input type="checkbox" name="letters" value="b" />
    845845<input checked="checked" type="checkbox" name="letters" value="c" />""")
    846846
    847847        # The id_for_label property of the subwidget should return the ID that is used on the subwidget's tag
    848         self.assertHTMLEqual("\n".join(['<input type="checkbox" name="letters" value="%s" id="%s" />' % (c.choice_value, c.id_for_label) for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', [], choices=zip(list('abc'), list('ABC')))]), """<input type="checkbox" name="letters" value="a" id="abc_0" />
     848        self.assertHTMLEqual("\n".join('<input type="checkbox" name="letters" value="%s" id="%s" />' % (c.choice_value, c.id_for_label) for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', [], choices=zip(list('abc'), list('ABC')))), """<input type="checkbox" name="letters" value="a" id="abc_0" />
    849849<input type="checkbox" name="letters" value="b" id="abc_1" />
    850850<input type="checkbox" name="letters" value="c" id="abc_2" />""")
    851851
  • tests/proxy_models/tests.py

    diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py
    index f0c0d04..f9cb132 100644
    a b class ProxyModelTests(TestCase):  
    7979        Person.objects.create(name="Foo McBar")
    8080        MyPerson.objects.create(name="Bazza del Frob")
    8181        LowerStatusPerson.objects.create(status="low", name="homer")
    82         pp = sorted([mpp.name for mpp in MyPersonProxy.objects.all()])
     82        pp = sorted(mpp.name for mpp in MyPersonProxy.objects.all())
    8383        self.assertEqual(pp, ['Bazza del Frob', 'Foo McBar', 'homer'])
    8484
    8585    def test_proxy_included_in_ancestors(self):
  • tests/schema/tests.py

    diff --git a/tests/schema/tests.py b/tests/schema/tests.py
    index c376497..7c21b58 100644
    a b class SchemaTests(TransactionTestCase):  
    4242                            "table": connection.ops.quote_name(field.rel.through._meta.db_table),
    4343                        })
    4444                    except DatabaseError as e:
    45                         if any([s in str(e).lower() for s in self.no_table_strings]):
     45                        if any(s in str(e).lower() for s in self.no_table_strings):
    4646                            pass
    4747                        else:
    4848                            raise
    class SchemaTests(TransactionTestCase):  
    5353                        "table": connection.ops.quote_name(model._meta.db_table),
    5454                    })
    5555                except DatabaseError as e:
    56                     if any([s in str(e).lower() for s in self.no_table_strings]):
     56                    if any(s in str(e).lower() for s in self.no_table_strings):
    5757                        pass
    5858                    else:
    5959                        raise
  • tests/servers/views.py

    diff --git a/tests/servers/views.py b/tests/servers/views.py
    index 00baf4b..eb7c6c6 100644
    a b def example_view(request):  
    88
    99def model_view(request):
    1010    people = Person.objects.all()
    11     return HttpResponse('\n'.join([person.name for person in people]))
     11    return HttpResponse('\n'.join(person.name for person in people))
    1212
    1313
    1414def create_model_instance(request):
    def create_model_instance(request):  
    1818
    1919
    2020def environ_view(request):
    21     return HttpResponse("\n".join(["%s: %r" % (k, v) for k, v in request.environ.items()]))
     21    return HttpResponse("\n".join("%s: %r" % (k, v) for k, v in request.environ.items()))
  • tests/syndication/tests.py

    diff --git a/tests/syndication/tests.py b/tests/syndication/tests.py
    index 8bc6b04..79004aa 100644
    a b class FeedTestCase(TestCase):  
    1515    fixtures = ['feeddata.json']
    1616
    1717    def assertChildNodes(self, elem, expected):
    18         actual = set([n.nodeName for n in elem.childNodes])
     18        actual = set(n.nodeName for n in elem.childNodes)
    1919        expected = set(expected)
    2020        self.assertEqual(actual, expected)
    2121
  • tests/template_tests/templatetags/custom.py

    diff --git a/tests/template_tests/templatetags/custom.py b/tests/template_tests/templatetags/custom.py
    index 32035ab..5e96ca8 100644
    a b simple_one_default.anything = "Expected simple_one_default __dict__"  
    6464@register.simple_tag
    6565def simple_unlimited_args(one, two='hi', *args):
    6666    """Expected simple_unlimited_args __doc__"""
    67     return "simple_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)]))
     67    return "simple_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))
    6868simple_unlimited_args.anything = "Expected simple_unlimited_args __dict__"
    6969
    7070@register.simple_tag
    7171def simple_only_unlimited_args(*args):
    7272    """Expected simple_only_unlimited_args __doc__"""
    73     return "simple_only_unlimited_args - Expected result: %s" % ', '.join([six.text_type(arg) for arg in args])
     73    return "simple_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args)
    7474simple_only_unlimited_args.anything = "Expected simple_only_unlimited_args __dict__"
    7575
    7676@register.simple_tag
    def simple_unlimited_args_kwargs(one, two='hi', *args, **kwargs):  
    7979    # Sort the dictionary by key to guarantee the order for testing.
    8080    sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
    8181    return "simple_unlimited_args_kwargs - Expected result: %s / %s" % (
    82         ', '.join([six.text_type(arg) for arg in [one, two] + list(args)]),
    83         ', '.join(['%s=%s' % (k, v) for (k, v) in sorted_kwarg])
     82        ', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
     83        ', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
    8484        )
    8585simple_unlimited_args_kwargs.anything = "Expected simple_unlimited_args_kwargs __dict__"
    8686
    inclusion_one_default_from_template.anything = "Expected inclusion_one_default_f  
    191191@register.inclusion_tag('inclusion.html')
    192192def inclusion_unlimited_args(one, two='hi', *args):
    193193    """Expected inclusion_unlimited_args __doc__"""
    194     return {"result": "inclusion_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)]))}
     194    return {"result": "inclusion_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))}
    195195inclusion_unlimited_args.anything = "Expected inclusion_unlimited_args __dict__"
    196196
    197197@register.inclusion_tag(get_template('inclusion.html'))
    198198def inclusion_unlimited_args_from_template(one, two='hi', *args):
    199199    """Expected inclusion_unlimited_args_from_template __doc__"""
    200     return {"result": "inclusion_unlimited_args_from_template - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)]))}
     200    return {"result": "inclusion_unlimited_args_from_template - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))}
    201201inclusion_unlimited_args_from_template.anything = "Expected inclusion_unlimited_args_from_template __dict__"
    202202
    203203@register.inclusion_tag('inclusion.html')
    204204def inclusion_only_unlimited_args(*args):
    205205    """Expected inclusion_only_unlimited_args __doc__"""
    206     return {"result": "inclusion_only_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in args]))}
     206    return {"result": "inclusion_only_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in args))}
    207207inclusion_only_unlimited_args.anything = "Expected inclusion_only_unlimited_args __dict__"
    208208
    209209@register.inclusion_tag(get_template('inclusion.html'))
    210210def inclusion_only_unlimited_args_from_template(*args):
    211211    """Expected inclusion_only_unlimited_args_from_template __doc__"""
    212     return {"result": "inclusion_only_unlimited_args_from_template - Expected result: %s" % (', '.join([six.text_type(arg) for arg in args]))}
     212    return {"result": "inclusion_only_unlimited_args_from_template - Expected result: %s" % (', '.join(six.text_type(arg) for arg in args))}
    213213inclusion_only_unlimited_args_from_template.anything = "Expected inclusion_only_unlimited_args_from_template __dict__"
    214214
    215215@register.inclusion_tag('test_incl_tag_current_app.html', takes_context=True)
    def inclusion_unlimited_args_kwargs(one, two='hi', *args, **kwargs):  
    230230    # Sort the dictionary by key to guarantee the order for testing.
    231231    sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
    232232    return {"result": "inclusion_unlimited_args_kwargs - Expected result: %s / %s" % (
    233         ', '.join([six.text_type(arg) for arg in [one, two] + list(args)]),
    234         ', '.join(['%s=%s' % (k, v) for (k, v) in sorted_kwarg])
     233        ', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
     234        ', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
    235235        )}
    236236inclusion_unlimited_args_kwargs.anything = "Expected inclusion_unlimited_args_kwargs __dict__"
    237237
    assignment_one_default.anything = "Expected assignment_one_default __dict__"  
    286286@register.assignment_tag
    287287def assignment_unlimited_args(one, two='hi', *args):
    288288    """Expected assignment_unlimited_args __doc__"""
    289     return "assignment_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)]))
     289    return "assignment_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))
    290290assignment_unlimited_args.anything = "Expected assignment_unlimited_args __dict__"
    291291
    292292@register.assignment_tag
    293293def assignment_only_unlimited_args(*args):
    294294    """Expected assignment_only_unlimited_args __doc__"""
    295     return "assignment_only_unlimited_args - Expected result: %s" % ', '.join([six.text_type(arg) for arg in args])
     295    return "assignment_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args)
    296296assignment_only_unlimited_args.anything = "Expected assignment_only_unlimited_args __dict__"
    297297
    298298@register.assignment_tag
    def assignment_unlimited_args_kwargs(one, two='hi', *args, **kwargs):  
    301301    # Sort the dictionary by key to guarantee the order for testing.
    302302    sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
    303303    return "assignment_unlimited_args_kwargs - Expected result: %s / %s" % (
    304         ', '.join([six.text_type(arg) for arg in [one, two] + list(args)]),
    305         ', '.join(['%s=%s' % (k, v) for (k, v) in sorted_kwarg])
     304        ', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
     305        ', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
    306306        )
    307307assignment_unlimited_args_kwargs.anything = "Expected assignment_unlimited_args_kwargs __dict__"
    308308
  • tests/template_tests/tests.py

    diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py
    index e9c0a0f..2eb1b5e 100644
    a b class TemplateTests(TransRealMixin, TestCase):  
    473473        template_tests.update(filter_tests)
    474474
    475475        cache_loader = setup_test_template_loader(
    476             dict([(name, t[0]) for name, t in six.iteritems(template_tests)]),
     476            dict((name, t[0]) for name, t in six.iteritems(template_tests)),
    477477            use_cached_loader=True,
    478478        )
    479479
Back to Top