From 9d304b26cf2ce071a682bf68a29dee04d0e4cfdb Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 31 Dec 2016 09:52:31 -0500 Subject: [PATCH] Refs #20223 -- Removed deprecated django.utils.functional.allow_lazy(). --- django/utils/functional.py | 10 ---------- docs/ref/utils.txt | 7 ------- docs/releases/2.0.txt | 2 ++ tests/decorators/tests.py | 15 +-------------- 4 files changed, 3 insertions(+), 31 deletions(-) diff --git a/django/utils/functional.py b/django/utils/functional.py index 7d5b7feea55..794f31047c5 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -1,10 +1,8 @@ import copy import operator -import warnings from functools import total_ordering, wraps from django.utils import six -from django.utils.deprecation import RemovedInDjango20Warning # You can't trivially replace this with `functools.partial` because this binds @@ -189,14 +187,6 @@ def lazystr(text): return lazy(force_text, six.text_type)(text) -def allow_lazy(func, *resultclasses): - warnings.warn( - "django.utils.functional.allow_lazy() is deprecated in favor of " - "django.utils.functional.keep_lazy()", - RemovedInDjango20Warning, 2) - return keep_lazy(*resultclasses)(func) - - def keep_lazy(*resultclasses): """ A decorator that allows a function to be called with one or more lazy diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 1105dc9a169..5870c955f6d 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -518,13 +518,6 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004 z = person.friends # does not call x is z # is True -.. function:: allow_lazy(func, *resultclasses) - - .. deprecated:: 1.10 - - Works like :meth:`~django.utils.functional.keep_lazy` except that it can't - be used as a decorator. - .. function:: keep_lazy(func, *resultclasses) .. versionadded:: 1.10 diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 0bc5c8d388a..1acfdb59009 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -336,3 +336,5 @@ these features. * The ``cascaded_union`` property of ``django.contrib.gis.geos.MultiPolygon`` is removed. + +* ``django.utils.functional.allow_lazy()`` is removed. diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py index f8f8f4dc0a5..851c2b8daa9 100644 --- a/tests/decorators/tests.py +++ b/tests/decorators/tests.py @@ -8,13 +8,9 @@ from django.contrib.auth.decorators import ( from django.http import HttpRequest, HttpResponse, HttpResponseNotAllowed from django.middleware.clickjacking import XFrameOptionsMiddleware from django.test import SimpleTestCase -from django.utils import six from django.utils.decorators import method_decorator -from django.utils.deprecation import RemovedInDjango20Warning -from django.utils.encoding import force_text -from django.utils.functional import allow_lazy, keep_lazy, keep_lazy_text, lazy +from django.utils.functional import keep_lazy, keep_lazy_text, lazy from django.utils.safestring import mark_safe -from django.utils.translation import ugettext_lazy from django.views.decorators.cache import ( cache_control, cache_page, never_cache, ) @@ -155,15 +151,6 @@ class DecoratorsTest(TestCase): request.method = 'DELETE' self.assertIsInstance(my_safe_view(request), HttpResponseNotAllowed) - def test_deprecated_allow_lazy(self): - with self.assertRaises(RemovedInDjango20Warning): - def noop_text(text): - return force_text(text) - noop_text = allow_lazy(noop_text, six.text_type) - rendered = noop_text(ugettext_lazy("I am a text")) - self.assertEqual(type(rendered), six.text_type) - self.assertEqual(rendered, "I am a text") - # For testing method_decorator, a decorator that assumes a single argument. # We will get type arguments if there is a mismatch in the number of arguments.