
    g                    
   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Zdd	Z G d
 de      Z G d de	      Z G d de      Z G d de      Z G d de	      Z G d de      Z G d de	      Zy)    )annotations)TYPE_CHECKINGAny)	type_util)MarkdownFormattedExceptionStreamlitAPIException)	CacheTypeget_decorator_api_name)FunctionTypez?https://docs.streamlit.io/develop/concepts/architecture/cachingc                    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)funcs    [/var/www/openai/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_errors.pyget_cached_func_name_mdr      sZ    tZ 4==/%%	dZ	(4:&&'q))tDzl!    c                    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   )return_values    r   get_return_value_typer   &   sM    |\*wtL7I:/V<**+1T,-?-H-H,IKK"<00r   c                      e Zd Zy)UnhashableTypeErrorNr   r   __qualname__ r   r   r   r   ,       r   r   c                  Z     e Zd Z	 	 	 	 	 	 	 	 	 	 d fdZe	 	 	 	 	 	 	 	 	 	 dd       Z xZS )UnhashableParamErrorc                    | j                  ||||      }t        | 	  |       | j                  |j                         y )N)_create_messagesuper__init__with_traceback__traceback__)self
cache_typer   arg_name	arg_valueorig_excmsg	__class__s          r   r%   zUnhashableParamError.__init__1   s<     "":tXyIH223r   c                    ||nd}t        j                  |      }|j                  }|d| nd}d| d| d| dt        |        d| d	| d
j	                  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_names           r   r#   z$UnhashableParamError._create_message=   s     $,#7x[)))4MM	191E8*~6#nL
') M J'( )Kq%& ' %+	r   )
r)   r	   r   r   r*   
str | Noner+   r   r,   BaseException)
r)   r	   r   r   r*   r:   r+   r   returnstr)r   r   r   r%   staticmethodr#   __classcell__r.   s   @r   r!   r!   0   sz    
4
4 
4 	
4
 
4  
4   	
 
 r   r!   c                      e Zd Zy)CacheKeyNotFoundErrorNr   r   r   r   rB   rB   Y   r   r   rB   c                      e Zd Zy)
CacheErrorNr   r   r   r   rD   rD   ]   r   r   rD   c                  (     e Zd Z	 	 	 	 d fdZ xZS )CacheReplayClosureErrorc                    t        |      }t        |      }d| d| d| d| d| dj                  d      }t        |   |       y )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.
            r3   )r   r
   r5   r$   r%   )r(   r)   cached_funcr8   decorator_namer-   r.   s         r   r%   z CacheReplayClosureError.__init__b   su    
 ,K8	/
;k & '0[ 155>K @!""3I; ?
 %+ 	 	r   )r)   r	   rH   r   )r   r   r   r%   r?   r@   s   @r   rF   rF   a   s     " r   rF   c                      e Zd ZddZy)UnserializableReturnValueErrorc           
     p    t        j                  | dt        |       dt        |       dt         d       y )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   s      r   r%   z'UnserializableReturnValueError.__init__|   sJ    "++88Ml8[7\ ]'-. /% &4$44GK	
r   N)r   r   r   r   )r   r   r   r%   r   r   r   rK   rK   {   s    
r   rK   c                      e Zd ZdZy)UnevaluatedDataFrameErrorz@Used to display a message about uncollected dataframe being usedN)r   r   r   __doc__r   r   r   rO   rO      s    Jr   rO   N)r   r   r<   r=   )r   r   r<   r=   )
__future__r   typingr   r   	streamlitr   streamlit.errorsr   r   $streamlit.runtime.caching.cache_typer	   r
   typesr   rM   r   r   	Exceptionr   r!   rB   rD   rF   rK   rO   r   r   r   <module>rX      s    # %  N R"R1	) 	&0 &R	I 		 	3 4
%? 
 	 5 	r   