summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-12 13:00:18 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-17 11:49:15 +0100
commit5c10041f4636c3dfe637924ab24da85dd657d790 (patch)
tree18d7e7628e60a592bf7f74d11a5db4b3a5676b2d
parente01970e9d23a241473671ea26126f8440db4dead (diff)
Refs #30127 -- Removed name argument for django.utils.functional.cached_property().
Per deprecation timeline.
-rw-r--r--django/utils/functional.py12
-rw-r--r--docs/ref/utils.txt7
-rw-r--r--docs/releases/5.0.txt3
-rw-r--r--tests/utils_tests/test_functional.py26
4 files changed, 5 insertions, 43 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index fd2c3c44d6..9b059ee704 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -1,7 +1,6 @@
import copy
import itertools
import operator
-import warnings
from functools import total_ordering, wraps
@@ -23,16 +22,7 @@ class cached_property:
"__set_name__() on it."
)
- def __init__(self, func, name=None):
- from django.utils.deprecation import RemovedInDjango50Warning
-
- if name is not None:
- warnings.warn(
- "The name argument is deprecated as it's unnecessary as of "
- "Python 3.6.",
- RemovedInDjango50Warning,
- stacklevel=2,
- )
+ def __init__(self, func):
self.real_func = func
self.__doc__ = getattr(func, "__doc__")
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 2a8a8357fb..c70c374a63 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -427,7 +427,7 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
.. module:: django.utils.functional
:synopsis: Functional programming tools.
-.. class:: cached_property(func, name=None)
+.. class:: cached_property(func)
The ``@cached_property`` decorator caches the result of a method with a
single ``self`` argument as a property. The cached result will persist
@@ -509,11 +509,6 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
z = person.friends # does not call
x is z # is True
- .. deprecated:: 4.1
-
- The ``name`` parameter is deprecated and will be removed in Django 5.0
- as it's unnecessary as of Python 3.6.
-
.. class:: classproperty(method=None)
Similar to :py:func:`@classmethod <classmethod>`, the ``@classproperty``
diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt
index 0a5ab35501..c09973578a 100644
--- a/docs/releases/5.0.txt
+++ b/docs/releases/5.0.txt
@@ -308,3 +308,6 @@ to remove usage of these features.
* The ``SitemapIndexItem.__str__()`` method is removed.
* The ``CSRF_COOKIE_MASKED`` transitional setting is removed.
+
+* The ``name`` argument of ``django.utils.functional.cached_property()`` is
+ removed.
diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py
index 1e403f351b..23e2eaddcd 100644
--- a/tests/utils_tests/test_functional.py
+++ b/tests/utils_tests/test_functional.py
@@ -1,8 +1,6 @@
from unittest import mock
from django.test import SimpleTestCase
-from django.test.utils import ignore_warnings
-from django.utils.deprecation import RemovedInDjango50Warning
from django.utils.functional import cached_property, classproperty, lazy
@@ -108,30 +106,6 @@ class FunctionalTests(SimpleTestCase):
for attr in attrs:
self.assertCachedPropertyWorks(attr, Class)
- @ignore_warnings(category=RemovedInDjango50Warning)
- def test_cached_property_name(self):
- class Class:
- def other_value(self):
- """Here is the docstring..."""
- return 1, object()
-
- other = cached_property(other_value, name="other")
- other2 = cached_property(other_value, name="different_name")
-
- self.assertCachedPropertyWorks("other", Class)
- # An explicit name is ignored.
- obj = Class()
- obj.other2
- self.assertFalse(hasattr(obj, "different_name"))
-
- def test_cached_property_name_deprecation_warning(self):
- def value(self):
- return 1
-
- msg = "The name argument is deprecated as it's unnecessary as of Python 3.6."
- with self.assertWarnsMessage(RemovedInDjango50Warning, msg):
- cached_property(value, name="other_name")
-
def test_cached_property_auto_name(self):
"""
cached_property caches its value and behaves like a property