o
    沪g<<                     @  s  d dl mZ d dlZd dlmZmZ d dlmZ G dd deZ	G dd de	Z
G d	d
 d
e	ZG dd de	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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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G d/d0 d0eZ G d1d2 d2eZ!G d3d4 d4eZ"G d5d6 d6eZ#G d7d8 d8eZ$G d9d: d:eZ%G d;d< d<eZ&G d=d> d>eZ'G d?d@ d@eZ(G dAdB dBeZ)G dCdD dDeZ*G dEdF dFeZ+G dGdH dHeZ,G dIdJ dJeZ-G dKdL dLeZ.G dMdN dNeZ/G dOdP dPeZ0dS )Q    )annotationsN)AnyLiteral)utilc                   @     e Zd ZdZdS )ErrorzThe base class for all exceptions thrown by Streamlit.

    Should be used for exceptions raised due to user errors (typically via
    StreamlitAPIException) as well as exceptions raised by Streamlit's internal
    code.
    N__name__
__module____qualname____doc__ r   r   L/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/errors.pyr      s    r   c                   @  r   )CustomComponentErrorz5Exceptions thrown in the custom components code path.Nr   r   r   r   r   r   "   s    r   c                   @     e Zd ZdS )DeprecationErrorNr	   r
   r   r   r   r   r   r   (       r   c                   @  r   )FragmentStorageKeyErrorzXA KeyError raised when a KeyError is encountered during a FragmentStorage
    operation.Nr   r   r   r   r   r   ,   s    r   c                   @  r   )FragmentHandledExceptionz^An exception that is raised by the fragment
    when it has handled the exception itself.
    Nr   r   r   r   r   r   3   s    r   c                   @  r   )NoStaticFilesNr   r   r   r   r   r   ;   r   r   c                   @  r   )NoSessionContextNr   r   r   r   r   r   ?   r   r   c                   @  r   )MarkdownFormattedExceptionzExceptions with Markdown in their description.

    Instances of this class can use markdown in their messages, which will get
    nicely formatted on the frontend.
    Nr   r   r   r   r   r   C   s    r   c                   @  s   e Zd ZdZdddZdS )StreamlitAPIExceptiona  Base class for Streamlit API exceptions.

    An API exception should be thrown when user code interacts with the
    Streamlit API incorrectly. (That is, when we throw an exception as a
    result of a user's malformed `st.foo` call, it should be a
    StreamlitAPIException or subclass.)

    When displaying these exceptions on the frontend, we strip Streamlit
    entries from the stack trace so that the user doesn't see a bunch of
    noise related to Streamlit internals.

    returnstrc                 C  
   t | S Nr   repr_selfr   r   r   __repr__[      
zStreamlitAPIException.__repr__Nr   r   )r	   r
   r   r   r"   r   r   r   r   r   M   s    r   c                   @  r   )DuplicateWidgetIDNr   r   r   r   r   r%   _   r   r%   c                   @  r   )StreamlitAuthErrorNr   r   r   r   r   r&   c   r   r&   c                      "   e Zd ZdZd fddZ  ZS )StreamlitDuplicateElementIdzKAn exception raised when the auto-generated ID of an element is not unique.element_typer   c                   s   t  d| d| d d S )NzThere are multiple `a&  ` elements with the same auto-generated ID. When this element is created, it is assigned an internal ID based on the element type and provided parameters. Multiple elements with the same type and parameters will cause this error.

To fix this error, please pass a unique `key` argument to the `z
` element.super__init__)r!   r)   	__class__r   r   r,   j   s
   z$StreamlitDuplicateElementId.__init__)r)   r   r	   r
   r   r   r,   __classcell__r   r   r-   r   r(   g       r(   c                      r'   )StreamlitDuplicateElementKeyz=An exception raised when the key of an element is not unique.user_keyr   c                   s   t  d| d d S )Nz0There are multiple elements with the same `key='z`'`. To fix this, please make sure that the `key` argument is unique for each element you create.r*   )r!   r3   r-   r   r   r,   x   s   
z%StreamlitDuplicateElementKey.__init__)r3   r   r/   r   r   r-   r   r2   u   r1   r2   c                   @  r   )UnserializableSessionStateErrorNr   r   r   r   r   r4      r   r4   c                      s*   e Zd ZdZ fddZdddZ  ZS )	StreamlitAPIWarningzsUsed to display a warning.

    Note that this should not be "raised", but passed to st.exception
    instead.
    c                   s4   t  j|  dd l}dd l}| }||| _d S )Nr   )r+   r,   inspect	tracebackcurrentframeextract_stacktacked_on_stack)r!   argsr6   r7   fr-   r   r   r,      s
   zStreamlitAPIWarning.__init__r   r   c                 C  r   r   r   r    r   r   r   r"      r#   zStreamlitAPIWarning.__repr__r$   )r	   r
   r   r   r,   r"   r0   r   r   r-   r   r5      s    r5   c                          e Zd ZdZ fddZ  ZS )StreamlitModuleNotFoundErrorzsPrint a pretty message when a Streamlit command requires a dependency
    that is not one of our core dependencies.c                   s$   d| d}t  j|g|R   d S )Nz(This Streamlit command requires module "z" to be installed.r*   )r!   module_namer;   messager-   r   r   r,      s   
z%StreamlitModuleNotFoundError.__init__r/   r   r   r-   r   r>      s    r>   c                      s,   e Zd Zd	 fddZed
ddZ  ZS )LocalizableStreamlitExceptionr@   r   c                   s"   t  |jdi | || _d S )Nr   )r+   r,   format_exec_kwargs)r!   r@   kwargsr-   r   r   r,      s   
z&LocalizableStreamlitException.__init__r   dict[str, Any]c                 C  s   | j S r   )rC   r    r   r   r   exec_kwargs   s   z)LocalizableStreamlitException.exec_kwargsr@   r   )r   rE   )r	   r
   r   r,   propertyrF   r0   r   r   r-   r   rA      s    rA   c                      r=   )-StreamlitSetPageConfigMustBeFirstCommandErrorz^Exception raised when the set_page_config command is not the first executed streamlit command.c                      t  d d S )Nz`set_page_config()` can only be called once per app page, and must be called as the first Streamlit command in your script.

For more information refer to the [docs](https://docs.streamlit.io/develop/api-reference/configuration/st.set_page_config).r*   r    r-   r   r   r,         z6StreamlitSetPageConfigMustBeFirstCommandError.__init__r/   r   r   r-   r   rI          rI   c                      r'   )StreamlitInvalidPageLayoutErrorz?Exception raised when an invalid value is specified for layout.layoutr   c                      t  jd|d d S )Nz<`layout` must be `"centered"` or `"wide"` (got `"{layout}"`))rN   r*   )r!   rN   r-   r   r   r,         
z(StreamlitInvalidPageLayoutError.__init__)rN   r   r/   r   r   r-   r   rM      r1   rM   c                      r'   )!StreamlitInvalidSidebarStateErrorzPException raised when an invalid value is specified for `initial_sidebar_state`.initial_sidebar_stater   c                   rO   )Nzk`initial_sidebar_state` must be `"auto"` or `"expanded"` or `"collapsed"` (got `"{initial_sidebar_state}"`))rR   r*   )r!   rR   r-   r   r   r,      rP   z*StreamlitInvalidSidebarStateError.__init__)rR   r   r/   r   r   r-   r   rQ      r1   rQ   c                      r'   ) StreamlitInvalidMenuItemKeyErrorz2Exception raised when an invalid key is specified.keyr   c                   rO   )NzfWe only accept the keys: `"Get help"`, `"Report a bug"`, and `"About"` (`"{key}"` is not a valid key.)rT   r*   r!   rT   r-   r   r   r,      rP   z)StreamlitInvalidMenuItemKeyError.__init__rT   r   r/   r   r   r-   r   rS      r1   rS   c                      r'   )StreamlitInvalidURLErroruc   Exception raised when an invalid URL is specified for any of the menu items except for “About”.urlr   c                   rO   )Nzw"{url}" is a not a valid URL. You must use a fully qualified domain beginning with "http://", "https://", or "mailto:".)rY   r*   )r!   rY   r-   r   r   r,         
z!StreamlitInvalidURLError.__init__)rY   r   r/   r   r   r-   r   rX      r1   rX   c                      r=   )StreamlitInvalidColumnSpecErrorzRException raised when no weights are specified, or a negative weight is specified.c                   rJ   )Na  The `spec` argument to `st.columns` must be either a positive integer (number of columns) or a list of positive numbers (width ratios of the columns). See [documentation](https://docs.streamlit.io/develop/api-reference/layout/st.columns) for more information.r*   r    r-   r   r   r,      rK   z(StreamlitInvalidColumnSpecError.__init__r/   r   r   r-   r   r[      rL   r[   c                      r'   )&StreamlitInvalidVerticalAlignmentErrorzKException raised when an invalid value is specified for vertical_alignment.vertical_alignmentr   c                   rO   )NzThe `vertical_alignment` argument to `st.columns` must be `"top"`, `"center"`, or `"bottom"`. 
The argument passed was {vertical_alignment}.)r]   r*   )r!   r]   r-   r   r   r,      rZ   z/StreamlitInvalidVerticalAlignmentError.__init__)r]   r   r/   r   r   r-   r   r\      r1   r\   c                      r'   )StreamlitInvalidColumnGapErrorz<Exception raised when an invalid value is specified for gap.gapr   c                   rO   )NzoThe `gap` argument to `st.columns` must be `"small"`, `"medium"`, or `"large"`. 
The argument passed was {gap}.)r_   r*   )r!   r_   r-   r   r   r,      rZ   z'StreamlitInvalidColumnGapError.__init__)r_   r   r/   r   r   r-   r   r^      r1   r^   c                      "   e Zd ZdZd fddZ  ZS )&StreamlitSelectionCountExceedsMaxErrorzdException raised when there are more default selections specified than the max allowable selections.current_selections_countintmax_selections_countc                   s2   t  jd||dkrdnd||dkrdndd d S )Na  Multiselect has {current_selections_count} {current_selections_noun} selected but `max_selections` is set to {max_selections_count}. This happened because you either gave too many options to `default` or you manipulated the widget's state through `st.session_state`. Note that the latter can happen before the line indicated in the traceback. Please select at most {max_selections_count} {options_noun}.   optionoptions)rb   current_selections_nounrd   options_nounr*   )r!   rb   rd   r-   r   r   r,   	  s   
z/StreamlitSelectionCountExceedsMaxError.__init__)rb   rc   rd   rc   r/   r   r   r-   r   ra     r1   ra   c                      s"   e Zd ZdZd
 fdd	Z  ZS )StreamlitMixedNumericTypesErrorz;Exception raised mixing floats and ints in st.number_input.value#int | float | Literal['min'] | None	min_valueint | float | None	max_valuestepc           
        s   d }d }d }d }d}	|rt |j}|	d7 }	|r t |j}|	d7 }	|r+t |j}|	d7 }	|r6t |j}|	d7 }	t j|	||||d d S )Nz1All numerical arguments must be of the same type.z
`value` has {value_type} type.z'
`min_value` has {min_value_type} type.z'
`max_value` has {max_value_type} type.z
`step` has {step_type} type.)
value_typemin_value_typemax_value_type	step_type)typer	   r+   r,   )
r!   rk   rm   ro   rp   rq   rr   rs   rt   error_messager-   r   r   r,     s0   




z(StreamlitMixedNumericTypesError.__init__)rk   rl   rm   rn   ro   rn   rp   rn   r/   r   r   r-   r   rj     r1   rj   c                      r`   )StreamlitValueBelowMinErrorzBException raised when the `min_value` is greater than the `value`.rk   int | floatrm   c                      t  jd||d d S )Nz=The `value` {value} is less than the `min_value` {min_value}.)rk   rm   r*   )r!   rk   rm   r-   r   r   r,   H  
   
z$StreamlitValueBelowMinError.__init__)rk   rx   rm   rx   r/   r   r   r-   r   rw   E  r1   rw   c                      r`   )StreamlitValueAboveMaxErrorz?Exception raised when the `max_value` is less than the `value`.rk   rx   ro   c                   ry   )NzEThe `value` {value} is greater than than the `max_value` {max_value}.)rk   ro   r*   )r!   rk   ro   r-   r   r   r,   S  rz   z$StreamlitValueAboveMaxError.__init__)rk   rx   ro   rx   r/   r   r   r-   r   r{   P  r1   r{   c                      r'   )StreamlitJSNumberBoundsErrorz=Exception raised when a number exceeds the Javascript limits.r@   r   c                   s   t  | d S r   r*   )r!   r@   r-   r   r   r,   ^     z%StreamlitJSNumberBoundsError.__init__rG   r/   r   r   r-   r   r|   [  r1   r|   c                      r'   )!StreamlitInvalidNumberFormatErrorzcException raised when the format string for `st.number_input` contains
    invalid characters.
    rB   r   c                   rO   )NzIFormat string for `st.number_input` contains invalid characters: {format})rB   r*   )r!   rB   r-   r   r   r,   g  rP   z*StreamlitInvalidNumberFormatError.__init__)rB   r   r/   r   r   r-   r   r~   b  s    r~   c                      r=   )StreamlitMissingPageLabelErrorz=Exception raised when a page_link is created without a label.c                   rJ   )NzeThe `label` param is required for external links used with `st.page_link` - please provide a `label`.r*   r    r-   r   r   r,   r  rK   z'StreamlitMissingPageLabelError.__init__r/   r   r   r-   r   r   o  rL   r   c                      s"   e Zd ZdZd	 fddZ  ZS )
StreamlitPageNotFoundErrorz2Exception raised the linked page can not be found.pager   main_script_directory	is_mpa_v2boolc                   s.   t j|}d}|rd}t j|||d d S )NzCould not find page: `{page}`. You must provide a file path relative to the entrypoint file (from the directory `{directory}`). Only the entrypoint file and files in the `pages/` directory are supported.zCould not find page: `{page}`. You must provide a `StreamlitPage` object or file path relative to the entrypoint file. Only pages previously defined by `st.Page` and passed to `st.navigation` are allowed.)r   	directory)ospathbasenamer+   r,   )r!   r   r   r   r   r@   r-   r   r   r,   {  s   
z#StreamlitPageNotFoundError.__init__)r   r   r   r   r   r   r/   r   r   r-   r   r   x  r1   r   c                      r=   ).StreamlitFragmentWidgetsNotAllowedOutsideErrorz\Exception raised when the fragment attempts to write to an element outside of its container.c                   rJ   )Nz5Fragments cannot write widgets to outside containers.r*   r    r-   r   r   r,     r}   z7StreamlitFragmentWidgetsNotAllowedOutsideError.__init__r/   r   r   r-   r   r     rL   r   c                      r=   )!StreamlitInvalidFormCallbackErrorzoException raised a `on_change` callback is set on any element in a form except for the `st.form_submit_button`.c                   rJ   )NzWithin a form, callbacks can only be defined on `st.form_submit_button`. Defining callbacks on other widgets inside a form is not allowed.r*   r    r-   r   r   r,     rK   z*StreamlitInvalidFormCallbackError.__init__r/   r   r   r-   r   r     rL   r   c                      r'   )'StreamlitValueAssignmentNotAllowedErrorzHException raised when trying to set values where writes are not allowed.rT   r   c                   rO   )NzPValues for the widget with `key` '{key}' cannot be set using `st.session_state`.rU   r*   rV   r-   r   r   r,     rP   z0StreamlitValueAssignmentNotAllowedError.__init__rW   r/   r   r   r-   r   r     r1   r   c                      s   e Zd Z fddZ  ZS )StreamlitInvalidColorErrorc                   s   t  jdt|d d S )NzThis does not look like a valid color: {color}.

Colors must be in one of the following formats:* Hex string with 3, 4, 6, or 8 digits. Example: `'#00ff00'`* List or tuple with 3 or 4 components. Example: `[1.0, 0.5, 0, 0.2]`)color)r+   r,   repr)r!   r   r-   r   r   r,     s   
z#StreamlitInvalidColorError.__init__)r	   r
   r   r,   r0   r   r   r-   r   r     s    r   c                      r'   )StreamlitBadTimeStringErrorzMException Raised when a time string argument is passed that cannot be parsed.time_stringr   c                   rO   )NzqTime string doesn't look right. It should be formatted as`'1d2h34m'` or `2 days`, for example. Got: {time_string})r   r*   )r!   r   r-   r   r   r,     rZ   z$StreamlitBadTimeStringError.__init__)r   r   r/   r   r   r-   r   r     r1   r   )1
__future__r   r   typingr   r   	streamlitr   	Exceptionr   r   r   KeyErrorr   r   r   r   r   r   r%   r&   r(   r2   r4   Warningr5   r>   rA   rI   rM   rQ   rS   rX   r[   r\   r^   ra   rj   rw   r{   r|   r~   r   r   r   r   r   r   r   r   r   r   r   <module>   sT   



*	

