o
    2g                     @  s2   d Z ddlmZ ddlmZmZ G dd dZdS )zCaching utilities.    )annotations)AnyCallablec                   @  s<   e Zd ZdZdddZddddZddddZdddZdS )cachedpropertyar  A decorator for caching a property's result.

    Similar to :py:class:`property`, but the wrapped method's result is cached on the
    instance. This is achieved by setting an entry in the object's instance dictionary
    with the same name as the property. When the name is later accessed, the value in
    the instance dictionary takes precedence over the (non-data descriptor) property.

    This is useful for implementing lazy-loaded properties.

    The cache can be invalidated via :py:meth:`delattr`, or by modifying ``__dict__``
    directly. It will be repopulated on next access.

    .. versionadded:: 6.3.0

    argsr   kwargsc                 O  s   dS )z)Empty method to make sphinx run properly.N )selfr   r   r   r   G/home/garg/my-data/venv/lib/python3.10/site-packages/praw/util/cache.py__call__   s    zcachedproperty.__call__Nobj
Any | Noneobjtypereturnc                 C  s(   |du r| S |  | }|j| j j< |S )zImplement descriptor getter.

        Calculate the property's value and then store it in the associated object's
        instance dictionary.

        N)func__dict____name__)r	   r   r   valuer   r   r
   __get__   s   zcachedproperty.__get__r   Callable[[Any], Any]doc
str | Nonec                 C  s$   | | _ | _|du r|j}|| _dS )z/Initialize a :class:`.cachedproperty` instance.N)r   __wrapped____doc__)r	   r   r   r   r   r
   __init__*   s   
zcachedproperty.__init__strc                 C  s   d| j j d| j dS )z?Return an object initialization representation of the instance.< >)	__class__r   r   )r	   r   r   r
   __repr__2   s   zcachedproperty.__repr__)r   r   r   r   )N)r   r   r   r   r   r   )r   r   r   r   )r   r   )r   
__module____qualname__r   r   r   r   r    r   r   r   r
   r      s    
r   N)r   
__future__r   typingr   r   r   r   r   r   r
   <module>   s    