summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruserimack <mahendra.k12@gmail.com>2016-01-23 22:17:07 +0530
committerTim Graham <timograham@gmail.com>2016-01-25 14:23:43 -0500
commit60586dd7379b295b72d8af4e03423c286913b5e8 (patch)
tree6f834957ea76305fbcda40e23e836077890d36b8
parentabc0777b63057e2ff97eee2ff184356051e14c47 (diff)
Fixed #26125 -- Fixed E731 flake warnings.
-rw-r--r--django/conf/global_settings.py9
-rw-r--r--django/contrib/admin/templatetags/admin_list.py7
-rw-r--r--django/contrib/postgres/validators.py6
-rw-r--r--django/contrib/staticfiles/storage.py10
-rw-r--r--django/core/cache/backends/memcached.py3
-rw-r--r--django/core/management/color.py3
-rw-r--r--django/core/management/commands/inspectdb.py7
-rw-r--r--django/core/management/commands/makemessages.py6
-rw-r--r--django/core/management/commands/makemigrations.py5
-rw-r--r--django/core/serializers/python.py9
-rw-r--r--django/core/serializers/xml_serializer.py3
-rw-r--r--django/core/validators.py32
-rw-r--r--django/db/backends/base/operations.py3
-rw-r--r--django/db/backends/mysql/introspection.py5
-rw-r--r--django/db/models/fields/related.py5
-rw-r--r--django/db/models/fields/related_descriptors.py5
-rw-r--r--django/db/models/options.py16
-rw-r--r--django/http/request.py7
-rw-r--r--django/template/defaultfilters.py6
-rw-r--r--django/test/client.py10
-rw-r--r--django/utils/decorators.py3
-rw-r--r--django/utils/feedgenerator.py6
-rw-r--r--django/utils/text.py3
-rw-r--r--django/utils/translation/trans_null.py27
-rw-r--r--django/views/i18n.py5
-rw-r--r--setup.cfg2
-rw-r--r--tests/absolute_url_overrides/tests.py6
-rw-r--r--tests/admin_inlines/tests.py10
-rw-r--r--tests/admin_utils/tests.py3
-rw-r--r--tests/flatpages_tests/test_templatetags.py3
-rw-r--r--tests/forms_tests/tests/test_fields.py3
-rw-r--r--tests/lookup/tests.py6
-rw-r--r--tests/middleware/tests.py5
-rw-r--r--tests/model_meta/tests.py6
-rw-r--r--tests/test_client/tests.py3
-rw-r--r--tests/utils_tests/test_datastructures.py3
36 files changed, 176 insertions, 75 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 5128a28079..b540fbc5a3 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
+"""
+Default Django settings. Override these with settings in the module pointed to
+by the DJANGO_SETTINGS_MODULE environment variable.
+"""
from __future__ import unicode_literals
-# Default Django settings. Override these with settings in the module
-# pointed-to by the DJANGO_SETTINGS_MODULE environment variable.
# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
-gettext_noop = lambda s: s
+def gettext_noop(s):
+ return s
####################
# CORE #
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index a45cf74bf5..a1fd3b5657 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -143,7 +143,9 @@ def result_headers(cl):
o_list_primary = [] # URL for making this field the primary sort
o_list_remove = [] # URL for removing this field from sort
o_list_toggle = [] # URL for toggling order type for this field
- make_qs_param = lambda t, n: ('-' if t == 'desc' else '') + str(n)
+
+ def make_qs_param(t, n):
+ return ('-' if t == 'desc' else '') + str(n)
for j, ot in ordering_field_columns.items():
if j == i: # Same column
@@ -341,7 +343,8 @@ def date_hierarchy(cl):
month_lookup = cl.params.get(month_field)
day_lookup = cl.params.get(day_field)
- link = lambda filters: cl.get_query_string(filters, [field_generic])
+ def link(filters):
+ return cl.get_query_string(filters, [field_generic])
if not (year_lookup or month_lookup or day_lookup):
# select appropriate start level
diff --git a/django/contrib/postgres/validators.py b/django/contrib/postgres/validators.py
index 3f576873f4..69ceeea8ba 100644
--- a/django/contrib/postgres/validators.py
+++ b/django/contrib/postgres/validators.py
@@ -69,10 +69,12 @@ class KeysValidator(object):
class RangeMaxValueValidator(MaxValueValidator):
- compare = lambda self, a, b: a.upper > b
+ def compare(self, a, b):
+ return a.upper > b
message = _('Ensure that this range is completely less than or equal to %(limit_value)s.')
class RangeMinValueValidator(MinValueValidator):
- compare = lambda self, a, b: a.lower < b
+ def compare(self, a, b):
+ return a.lower < b
message = _('Ensure that this range is completely greater than or equal to %(limit_value)s.')
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index d6911c9fd7..58cb847f1f 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -217,11 +217,15 @@ class HashedFilesMixin(object):
hashed_files = OrderedDict()
# build a list of adjustable files
- matches = lambda path: matches_patterns(path, self._patterns.keys())
- adjustable_paths = [path for path in paths if matches(path)]
+ adjustable_paths = [
+ path for path in paths
+ if matches_patterns(path, self._patterns.keys())
+ ]
# then sort the files by the directory level
- path_level = lambda name: len(name.split(os.sep))
+ def path_level(name):
+ return len(name.split(os.sep))
+
for name in sorted(paths.keys(), key=path_level, reverse=True):
# use the original, local file, not the copied-but-unprocessed
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index 40f13183d4..1573746329 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -146,8 +146,7 @@ class BaseMemcachedCache(BaseCache):
self._cache.set_multi(safe_data, self.get_backend_timeout(timeout))
def delete_many(self, keys, version=None):
- l = lambda x: self.make_key(x, version=version)
- self._cache.delete_multi(map(l, keys))
+ self._cache.delete_multi(self.make_key(key, version=version) for key in keys)
def clear(self):
self._cache.flush_all()
diff --git a/django/core/management/color.py b/django/core/management/color.py
index 3803ea3e3e..7a32370860 100644
--- a/django/core/management/color.py
+++ b/django/core/management/color.py
@@ -46,7 +46,8 @@ def make_style(config_string=''):
format = color_settings.get(role, {})
style_func = termcolors.make_style(**format)
else:
- style_func = lambda x: x
+ def style_func(x):
+ return x
setattr(style, role, style_func)
# For backwards compatibility,
diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
index 7c26abba92..3bb8e75924 100644
--- a/django/core/management/commands/inspectdb.py
+++ b/django/core/management/commands/inspectdb.py
@@ -32,8 +32,11 @@ class Command(BaseCommand):
# 'table_name_filter' is a stealth option
table_name_filter = options.get('table_name_filter')
- table2model = lambda table_name: re.sub(r'[^a-zA-Z0-9]', '', table_name.title())
- strip_prefix = lambda s: s[1:] if s.startswith("u'") else s
+ def table2model(table_name):
+ return re.sub(r'[^a-zA-Z0-9]', '', table_name.title())
+
+ def strip_prefix(s):
+ return s[1:] if s.startswith("u'") else s
with connection.cursor() as cursor:
yield "# This is an auto-generated Django model module."
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 1fe17cad7f..ebec17ff01 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -365,8 +365,10 @@ class Command(BaseCommand):
Check if the given path should be ignored or not.
"""
filename = os.path.basename(path)
- ignore = lambda pattern: (fnmatch.fnmatchcase(filename, pattern) or
- fnmatch.fnmatchcase(path, pattern))
+
+ def ignore(pattern):
+ return fnmatch.fnmatchcase(filename, pattern) or fnmatch.fnmatchcase(path, pattern)
+
return any(ignore(pattern) for pattern in ignore_patterns)
ignore_patterns = [os.path.normcase(p) for p in self.ignore_patterns]
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index 2153198751..80e4314b3c 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -224,7 +224,10 @@ class Command(BaseCommand):
if mig[0] == migration.app_label
]
merge_migrations.append(migration)
- all_items_equal = lambda seq: all(item == seq[0] for item in seq[1:])
+
+ def all_items_equal(seq):
+ return all(item == seq[0] for item in seq[1:])
+
merge_migrations_generations = zip(*[m.ancestry for m in merge_migrations])
common_ancestor_count = sum(1 for common_ancestor_generation
in takewhile(all_items_equal, merge_migrations_generations))
diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
index 09a5438861..8a8a776d48 100644
--- a/django/core/serializers/python.py
+++ b/django/core/serializers/python.py
@@ -70,9 +70,11 @@ class Serializer(base.Serializer):
def handle_m2m_field(self, obj, field):
if field.remote_field.through._meta.auto_created:
if self.use_natural_foreign_keys and hasattr(field.remote_field.model, 'natural_key'):
- m2m_value = lambda value: value.natural_key()
+ def m2m_value(value):
+ return value.natural_key()
else:
- m2m_value = lambda value: force_text(value._get_pk_val(), strings_only=True)
+ def m2m_value(value):
+ return force_text(value._get_pk_val(), strings_only=True)
self._current[field.name] = [m2m_value(related)
for related in getattr(obj, field.name).iterator()]
@@ -136,7 +138,8 @@ def Deserializer(object_list, **options):
else:
return force_text(model._meta.pk.to_python(value), strings_only=True)
else:
- m2m_convert = lambda v: force_text(model._meta.pk.to_python(v), strings_only=True)
+ def m2m_convert(v):
+ return force_text(model._meta.pk.to_python(v), strings_only=True)
try:
m2m_data[field.name] = []
diff --git a/django/core/serializers/xml_serializer.py b/django/core/serializers/xml_serializer.py
index 44d745d55d..3d38217612 100644
--- a/django/core/serializers/xml_serializer.py
+++ b/django/core/serializers/xml_serializer.py
@@ -275,7 +275,8 @@ class Deserializer(base.Deserializer):
obj_pk = model._meta.pk.to_python(n.getAttribute('pk'))
return obj_pk
else:
- m2m_convert = lambda n: model._meta.pk.to_python(n.getAttribute('pk'))
+ def m2m_convert(n):
+ return model._meta.pk.to_python(n.getAttribute('pk'))
return [m2m_convert(c) for c in node.getElementsByTagName("object")]
def _get_model_from_node(self, node, attr):
diff --git a/django/core/validators.py b/django/core/validators.py
index 8c43644ed6..dd18aee3cb 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -295,8 +295,6 @@ validate_comma_separated_integer_list = int_list_validator(
@deconstructible
class BaseValidator(object):
- compare = lambda self, a, b: a is not b
- clean = lambda self, x: x
message = _('Ensure this value is %(limit_value)s (it is %(show_value)s).')
code = 'limit_value'
@@ -319,42 +317,60 @@ class BaseValidator(object):
and (self.code == other.code)
)
+ def compare(self, a, b):
+ return a is not b
+
+ def clean(self, x):
+ return x
+
@deconstructible
class MaxValueValidator(BaseValidator):
- compare = lambda self, a, b: a > b
message = _('Ensure this value is less than or equal to %(limit_value)s.')
code = 'max_value'
+ def compare(self, a, b):
+ return a > b
+
@deconstructible
class MinValueValidator(BaseValidator):
- compare = lambda self, a, b: a < b
message = _('Ensure this value is greater than or equal to %(limit_value)s.')
code = 'min_value'
+ def compare(self, a, b):
+ return a < b
+
@deconstructible
class MinLengthValidator(BaseValidator):
- compare = lambda self, a, b: a < b
- clean = lambda self, x: len(x)
message = ungettext_lazy(
'Ensure this value has at least %(limit_value)d character (it has %(show_value)d).',
'Ensure this value has at least %(limit_value)d characters (it has %(show_value)d).',
'limit_value')
code = 'min_length'
+ def compare(self, a, b):
+ return a < b
+
+ def clean(self, x):
+ return len(x)
+
@deconstructible
class MaxLengthValidator(BaseValidator):
- compare = lambda self, a, b: a > b
- clean = lambda self, x: len(x)
message = ungettext_lazy(
'Ensure this value has at most %(limit_value)d character (it has %(show_value)d).',
'Ensure this value has at most %(limit_value)d characters (it has %(show_value)d).',
'limit_value')
code = 'max_length'
+ def compare(self, a, b):
+ return a > b
+
+ def clean(self, x):
+ return len(x)
+
@deconstructible
class DecimalValidator(object):
diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py
index 6e5aff19cd..d68a5aa996 100644
--- a/django/db/backends/base/operations.py
+++ b/django/db/backends/base/operations.py
@@ -204,7 +204,8 @@ class BaseDatabaseOperations(object):
according to their own quoting schemes.
"""
# Convert params to contain Unicode values.
- to_unicode = lambda s: force_text(s, strings_only=True, errors='replace')
+ def to_unicode(s):
+ return force_text(s, strings_only=True, errors='replace')
if isinstance(params, (list, tuple)):
u_params = tuple(to_unicode(val) for val in params)
elif params is None:
diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py
index 3d0f6f3689..835276d7e1 100644
--- a/django/db/backends/mysql/introspection.py
+++ b/django/db/backends/mysql/introspection.py
@@ -71,7 +71,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
field_info = {line[0]: InfoLine(*line) for line in cursor.fetchall()}
cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
- to_int = lambda i: int(i) if i is not None else i
+
+ def to_int(i):
+ return int(i) if i is not None else i
+
fields = []
for line in cursor.description:
col_name = force_text(line[0])
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 162a84793d..2071d5ff96 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -85,7 +85,10 @@ def add_lazy_relation(cls, field, relation, operation):
"and related methods on the Apps class.",
RemovedInDjango20Warning, stacklevel=2)
# Rearrange args for new Apps.lazy_model_operation
- function = lambda local, related, field: operation(field, related, local)
+
+ def function(local, related, field):
+ return operation(field, related, local)
+
lazy_related_operation(function, cls, relation, field=field)
diff --git a/django/db/models/fields/related_descriptors.py b/django/db/models/fields/related_descriptors.py
index 050866efce..8f45a9231b 100644
--- a/django/db/models/fields/related_descriptors.py
+++ b/django/db/models/fields/related_descriptors.py
@@ -300,7 +300,10 @@ class ReverseOneToOneDescriptor(object):
queryset._add_hints(instance=instances[0])
rel_obj_attr = attrgetter(self.related.field.attname)
- instance_attr = lambda obj: obj._get_pk_val()
+
+ def instance_attr(obj):
+ return obj._get_pk_val()
+
instances_dict = {instance_attr(inst): inst for inst in instances}
query = {'%s__in' % self.related.field.name: instances}
queryset = queryset.filter(**query)
diff --git a/django/db/models/options.py b/django/db/models/options.py
index 2f1f930ec5..4fdcc025f7 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -371,11 +371,17 @@ class Options(object):
# use that property directly because related_model is a cached property,
# and all the models may not have been loaded yet; we don't want to cache
# the string reference to the related_model.
- is_not_an_m2m_field = lambda f: not (f.is_relation and f.many_to_many)
- is_not_a_generic_relation = lambda f: not (f.is_relation and f.one_to_many)
- is_not_a_generic_foreign_key = lambda f: not (
- f.is_relation and f.many_to_one and not (hasattr(f.remote_field, 'model') and f.remote_field.model)
- )
+ def is_not_an_m2m_field(f):
+ return not (f.is_relation and f.many_to_many)
+
+ def is_not_a_generic_relation(f):
+ return not (f.is_relation and f.one_to_many)
+
+ def is_not_a_generic_foreign_key(f):
+ return not (
+ f.is_relation and f.many_to_one and not (hasattr(f.remote_field, 'model') and f.remote_field.model)
+ )
+
return make_immutable_fields_list(
"fields",
(f for f in self._get_fields(reverse=False) if
diff --git a/django/http/request.py b/django/http/request.py
index 22405d8306..d6ce49d755 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -481,9 +481,12 @@ class QueryDict(MultiValueDict):
output = []
if safe:
safe = force_bytes(safe, self.encoding)
- encode = lambda k, v: '%s=%s' % ((quote(k, safe), quote(v, safe)))
+
+ def encode(k, v):
+ return '%s=%s' % ((quote(k, safe), quote(v, safe)))
else:
- encode = lambda k, v: urlencode({k: v})
+ def encode(k, v):
+ return urlencode({k: v})
for k, list_ in self.lists():
k = force_bytes(k, self.encoding)
output.extend(encode(k, force_bytes(v, self.encoding))
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 71727208c3..631118f4b9 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -639,7 +639,8 @@ def unordered_list(value, autoescape=True):
if autoescape:
escaper = conditional_escape
else:
- escaper = lambda x: x
+ def escaper(x):
+ return x
def walk_items(item_list):
item_iterator = iter(item_list)
@@ -850,7 +851,8 @@ def filesizeformat(bytes_):
value = ungettext("%(size)d byte", "%(size)d bytes", 0) % {'size': 0}
return avoid_wrapping(value)
- filesize_number_format = lambda value: formats.number_format(round(value, 1), 1)
+ def filesize_number_format(value):
+ return formats.number_format(round(value, 1), 1)
KB = 1 << 10
MB = 1 << 20
diff --git a/django/test/client.py b/django/test/client.py
index 78a5df5c52..61c2136b09 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -160,10 +160,13 @@ def encode_multipart(boundary, data):
as an application/octet-stream; otherwise, str(value) will be sent.
"""
lines = []
- to_bytes = lambda s: force_bytes(s, settings.DEFAULT_CHARSET)
+
+ def to_bytes(s):
+ return force_bytes(s, settings.DEFAULT_CHARSET)
# Not by any means perfect, but good enough for our purposes.
- is_file = lambda thing: hasattr(thing, "read") and callable(thing.read)
+ def is_file(thing):
+ return hasattr(thing, "read") and callable(thing.read)
# Each bit of the multipart form data could be either a form value or a
# file, or a *list* of form values and/or files. Remember that HTTP field
@@ -198,7 +201,8 @@ def encode_multipart(boundary, data):
def encode_file(boundary, key, file):
- to_bytes = lambda s: force_bytes(s, settings.DEFAULT_CHARSET)
+ def to_bytes(s):
+ return force_bytes(s, settings.DEFAULT_CHARSET)
filename = os.path.basename(file.name) if hasattr(file, 'name') else ''
if hasattr(file, 'content_type'):
content_type = file.content_type
diff --git a/django/utils/decorators.py b/django/utils/decorators.py
index 87a702d3d8..7ba31a32e3 100644
--- a/django/utils/decorators.py
+++ b/django/utils/decorators.py
@@ -159,7 +159,8 @@ def make_middleware_decorator(middleware_class):
# Defer running of process_response until after the template
# has been rendered:
if hasattr(middleware, 'process_response'):
- callback = lambda response: middleware.process_response(request, response)
+ def callback(response):
+ return middleware.process_response(request, response)
response.add_post_render_callback(callback)
else:
if hasattr(middleware, 'process_response'):
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 3fae71cdee..367245be22 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -91,7 +91,8 @@ class SyndicationFeed(object):
def __init__(self, title, link, description, language=None, author_email=None,
author_name=None, author_link=None, subtitle=None, categories=None,
feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
- to_unicode = lambda s: force_text(s, strings_only=True)
+ def to_unicode(s):
+ return force_text(s, strings_only=True)
if categories:
categories = [force_text(c) for c in categories]
if ttl is not None:
@@ -126,7 +127,8 @@ class SyndicationFeed(object):
objects, and enclosures, which is an iterable of instances of the
Enclosure class.
"""
- to_unicode = lambda s: force_text(s, strings_only=True)
+ def to_unicode(s):
+ return force_text(s, strings_only=True)
if categories:
categories = [to_unicode(c) for c in categories]
if ttl is not None:
diff --git a/django/utils/text.py b/django/utils/text.py
index af80812a0d..46872372ac 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -19,7 +19,8 @@ if six.PY2:
# Capitalizes the first letter of a string.
-capfirst = lambda x: x and force_text(x)[0].upper() + force_text(x)[1:]
+def capfirst(x):
+ return x and force_text(x)[0].upper() + force_text(x)[1:]
capfirst = keep_lazy_text(capfirst)
# Set up regular expressions
diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
index cb909c63f7..7d02fa5607 100644
--- a/django/utils/translation/trans_null.py
+++ b/django/utils/translation/trans_null.py
@@ -24,11 +24,28 @@ def pgettext(context, message):
def npgettext(context, singular, plural, number):
return ungettext(singular, plural, number)
-activate = lambda x: None
-deactivate = deactivate_all = lambda: None
-get_language = lambda: settings.LANGUAGE_CODE
-get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI
-check_for_language = lambda x: True
+
+def activate(x):
+ return None
+
+
+def deactivate():
+ return None
+
+
+deactivate_all = deactivate
+
+
+def get_language():
+ return settings.LANGUAGE_CODE
+
+
+def get_language_bidi():
+ return settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI
+
+
+def check_for_language(x):
+ return True
def gettext(message):
diff --git a/django/views/i18n.py b/django/views/i18n.py
index 37d38d9e74..974b63e194 100644
--- a/django/views/i18n.py
+++ b/django/views/i18n.py
@@ -186,7 +186,10 @@ js_catalog_template = r"""
def render_javascript_catalog(catalog=None, plural=None):
template = Engine().from_string(js_catalog_template)
- indent = lambda s: s.replace('\n', '\n ')
+
+ def indent(s):
+ return s.replace('\n', '\n ')
+
context = Context({
'catalog_str': indent(json.dumps(
catalog, sort_keys=True, indent=2)) if catalog else None,
diff --git a/setup.cfg b/setup.cfg
index 9ba33169ae..8579282aec 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8]
exclude = build,.git,./django/utils/lru_cache.py,./django/utils/six.py,./django/conf/app_template/*,./django/dispatch/weakref_backports.py,./tests/.env,./xmlrunner,tests/view_tests/tests/py3_test_debug.py,tests/template_tests/annotated_tag_function.py
-ignore = E123,E128,E402,W503,E731,W601
+ignore = E123,E128,E402,W503,W601
max-line-length = 119
[isort]
diff --git a/tests/absolute_url_overrides/tests.py b/tests/absolute_url_overrides/tests.py
index 7187456112..6879283083 100644
--- a/tests/absolute_url_overrides/tests.py
+++ b/tests/absolute_url_overrides/tests.py
@@ -10,7 +10,8 @@ class AbsoluteUrlOverrideTests(SimpleTestCase):
"""
get_absolute_url() functions as a normal method.
"""
- get_absolute_url = lambda o: '/test-a/%s/' % o.pk
+ def get_absolute_url(o):
+ return '/test-a/%s/' % o.pk
TestA = self._create_model_class('TestA', get_absolute_url)
self.assertTrue(hasattr(TestA, 'get_absolute_url'))
@@ -21,7 +22,8 @@ class AbsoluteUrlOverrideTests(SimpleTestCase):
"""
ABSOLUTE_URL_OVERRIDES should override get_absolute_url().
"""
- get_absolute_url = lambda o: '/test-b/%s/' % o.pk
+ def get_absolute_url(o):
+ return '/test-b/%s/' % o.pk
with self.settings(
ABSOLUTE_URL_OVERRIDES={
'absolute_url_overrides.testb': lambda o: '/overridden-test-b/%s/' % o.pk,
diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
index f59f87e6de..450ff1ffda 100644
--- a/tests/admin_inlines/tests.py
+++ b/tests/admin_inlines/tests.py
@@ -729,8 +729,9 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
reverse('admin:admin_inlines_holder4_add')))
inline_id = '#inner4stacked_set-group'
- rows_length = lambda: len(self.selenium.find_elements_by_css_selector(
- '%s .dynamic-inner4stacked_set' % inline_id))
+
+ def rows_length():
+ return len(self.selenium.find_elements_by_css_selector('%s .dynamic-inner4stacked_set' % inline_id))
self.assertEqual(rows_length(), 3)
add_button = self.selenium.find_element_by_link_text(
@@ -745,8 +746,9 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
reverse('admin:admin_inlines_holder4_add')))
inline_id = '#inner4stacked_set-group'
- rows_length = lambda: len(self.selenium.find_elements_by_css_selector(
- '%s .dynamic-inner4stacked_set' % inline_id))
+
+ def rows_length():
+ return len(self.selenium.find_elements_by_css_selector('%s .dynamic-inner4stacked_set' % inline_id))
self.assertEqual(rows_length(), 3)
add_button = self.selenium.find_element_by_link_text(
diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py
index 694c529b76..01ec6702cc 100644
--- a/tests/admin_utils/tests.py
+++ b/tests/admin_utils/tests.py
@@ -111,7 +111,8 @@ class UtilsTests(SimpleTestCase):
def get_admin_value(self, obj):
return ADMIN_METHOD
- simple_function = lambda obj: SIMPLE_FUNCTION
+ def simple_function(obj):
+ return SIMPLE_FUNCTION
site_obj = Site(domain=SITE_NAME)
article = Article(
diff --git a/tests/flatpages_tests/test_templatetags.py b/tests/flatpages_tests/test_templatetags.py
index 994491e1a0..dbe1446988 100644
--- a/tests/flatpages_tests/test_templatetags.py
+++ b/tests/flatpages_tests/test_templatetags.py
@@ -141,7 +141,8 @@ class FlatpageTemplateTagTests(TestCase):
def test_parsing_errors(self):
"There are various ways that the flatpages template tag won't parse"
- render = lambda t: Template(t).render(Context())
+ def render(t):
+ return Template(t).render(Context())
self.assertRaises(TemplateSyntaxError, render,
"{% load flatpages %}{% get_flatpages %}")
diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py
index 1bab912cfc..45545cdb48 100644
--- a/tests/forms_tests/tests/test_fields.py
+++ b/tests/forms_tests/tests/test_fields.py
@@ -1173,7 +1173,8 @@ class FieldsTests(SimpleTestCase):
)
def test_choicefield_callable(self):
- choices = lambda: [('J', 'John'), ('P', 'Paul')]
+ def choices():
+ return [('J', 'John'), ('P', 'Paul')]
f = ChoiceField(choices=choices)
self.assertEqual('J', f.clean('J'))
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index 203f25406a..bc1f3aacce 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -141,7 +141,8 @@ class LookupTests(TestCase):
def test_values(self):
# values() returns a list of dictionaries instead of object instances --
# and you can specify which fields you want to retrieve.
- identity = lambda x: x
+ def identity(x):
+ return x
self.assertQuerysetEqual(Article.objects.values('headline'),
[
{'headline': 'Article 5'},
@@ -276,7 +277,8 @@ class LookupTests(TestCase):
# returned as a list of tuples, rather than a list of dictionaries.
# Within each tuple, the order of the elements is the same as the order
# of fields in the values_list() call.
- identity = lambda x: x
+ def identity(x):
+ return x
self.assertQuerysetEqual(Article.objects.values_list('headline'),
[
('Article 5',),
diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py
index bf96f05048..202f7511cd 100644
--- a/tests/middleware/tests.py
+++ b/tests/middleware/tests.py
@@ -707,12 +707,11 @@ class GZipMiddlewareTest(SimpleTestCase):
"""
Compression is performed on FileResponse.
"""
- open_file = lambda: open(__file__, 'rb')
- with open_file() as file1:
+ with open(__file__, 'rb') as file1:
file_resp = FileResponse(file1)
file_resp['Content-Type'] = 'text/html; charset=UTF-8'
r = GZipMiddleware().process_response(self.req, file_resp)
- with open_file() as file2:
+ with open(__file__, 'rb') as file2:
self.assertEqual(self.decompress(b''.join(r)), file2.read())
self.assertEqual(r.get('Content-Encoding'), 'gzip')
self.assertIsNot(r.file_to_stream, file1)
diff --git a/tests/model_meta/tests.py b/tests/model_meta/tests.py
index 1dbfca0c8e..cfae4736fa 100644
--- a/tests/model_meta/tests.py
+++ b/tests/model_meta/tests.py
@@ -68,7 +68,8 @@ class DataTests(OptionsBaseTests):
self.assertEqual([f.attname for f in fields], expected_result)
def test_local_fields(self):
- is_data_field = lambda f: isinstance(f, Field) and not isinstance(f, related.ManyToManyField)
+ def is_data_field(f):
+ return isinstance(f, Field) and not isinstance(f, related.ManyToManyField)
for model, expected_result in TEST_RESULTS['local_fields'].items():
fields = model._meta.local_fields
@@ -101,7 +102,8 @@ class M2MTests(OptionsBaseTests):
class RelatedObjectsTests(OptionsBaseTests):
- key_name = lambda self, r: r[0]
+ def key_name(self, r):
+ return r[0]
def test_related_objects(self):
result_key = 'get_all_related_objects_with_model'
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index ccddf76cf1..d8e0b9d6f0 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -690,7 +690,8 @@ class CustomTestClientTest(SimpleTestCase):
self.assertEqual(hasattr(self.client, "i_am_customized"), True)
-_generic_view = lambda request: HttpResponse(status=200)
+def _generic_view(request):
+ return HttpResponse(status=200)
@override_settings(ROOT_URLCONF='test_client.urls')
diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py
index 99f7a1d05f..d151f12bb5 100644
--- a/tests/utils_tests/test_datastructures.py
+++ b/tests/utils_tests/test_datastructures.py
@@ -126,7 +126,8 @@ class ImmutableListTests(SimpleTestCase):
class DictWrapperTests(SimpleTestCase):
def test_dictwrapper(self):
- f = lambda x: "*%s" % x
+ def f(x):
+ return "*%s" % x
d = DictWrapper({'a': 'a'}, f, 'xx_')
self.assertEqual(
"Normal: %(a)s. Modified: %(xx_a)s" % d,