o
    h                     @  s   d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZmZ er,d dlmZ dZd ddZd!ddZG dd deZG dd de	ZG dd deZG dd deZG dd de	ZG dd deZG dd de	ZdS )"    )annotations)TYPE_CHECKINGAny)	type_util)MarkdownFormattedExceptionStreamlitAPIException)	CacheTypeget_decorator_api_name)FunctionTypez?https://docs.streamlit.io/develop/concepts/architecture/cachingfuncr   returnstrc                 C  sH   t | drd| j dS t t| drdt| j dS dt|  dS )z1Get markdown representation of the function name.__name__`z()`)hasattrr   type)r    r   Z/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/runtime/caching/cache_errors.pyget_cached_func_name_md   s
   
r   return_valuec                 C  s:   t | drt t| drd| j dt| j dS t| S )N
__module__r   r   .)r   r   r   r   r   )r   r   r   r   get_return_value_type&   s   r   c                   @     e Zd ZdS )UnhashableTypeErrorNr   r   __qualname__r   r   r   r   r   ,       r   c                      s,   e Zd Zd fddZedddZ  ZS )UnhashableParamError
cache_typer   r   r
   arg_name
str | None	arg_valuer   orig_excBaseExceptionc                   s,   |  ||||}t | | |j d S )N)_create_messagesuper__init__with_traceback__traceback__)selfr   r   r    r"   r#   msg	__class__r   r   r'   1   s   zUnhashableParamError.__init__r   r   c                 C  sj   |d ur|nd}t |}|j}|d urd| nd}d| d| d| dt|  d| d	| d
dS )Nz	(unnamed)__argz
Cannot hash argument 'z' (of type `z`) in 'z'.

To address this, you can tell Streamlit not to hash this argument by adding a
leading underscore to the argument's name in the function signature:

```
@st.z
def (z , ...):
    ...
```
            
)r   get_fqn_typer   r	   strip)r   r   r    r"   arg_name_strarg_type	func_namearg_replacement_namer   r   r   r%   =   s&   
z$UnhashableParamError._create_message)
r   r   r   r
   r    r!   r"   r   r#   r$   )
r   r   r   r
   r    r!   r"   r   r   r   )r   r   r   r'   staticmethodr%   __classcell__r   r   r,   r   r   0   s    r   c                   @  r   )CacheKeyNotFoundErrorNr   r   r   r   r   r:   Y   r   r:   c                   @  r   )
CacheErrorNr   r   r   r   r   r;   ]   r   r;   c                      s   e Zd Zd fddZ  ZS )CacheReplayClosureErrorr   r   cached_funcr
   c                   sJ   t |}t|}d| d| d| d| d| dd}t | d S )Nz
While running a  , a streamlit element is called on some layout block
created outside the function. This is incompatible with replaying the cached
effect of that element, because the the referenced block might not exist when
the replay happens.

How to fix this:
* Move the creation of $THING inside z6.
* Move the call to the streamlit element outside of z.
* Remove the `@st.z` decorator from z.
            r1   )r   r	   r3   r&   r'   )r*   r   r=   r6   decorator_namer+   r,   r   r   r'   b   s    		z CacheReplayClosureError.__init__)r   r   r=   r
   )r   r   r   r'   r9   r   r   r,   r   r<   a   s    r<   c                   @  s   e Zd ZdddZdS )UnserializableReturnValueErrorr   r
   r   c              
   C  s,   t | dt| dt| dt d d S )Nz8
            Cannot serialize the return value (of type z)
            in a  . `st.cache_data` uses
            [pickle](https://docs.python.org/3/library/pickle.html) to serialize the
            function's return value and safely store it in the cache
            without mutating the original object. Please convert the return value to a
            pickle-serializable type. If you want to cache unserializable objects such
            as database connections or Tensorflow sessions, use `st.cache_resource`
            instead (see [our docs](z) for differences).)r   r'   r   r   CACHE_DOCS_URL)r*   r   r   r   r   r   r'   |   s   z'UnserializableReturnValueError.__init__N)r   r
   r   r
   )r   r   r   r'   r   r   r   r   r?   {   s    r?   c                   @  s   e Zd ZdZdS )UnevaluatedDataFrameErrorzAUsed to display a message about uncollected dataframe being used.N)r   r   r   __doc__r   r   r   r   rA      s    rA   N)r   r   r   r   )r   r   r   r   )
__future__r   typingr   r   	streamlitr   streamlit.errorsr   r   $streamlit.runtime.caching.cache_typer   r	   typesr
   r@   r   r   	Exceptionr   r   r:   r;   r<   r?   rA   r   r   r   r   <module>   s"   

	)