o
    Yh                     @  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dZ		d-d.ddZ		d/d0d!d"Z	d+d1d$d%Zd2d(d)ZdS )3    )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   [/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/streamlit/deprecation_util.py!_error_details_in_browser_enabled   s   r   Tmessagestrshow_in_browserNonec                 C  s"   t  r
|r
t|  t|  dS )a  Show a deprecation warning message.

    Parameters
    ----------
    message : str
        The deprecation warning message.
    show_in_browser : bool, default=True
        Whether to show the deprecation warning in the browser. When this is True,
        we will show the deprecation warning in the browser unless the user has
        disabled error details in the browser by setting the `client.showErrorDetails`
        config option to "none".
    N)r   	streamlitwarningr
   )r   r   r   r   r   show_deprecation_warning#   s   

r   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_warning7   s   

r#   funcname_overridec                   s8   t d	 fdd}|_j|_td|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__.
    argsr   kwargsr   c                    s<   | i |}t tptdrtjnd  |S )N__name__unknown)r   r#   hasattrr   r(   )r&   r'   resultr   r$   r%   r   r   r   r   wrapped_funcj   s   	z)deprecate_func_name.<locals>.wrapped_funcr   N)r&   r   r'   r   r   r   )	functoolswrapsr(   __doc__r   )r$   r   r   r   r%   r-   r   r,   r   deprecate_func_nameI   s
   !
r1   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
        message 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)r2   r   r   r   r    r   r3   r   deprecate_obj_name~   s   "r6   show_warningCallable[[], Any]c                   s6   dd
fddG  fddd t d  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_warningr7   r   r   maybe_show_warning   s   
z:_create_deprecated_obj_wrapper.<locals>.maybe_show_warningc                      sN   e Zd Zd fddZdfdd	ZedddZedfddZdS )z/_create_deprecated_obj_wrapper.<locals>.Wrapperr   r   c                   s.     jD ]}t| j|t| | qd S N)_get_magic_functions	__class__setattrproperty_make_magic_function_proxy)selfname)Wrapperr2   r   r   __init__   s   z8_create_deprecated_obj_wrapper.<locals>.Wrapper.__init__attrr   r   c                   s$   || j v r
t| |S    t|S r<   )__dict__getattr)rB   rF   r;   r2   r   r   __getattr__   s   


z;_create_deprecated_obj_wrapper.<locals>.Wrapper.__getattr__self_clstype[object]	list[str]c                   s   d  fddt | D S )N)r>   rG   __getattribute__rJ   c                   s"   g | ]}| vr| d r|qS )__)
startswith).0rC   ignorer   r   
<listcomp>   s
    zX_create_deprecated_obj_wrapper.<locals>.Wrapper._get_magic_functions.<locals>.<listcomp>)dir)rK   r   rR   r   r=      s   
zD_create_deprecated_obj_wrapper.<locals>.Wrapper._get_magic_functionsrC   Callable[[Any], Any]c                   s   d fdd}|S )N_selfr   r&   r   c                   s      t S r<   )rH   )rW   r&   )r;   rC   r2   r   r   proxy   s   
zY_create_deprecated_obj_wrapper.<locals>.Wrapper._make_magic_function_proxy.<locals>.proxy)rW   r   r&   r   r   r   r   )rC   rX   rI   )rC   r   rA      s   zJ_create_deprecated_obj_wrapper.<locals>.Wrapper._make_magic_function_proxyNr   r   )rF   r   r   r   )rK   rL   r   rM   )rC   r   r   rV   )r(   
__module____qualname__rE   rJ   staticmethodr=   rA   r   )rD   r;   r2   r   r   rD      s    	
rD   r   NrY   )r   )r2   r7   r   )rD   r:   r;   r2   r7   r   r5      s   (r5   )r   r   )T)r   r   r   r   r   r   r9   )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   )r2   r   r   r   r   r   r   r   r    r   r   r   )r2   r   r7   r8   r   r   )
__future__r   r.   typingr   r   r   r   r   r   r   streamlit.loggerr	   r(   r
   __annotations__r   objectr   r   r   r#   r1   r6   r5   r   r   r   r   <module>   s(   
:,