Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove a bunch of unnescesarry iterkeys() calls

  • Loading branch information...
commit 4c97101b1f0815a3f311fc77483b935fe62966bb 1 parent 576ec12
@alex alex authored
Showing with 42 additions and 42 deletions.
  1. +1 −1  django/conf/__init__.py
  2. +2 −2 django/contrib/admin/options.py
  3. +1 −1  django/contrib/admin/templatetags/admin_list.py
  4. +1 −1  django/contrib/auth/admin.py
  5. +1 −1  django/contrib/auth/tests/forms.py
  6. +1 −1  django/contrib/formtools/wizard/views.py
  7. +1 −1  django/contrib/gis/db/backends/mysql/operations.py
  8. +1 −1  django/contrib/gis/db/backends/oracle/operations.py
  9. +2 −2 django/contrib/gis/db/backends/postgis/operations.py
  10. +1 −1  django/contrib/gis/db/backends/spatialite/operations.py
  11. +1 −1  django/contrib/gis/db/models/query.py
  12. +1 −1  django/contrib/gis/db/models/sql/compiler.py
  13. +1 −1  django/core/management/__init__.py
  14. +1 −1  django/core/serializers/__init__.py
  15. +1 −1  django/core/validators.py
  16. +2 −2 django/db/models/base.py
  17. +1 −1  django/db/models/deletion.py
  18. +1 −1  django/db/models/fields/__init__.py
  19. +4 −4 django/db/models/fields/related.py
  20. +2 −2 django/db/models/options.py
  21. +9 −9 django/db/models/query.py
  22. +3 −3 django/db/models/sql/query.py
  23. +1 −1  django/template/defaulttags.py
  24. +1 −1  django/utils/datastructures.py
  25. +1 −1  django/utils/dictconfig.py
View
2  django/conf/__init__.py
@@ -158,7 +158,7 @@ def __getattr__(self, name):
return getattr(self.default_settings, name)
def __dir__(self):
- return list(six.iterkeys(self.__dict__)) + dir(self.default_settings)
+ return list(self.__dict__) + dir(self.default_settings)
# For Python < 2.6:
__members__ = property(lambda self: self.__dir__())
View
4 django/contrib/admin/options.py
@@ -425,7 +425,7 @@ def get_fieldsets(self, request, obj=None):
if self.declared_fieldsets:
return self.declared_fieldsets
form = self.get_form(request, obj)
- fields = list(six.iterkeys(form.base_fields)) + list(self.get_readonly_fields(request, obj))
+ fields = list(form.base_fields) + list(self.get_readonly_fields(request, obj))
return [(None, {'fields': fields})]
def get_form(self, request, obj=None, **kwargs):
@@ -1415,7 +1415,7 @@ def get_fieldsets(self, request, obj=None):
if self.declared_fieldsets:
return self.declared_fieldsets
form = self.get_formset(request, obj).form
- fields = list(six.iterkeys(form.base_fields)) + list(self.get_readonly_fields(request, obj))
+ fields = list(form.base_fields) + list(self.get_readonly_fields(request, obj))
return [(None, {'fields': fields})]
def queryset(self, request):
View
2  django/contrib/admin/templatetags/admin_list.py
@@ -126,7 +126,7 @@ def result_headers(cl):
if i in ordering_field_columns:
sorted = True
order_type = ordering_field_columns.get(i).lower()
- sort_priority = list(six.iterkeys(ordering_field_columns)).index(i) + 1
+ sort_priority = list(ordering_field_columns).index(i) + 1
th_classes.append('sorted %sending' % order_type)
new_order_type = {'asc': 'desc', 'desc': 'asc'}[order_type]
View
2  django/contrib/auth/admin.py
@@ -129,7 +129,7 @@ def user_change_password(self, request, id, form_url=''):
else:
form = self.change_password_form(user)
- fieldsets = [(None, {'fields': list(six.iterkeys(form.base_fields))})]
+ fieldsets = [(None, {'fields': list(form.base_fields)})]
adminForm = admin.helpers.AdminForm(form, fieldsets, {})
context = {
View
2  django/contrib/auth/tests/forms.py
@@ -204,7 +204,7 @@ def test_success(self):
def test_field_order(self):
# Regression test - check the order of fields:
user = User.objects.get(username='testclient')
- self.assertEqual(list(six.iterkeys(PasswordChangeForm(user, {}).fields)),
+ self.assertEqual(list(PasswordChangeForm(user, {}).fields),
['old_password', 'new_password1', 'new_password2'])
View
2  django/contrib/formtools/wizard/views.py
@@ -44,7 +44,7 @@ def __repr__(self):
@property
def all(self):
"Returns the names of all steps/forms."
- return list(six.iterkeys(self._wizard.get_form_list()))
+ return list(self._wizard.get_form_list())
@property
def count(self):
View
2  django/contrib/gis/db/backends/mysql/operations.py
@@ -32,7 +32,7 @@ class MySQLOperations(DatabaseOperations, BaseSpatialOperations):
'within' : 'MBRWithin',
}
- gis_terms = dict([(term, None) for term in list(six.iterkeys(geometry_functions)) + ['isnull']])
+ gis_terms = dict([(term, None) for term in list(geometry_functions) + ['isnull']])
def geo_db_type(self, f):
return f.geom_type
View
2  django/contrib/gis/db/backends/oracle/operations.py
@@ -128,7 +128,7 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
geometry_functions.update(distance_functions)
gis_terms = ['isnull']
- gis_terms += list(six.iterkeys(geometry_functions))
+ gis_terms += list(geometry_functions)
gis_terms = dict([(term, None) for term in gis_terms])
truncate_params = {'relate' : None}
View
4 django/contrib/gis/db/backends/postgis/operations.py
@@ -217,8 +217,8 @@ def get_dist_ops(operator):
# Creating a dictionary lookup of all GIS terms for PostGIS.
gis_terms = ['isnull']
- gis_terms += list(six.iterkeys(self.geometry_operators))
- gis_terms += list(six.iterkeys(self.geometry_functions))
+ gis_terms += list(self.geometry_operators)
+ gis_terms += list(self.geometry_functions)
self.gis_terms = dict([(term, None) for term in gis_terms])
self.area = prefix + 'Area'
View
2  django/contrib/gis/db/backends/spatialite/operations.py
@@ -131,7 +131,7 @@ def __init__(self, connection):
# Creating the GIS terms dictionary.
gis_terms = ['isnull']
- gis_terms += list(six.iterkeys(self.geometry_functions))
+ gis_terms += list(self.geometry_functions)
self.gis_terms = dict([(term, None) for term in gis_terms])
if version >= (2, 4, 0):
View
2  django/contrib/gis/db/models/query.py
@@ -26,7 +26,7 @@ def values_list(self, *fields, **kwargs):
flat = kwargs.pop('flat', False)
if kwargs:
raise TypeError('Unexpected keyword arguments to values_list: %s'
- % (list(six.iterkeys(kwargs)),))
+ % (list(kwargs),))
if flat and len(fields) > 1:
raise TypeError("'flat' is not valid when values_list is called with more than one field.")
return self._clone(klass=GeoValuesListQuerySet, setup=True, flat=flat,
View
2  django/contrib/gis/db/models/sql/compiler.py
@@ -171,7 +171,7 @@ def resolve_columns(self, row, fields=()):
objects.
"""
values = []
- aliases = list(six.iterkeys(self.query.extra_select))
+ aliases = list(self.query.extra_select)
# Have to set a starting row number offset that is used for
# determining the correct starting row index -- needed for
View
2  django/core/management/__init__.py
@@ -295,7 +295,7 @@ def autocomplete(self):
except IndexError:
curr = ''
- subcommands = list(six.iterkeys(get_commands())) + ['help']
+ subcommands = list(get_commands()) + ['help']
options = [('--help', None)]
# subcommand
View
2  django/core/serializers/__init__.py
@@ -76,7 +76,7 @@ def get_serializer(format):
def get_serializer_formats():
if not _serializers:
_load_serializers()
- return list(six.iterkeys(_serializers))
+ return list(_serializers)
def get_public_serializer_formats():
if not _serializers:
View
2  django/core/validators.py
@@ -138,7 +138,7 @@ def ip_address_validators(protocol, unpack_ipv4):
return ip_address_validator_map[protocol.lower()]
except KeyError:
raise ValueError("The protocol '%s' is unknown. Supported: %s"
- % (protocol, list(six.iterkeys(ip_address_validator_map))))
+ % (protocol, list(ip_address_validator_map)))
comma_separated_int_list_re = re.compile('^[\d,]+$')
validate_comma_separated_integer_list = RegexValidator(comma_separated_int_list_re, _('Enter only digits separated by commas.'), 'invalid')
View
4 django/db/models/base.py
@@ -388,14 +388,14 @@ def __init__(self, *args, **kwargs):
setattr(self, field.attname, val)
if kwargs:
- for prop in list(six.iterkeys(kwargs)):
+ for prop in list(kwargs):
try:
if isinstance(getattr(self.__class__, prop), property):
setattr(self, prop, kwargs.pop(prop))
except AttributeError:
pass
if kwargs:
- raise TypeError("'%s' is an invalid keyword argument for this function" % list(six.iterkeys(kwargs))[0])
+ raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])
super(Model, self).__init__()
signals.post_init.send(sender=self.__class__, instance=self)
View
2  django/db/models/deletion.py
@@ -207,7 +207,7 @@ def instances_with_model(self):
def sort(self):
sorted_models = []
concrete_models = set()
- models = list(six.iterkeys(self.data))
+ models = list(self.data)
while len(sorted_models) < len(models):
found = False
for model in models:
View
2  django/db/models/fields/__init__.py
@@ -489,7 +489,7 @@ def formfield(self, form_class=forms.CharField, **kwargs):
# Many of the subclass-specific formfield arguments (min_value,
# max_value) don't apply for choice fields, so be sure to only pass
# the values that TypedChoiceField will understand.
- for k in list(six.iterkeys(kwargs)):
+ for k in list(kwargs):
if k not in ('coerce', 'empty_value', 'choices', 'required',
'widget', 'label', 'initial', 'help_text',
'error_messages', 'show_hidden_initial'):
View
8 django/db/models/fields/related.py
@@ -241,7 +241,7 @@ def get_prefetch_query_set(self, instances):
rel_obj_attr = attrgetter(self.related.field.attname)
instance_attr = lambda obj: obj._get_pk_val()
instances_dict = dict((instance_attr(inst), inst) for inst in instances)
- params = {'%s__pk__in' % self.related.field.name: list(six.iterkeys(instances_dict))}
+ params = {'%s__pk__in' % self.related.field.name: list(instances_dict)}
qs = self.get_query_set(instance=instances[0]).filter(**params)
# Since we're going to assign directly in the cache,
# we must manage the reverse relation cache manually.
@@ -335,9 +335,9 @@ def get_prefetch_query_set(self, instances):
instance_attr = attrgetter(self.field.attname)
instances_dict = dict((instance_attr(inst), inst) for inst in instances)
if other_field.rel:
- params = {'%s__pk__in' % self.field.rel.field_name: list(six.iterkeys(instances_dict))}
+ params = {'%s__pk__in' % self.field.rel.field_name: list(instances_dict)}
else:
- params = {'%s__in' % self.field.rel.field_name: list(six.iterkeys(instances_dict))}
+ params = {'%s__in' % self.field.rel.field_name: list(instances_dict)}
qs = self.get_query_set(instance=instances[0]).filter(**params)
# Since we're going to assign directly in the cache,
# we must manage the reverse relation cache manually.
@@ -488,7 +488,7 @@ def get_prefetch_query_set(self, instances):
instance_attr = attrgetter(attname)
instances_dict = dict((instance_attr(inst), inst) for inst in instances)
db = self._db or router.db_for_read(self.model, instance=instances[0])
- query = {'%s__%s__in' % (rel_field.name, attname): list(six.iterkeys(instances_dict))}
+ query = {'%s__%s__in' % (rel_field.name, attname): list(instances_dict)}
qs = super(RelatedManager, self).get_query_set().using(db).filter(**query)
# Since we just bypassed this class' get_query_set(), we must manage
# the reverse relation manually.
View
4 django/db/models/options.py
@@ -258,7 +258,7 @@ def _many_to_many(self):
self._m2m_cache
except AttributeError:
self._fill_m2m_cache()
- return list(six.iterkeys(self._m2m_cache))
+ return list(self._m2m_cache)
many_to_many = property(_many_to_many)
def get_m2m_with_model(self):
@@ -416,7 +416,7 @@ def get_all_related_many_to_many_objects(self, local_only=False):
cache = self._fill_related_many_to_many_cache()
if local_only:
return [k for k, v in cache.items() if not v]
- return list(six.iterkeys(cache))
+ return list(cache)
def get_all_related_m2m_objects_with_model(self):
"""
View
18 django/db/models/query.py
@@ -246,8 +246,8 @@ def iterator(self):
requested = None
max_depth = self.query.max_depth
- extra_select = list(six.iterkeys(self.query.extra_select))
- aggregate_select = list(six.iterkeys(self.query.aggregate_select))
+ extra_select = list(self.query.extra_select)
+ aggregate_select = list(self.query.aggregate_select)
only_load = self.query.get_loaded_field_names()
if not fill_cache:
@@ -594,7 +594,7 @@ def values_list(self, *fields, **kwargs):
flat = kwargs.pop('flat', False)
if kwargs:
raise TypeError('Unexpected keyword arguments to values_list: %s'
- % (list(six.iterkeys(kwargs)),))
+ % (list(kwargs),))
if flat and len(fields) > 1:
raise TypeError("'flat' is not valid when values_list is called with more than one field.")
return self._clone(klass=ValuesListQuerySet, setup=True, flat=flat,
@@ -694,7 +694,7 @@ def select_related(self, *fields, **kwargs):
depth = kwargs.pop('depth', 0)
if kwargs:
raise TypeError('Unexpected keyword arguments to select_related: %s'
- % (list(six.iterkeys(kwargs)),))
+ % (list(kwargs),))
obj = self._clone()
if fields:
if depth:
@@ -752,7 +752,7 @@ def annotate(self, *args, **kwargs):
obj = self._clone()
- obj._setup_aggregate_query(list(six.iterkeys(kwargs)))
+ obj._setup_aggregate_query(list(kwargs))
# Add the aggregates to the query
for (alias, aggregate_expr) in kwargs.items():
@@ -967,9 +967,9 @@ def __init__(self, *args, **kwargs):
def iterator(self):
# Purge any extra columns that haven't been explicitly asked for
- extra_names = list(six.iterkeys(self.query.extra_select))
+ extra_names = list(self.query.extra_select)
field_names = self.field_names
- aggregate_names = list(six.iterkeys(self.query.aggregate_select))
+ aggregate_names = list(self.query.aggregate_select)
names = extra_names + field_names + aggregate_names
@@ -1098,9 +1098,9 @@ def iterator(self):
# When extra(select=...) or an annotation is involved, the extra
# cols are always at the start of the row, and we need to reorder
# the fields to match the order in self._fields.
- extra_names = list(six.iterkeys(self.query.extra_select))
+ extra_names = list(self.query.extra_select)
field_names = self.field_names
- aggregate_names = list(six.iterkeys(self.query.aggregate_select))
+ aggregate_names = list(self.query.aggregate_select)
names = extra_names + field_names + aggregate_names
View
6 django/db/models/sql/query.py
@@ -1303,7 +1303,7 @@ def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
- names = opts.get_all_field_names() + list(six.iterkeys(self.aggregate_select))
+ names = opts.get_all_field_names() + list(self.aggregate_select)
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
@@ -1661,8 +1661,8 @@ def add_fields(self, field_names, allow_m2m=True):
# from the model on which the lookup failed.
raise
else:
- names = sorted(opts.get_all_field_names() + list(six.iterkeys(self.extra))
- + list(six.iterkeys(self.aggregate_select)))
+ names = sorted(opts.get_all_field_names() + list(self.extra)
+ + list(self.aggregate_select))
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
self.remove_inherited_models()
View
2  django/template/defaulttags.py
@@ -1189,7 +1189,7 @@ def templatetag(parser, token):
if tag not in TemplateTagNode.mapping:
raise TemplateSyntaxError("Invalid templatetag argument: '%s'."
" Must be one of: %s" %
- (tag, list(six.iterkeys(TemplateTagNode.mapping))))
+ (tag, list(TemplateTagNode.mapping)))
return TemplateTagNode(tag)
@register.tag
View
2  django/utils/datastructures.py
@@ -129,7 +129,7 @@ def __init__(self, data=None):
data = list(data)
super(SortedDict, self).__init__(data)
if isinstance(data, dict):
- self.keyOrder = list(six.iterkeys(data))
+ self.keyOrder = list(data)
else:
self.keyOrder = []
seen = set()
View
2  django/utils/dictconfig.py
@@ -363,7 +363,7 @@ def configure(self):
#which were in the previous configuration but
#which are not in the new configuration.
root = logging.root
- existing = list(six.iterkeys(root.manager.loggerDict))
+ existing = list(root.manager.loggerDict)
#The list needs to be sorted so that we can
#avoid disabling child loggers of explicitly
#named loggers. With a sorted list it is easier
Please sign in to comment.
Something went wrong with that request. Please try again.