From 71609a5b903ace05a437eb3f89859e9d35a88203 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Wed, 30 Nov 2016 00:01:12 +0000 Subject: [PATCH] Fixed #27555 -- Removed django.utils.functional.lazy_property. --- django/utils/functional.py | 21 --------------------- docs/releases/1.11.txt | 2 ++ tests/utils_tests/test_functional.py | 21 +-------------------- 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/django/utils/functional.py b/django/utils/functional.py index f86271b28d..7d5b7feea5 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -412,27 +412,6 @@ class SimpleLazyObject(LazyObject): return copy.deepcopy(self._wrapped, memo) -class lazy_property(property): - """ - A property that works with subclasses by wrapping the decorated - functions of the base class. - """ - def __new__(cls, fget=None, fset=None, fdel=None, doc=None): - if fget is not None: - @wraps(fget) - def fget(instance, instance_type=None, name=fget.__name__): - return getattr(instance, name)() - if fset is not None: - @wraps(fset) - def fset(instance, value, name=fset.__name__): - return getattr(instance, name)(value) - if fdel is not None: - @wraps(fdel) - def fdel(instance, name=fdel.__name__): - return getattr(instance, name)() - return property(fget, fset, fdel, doc) - - def partition(predicate, values): """ Splits the values into two sets, based on the return value of the function diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt index 0c60b8488b..fc4a5cc3f5 100644 --- a/docs/releases/1.11.txt +++ b/docs/releases/1.11.txt @@ -627,6 +627,8 @@ Miscellaneous * The unused ``BaseCommand.can_import_settings`` attribute is removed. +* The undocumented ``django.utils.functional.lazy_property`` is removed. + .. _deprecated-features-1.11: Features deprecated in 1.11 diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py index 1413ac23b3..7a633620fc 100644 --- a/tests/utils_tests/test_functional.py +++ b/tests/utils_tests/test_functional.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import unittest from django.utils import six -from django.utils.functional import cached_property, lazy, lazy_property +from django.utils.functional import cached_property, lazy class FunctionalTestCase(unittest.TestCase): @@ -38,25 +38,6 @@ class FunctionalTestCase(unittest.TestCase): t = lazy(lambda: Klazz(), Base)() self.assertEqual(t.method(), 'Klazz') - def test_lazy_property(self): - - class A(object): - - def _get_do(self): - raise NotImplementedError - - def _set_do(self, value): - raise NotImplementedError - do = lazy_property(_get_do, _set_do) - - class B(A): - def _get_do(self): - return "DO IT" - - with self.assertRaises(NotImplementedError): - A().do - self.assertEqual(B().do, 'DO IT') - def test_lazy_object_to_string(self): class Klazz(object):