summaryrefslogtreecommitdiff
path: root/django/utils/functional.py
diff options
context:
space:
mode:
authormgaligniana <marcelogaligniana@gmail.com>2021-12-15 01:15:41 -0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-12-16 18:52:27 +0100
commit068b2c072b0d28cbd5ea63811779629cdaad8638 (patch)
tree9e0a5b82e996babb7094e31081c17ac699929777 /django/utils/functional.py
parentbf7afe9c4e21f5fe5090c47b2b6ffc5a03a85815 (diff)
Fixed #30127 -- Deprecated name argument of cached_property().
Diffstat (limited to 'django/utils/functional.py')
-rw-r--r--django/utils/functional.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 5f12aa08ff..ea46cff20f 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -1,6 +1,7 @@
import copy
import itertools
import operator
+import warnings
from functools import total_ordering, wraps
@@ -11,8 +12,6 @@ class cached_property:
A cached property can be made out of an existing method:
(e.g. ``url = cached_property(get_absolute_url)``).
- The optional ``name`` argument is obsolete as of Python 3.6 and will be
- deprecated in Django 4.0 (#30127).
"""
name = None
@@ -24,6 +23,15 @@ class cached_property:
)
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,
+ )
self.real_func = func
self.__doc__ = getattr(func, '__doc__')