o
    沪gt                     @  s   U d dl mZ d dlZd dlmZmZmZmZmZ d dl	Z	d dl	m
Z
 d dlmZ eeZded< eded	ef d
Zeded
Zd)ddZd*ddZ		d+d,ddZ		d-d.d d!Z	d/d0d#d$Zd1d'd(ZdS )2    )annotationsN)AnyCallableFinalTypeVarcast)config)
get_loggerr   _LOGGERTFunc.)boundTObjreturnboolc                   C  s   t tdS )z<True if we should print deprecation warnings to the browser.zclient.showErrorDetails)r   r   
get_option r   r   V/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/deprecation_util.py+_should_show_deprecation_warning_in_browser   s   r   messagestrNonec                 C  s   t  rt|  t|  dS )z#Show a deprecation warning message.N)r   	streamlitwarningr
   )r   r   r   r   show_deprecation_warning#   s   
r   Told_namenew_nameremoval_dateextra_message
str | Noneinclude_st_prefixc              	   C  sJ   |rd|  } d| }d|  d| d|  d| d	|r"d|  S d S )	Nzst.zPlease replace `z` with `z`.

`z` will be removed after .z

 r   )r   r   r   r   r   r   r   r   make_deprecated_name_warning,   s   

r"   funcname_overridec                   s6   t  fdd}|_j|_tt|S )a  Wrap an `st` function whose name has changed.

    Wrapped functions will run as normal, but will also show an st.warning
    saying that the old name will be removed after removal_date.

    (We generally set `removal_date` to 3 months from the deprecation date.)

    Parameters
    ----------
    func
        The `st.` function whose name has changed.

    old_name
        The function's deprecated name within __init__.py.

    removal_date
        A date like "2020-01-01", indicating the last day we'll guarantee
        support for the deprecated name.

    extra_message
        An optional extra message to show in the deprecation warning.

    name_override
        An optional name to use in place of func.__name__.
    c                    s*   | i |}t tpj  |S N)r   r"   __name__)argskwargsresultr   r#   r$   r   r   r   r   wrapped_func_   s   z)deprecate_func_name.<locals>.wrapped_func)	functoolswrapsr&   __doc__r   r   )r#   r   r   r   r$   r+   r   r*   r   deprecate_func_name>   s
   !

r/   objc                   s   t |  fddS )a  Wrap an `st` object whose name has changed.

    Wrapped objects will behave as normal, but will also show an st.warning
    saying that the old name will be removed after `removal_date`.

    (We generally set `removal_date` to 3 months from the deprecation date.)

    Parameters
    ----------
    obj
        The `st.` object whose name has changed.

    old_name
        The object's deprecated name within __init__.py.

    new_name
        The object's new name within __init__.py.

    removal_date
        A date like "2020-01-01", indicating the last day we'll guarantee
        support for the deprecated name.

    include_st_prefix
        If False, does not prefix each of the object names in the deprecation
        essage with `st.*`. Defaults to True.
    c                     s   t t dS )N)r   )r   r"   r   r   r   r   r   r   r   <lambda>   s
    z$deprecate_obj_name.<locals>.<lambda>)_create_deprecated_obj_wrapper)r0   r   r   r   r   r   r1   r   deprecate_obj_nameo   s   "r4   show_warningCallable[[], Any]c                   s6   dd	fddG  fddd t t  S )
zCreate a wrapper for an object that has been deprecated. The first
    time one of the object's properties or functions is accessed, the
    given `show_warning` callback will be called.
    Fr   r   c                     s    s	d   d S d S NTr   r   )has_shown_warningr5   r   r   maybe_show_warning   s   
z:_create_deprecated_obj_wrapper.<locals>.maybe_show_warningc                      sH   e Zd Z fddZfddZedddZefd	d
ZdS )z/_create_deprecated_obj_wrapper.<locals>.Wrapperc                   s.     jD ]}t| j|t| | qd S r%   )_get_magic_functions	__class__setattrproperty_make_magic_function_proxy)selfname)Wrapperr0   r   r   __init__   s   z8_create_deprecated_obj_wrapper.<locals>.Wrapper.__init__c                   s$   || j v r
t| |S    t|S r%   )__dict__getattr)r?   attrr9   r0   r   r   __getattr__   s   


z;_create_deprecated_obj_wrapper.<locals>.Wrapper.__getattr__r   	list[str]c                   s   d  fddt | D S )N)r;   rC   __getattribute__rG   c                   s"   g | ]}| vr| d r|qS )__)
startswith).0r@   ignorer   r   
<listcomp>   s
    zX_create_deprecated_obj_wrapper.<locals>.Wrapper._get_magic_functions.<locals>.<listcomp>)dir)clsr   rM   r   r:      s   
zD_create_deprecated_obj_wrapper.<locals>.Wrapper._get_magic_functionsc                   s    fdd}|S )Nc                   s      t S r%   )rD   )r?   r'   )r9   r@   r0   r   r   proxy   s   
zY_create_deprecated_obj_wrapper.<locals>.Wrapper._make_magic_function_proxy.<locals>.proxyr   )r@   rR   rF   )r@   r   r>      s   zJ_create_deprecated_obj_wrapper.<locals>.Wrapper._make_magic_function_proxyN)r   rH   )r&   
__module____qualname__rB   rG   staticmethodr:   r>   r   )rA   r9   r0   r   r   rA      s    	
rA   N)r   r   )r   r   )r0   r5   r   )rA   r8   r9   r0   r5   r   r3      s   (r3   )r   r   )r   r   r   r   r7   )r   r   r   r   r   r   r   r   r   r   r   r   )NN)r#   r   r   r   r   r   r   r   r$   r   r   r   )T)r0   r   r   r   r   r   r   r   r   r   r   r   )r0   r   r5   r6   r   r   )
__future__r   r,   typingr   r   r   r   r   r   r   streamlit.loggerr	   r&   r
   __annotations__r   objectr   r   r   r"   r/   r4   r3   r   r   r   r   <module>   s(   

6,