diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2023-04-24 00:24:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 00:24:48 +0200 |
commit | 7fa848126c8178e78c47dff0415a1fc175b041eb (patch) | |
tree | 4fb9818b6eb1346ce6396831819756ef9be6aedb /astroid/decorators.py | |
parent | a91a8d60ccd5ca8e5f8e162d67b3b93444105235 (diff) | |
download | astroid-git-7fa848126c8178e78c47dff0415a1fc175b041eb.tar.gz |
Remove cachedproperty decorator (#2140)
Diffstat (limited to 'astroid/decorators.py')
-rw-r--r-- | astroid/decorators.py | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/astroid/decorators.py b/astroid/decorators.py index 48f64058..180e08c4 100644 --- a/astroid/decorators.py +++ b/astroid/decorators.py @@ -27,52 +27,6 @@ _R = TypeVar("_R") _P = ParamSpec("_P") -# TODO: Remove for astroid 3.0 -class cachedproperty: - """Provides a cached property equivalent to the stacking of - @cached and @property, but more efficient. - - After first usage, the <property_name> becomes part of the object's - __dict__. Doing: - - del obj.<property_name> empties the cache. - - Idea taken from the pyramid_ framework and the mercurial_ project. - - .. _pyramid: http://pypi.python.org/pypi/pyramid - .. _mercurial: http://pypi.python.org/pypi/Mercurial - """ - - __slots__ = ("wrapped",) - - def __init__(self, wrapped): - warnings.warn( - "cachedproperty has been deprecated and will be removed in astroid 3.0" - "Use functools.cached_property instead.", - DeprecationWarning, - stacklevel=2, - ) - try: - wrapped.__name__ # noqa[B018] - except AttributeError as exc: - raise TypeError(f"{wrapped} must have a __name__ attribute") from exc - self.wrapped = wrapped - - @property - def __doc__(self): - doc = getattr(self.wrapped, "__doc__", None) - return "<wrapped by the cachedproperty decorator>%s" % ( - "\n%s" % doc if doc else "" - ) - - def __get__(self, inst, objtype=None): - if inst is None: - return self - val = self.wrapped(inst) - setattr(inst, self.wrapped.__name__, val) - return val - - def path_wrapper(func): """Return the given infer function wrapped to handle the path. |