diff options
| author | userimack <mahendra.k12@gmail.com> | 2016-01-23 22:17:07 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-01-25 14:23:43 -0500 |
| commit | 60586dd7379b295b72d8af4e03423c286913b5e8 (patch) | |
| tree | 6f834957ea76305fbcda40e23e836077890d36b8 /django/core | |
| parent | abc0777b63057e2ff97eee2ff184356051e14c47 (diff) | |
Fixed #26125 -- Fixed E731 flake warnings.
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/cache/backends/memcached.py | 3 | ||||
| -rw-r--r-- | django/core/management/color.py | 3 | ||||
| -rw-r--r-- | django/core/management/commands/inspectdb.py | 7 | ||||
| -rw-r--r-- | django/core/management/commands/makemessages.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/makemigrations.py | 5 | ||||
| -rw-r--r-- | django/core/serializers/python.py | 9 | ||||
| -rw-r--r-- | django/core/serializers/xml_serializer.py | 3 | ||||
| -rw-r--r-- | django/core/validators.py | 32 |
8 files changed, 48 insertions, 20 deletions
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): |
