o
    i,                     @  s  d dl mZ d dl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mZmZmZmZ ejdk r;d dlmZ ed	ed
edZededZeded
edZededZedddZedddZd%ddZd&dd Zd!d" ZG d#d deee ZG d$d dee eZ dS )'    )annotationsN)CallableSequence)partial)getmroisclass)TYPE_CHECKINGGenericTypeTypeVarcastoverload)      )r   _BaseExceptionT_coT)bound	covariantdefault_BaseExceptionT)r   _ExceptionT_co_ExceptionT_ExceptionGroupSelfExceptionGroup_BaseExceptionGroupSelfBaseExceptionGroupexcBaseExceptionparentstuple[type[BaseException]]returnboolc                 C  s*   t | jd d D ]	}||v r dS q	dS )NTF)r   	__class__)r   r   cls r$   m/home/www/bk.finsightngr.online/finsigh_v2/venv200/lib/python3.10/site-packages/exceptiongroup/_exceptions.pycheck_direct_subclass   s
   r&   	condition`type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] | Callable[[_BaseExceptionT_co], bool]$Callable[[_BaseExceptionT_co], bool]c                 C  st   t | rtttt | trtt| fdS t| tr-t	dd | D r)tt| dS tdt
| r6td| S td)N)r   c                 s  s"    | ]}t |ot|tV  qd S N)r   
issubclassr   ).0xr$   r$   r%   	<genexpr>-   s     z'get_condition_filter.<locals>.<genexpr>zCallable[[BaseException], bool]z?expected a function, exception type or tuple of exception types)r   r+   r   r
   r   r   r&   
isinstancetupleallcallable	TypeError)r'   r$   r$   r%   get_condition_filter#   s   


r4   c                 C  s<   |  |}| j|_| j|_| j|_t| drt| j|_|S )N	__notes__)derive	__cause____context____traceback__hasattrlistr5   )selfZexcsZegr$   r$   r%   _derive_and_copy_attributes5   s   

r=   c                      s   e Zd ZdZd= fd
dZd>ddZd?ddZed@ddZedAddZ	e
dBddZe
dCd dZe
dDd#dZdEd%dZe
dFd'd(Ze
dGd*d(Ze
dHd,d(ZdId/d(Ze
dJd3d4Ze
dKd7d4ZdKd8d4Zd@d9d:Zd@d;d<Z  ZS )Lr   z/A combination of multiple unrelated exceptions.r#   type[_BaseExceptionGroupSelf]_BaseExceptionGroup__messagestr_BaseExceptionGroup__exceptionsSequence[_BaseExceptionT_co]r   r   c                   s   t |tstdt| t |tstd|stdt|D ]\}}t |ts2td| dq!| tu rBt	dd |D rBt
} t| tra|D ]}t |ts`| t
u rXtdtd	| jqIt | ||}t||_|S )
Nzargument 1 must be str, not z/second argument (exceptions) must be a sequencez9second argument (exceptions) must be a non-empty sequencezItem z4 of second argument (exceptions) is not an exceptionc                 s  s    | ]}t |tV  qd S r*   )r/   	Exception)r,   r   r$   r$   r%   r.   X   s    z-BaseExceptionGroup.__new__.<locals>.<genexpr>z/Cannot nest BaseExceptions in an ExceptionGroupzCannot nest BaseExceptions in )r/   r@   r3   typer   
ValueError	enumerater   r   r1   r   r+   rC   __name__super__new__r0   _exceptions)r#   r?   rA   ir   instancer"   r$   r%   rI   C   s>   








zBaseExceptionGroup.__new__argsobjectNonec                 G  s   t j| ||g|R   d S r*   )r   __init__)r<   r?   rA   rN   r$   r$   r%   rQ   k   s   zBaseExceptionGroup.__init__notec                 C  sF   t |tstd|dt|j dt| dsg | _| j| d S )NzExpected a string, got note=z (type )r5   )r/   r@   r3   rD   rG   r:   r5   append)r<   rR   r$   r$   r%   add_notes   s   

zBaseExceptionGroup.add_notec                 C  s
   | j d S )Nr   )rN   r<   r$   r$   r%   message~   s   
zBaseExceptionGroup.messageGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]c                 C  s
   t | jS r*   )r0   rJ   rV   r$   r$   r%   
exceptions   s   
zBaseExceptionGroup.exceptions_BaseExceptionGroup__condition1type[_ExceptionT] | tuple[type[_ExceptionT], ...]"ExceptionGroup[_ExceptionT] | Nonec                 C     d S r*   r$   r<   rZ   r$   r$   r%   subgroup      zBaseExceptionGroup.subgroup9type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...]*BaseExceptionGroup[_BaseExceptionT] | Nonec                 C  r]   r*   r$   r^   r$   r$   r%   r_      r`   >Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]-BaseExceptionGroup[_BaseExceptionT_co] | Nonec                 C  r]   r*   r$   r^   r$   r$   r%   r_      s   ztype[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] | Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]c                 C  s   t |}d}|| r| S g }| jD ](}t|tr-||}|d ur&|| ||ur,d}q||r7|| qd}q|s>| S |rGt| |}|S d S )NFT)r4   rY   r/   r   r_   rT   r=   )r<   rZ   r'   modifiedrY   r   r_   groupr$   r$   r%   r_      s,   




Xtuple[ExceptionGroup[_ExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  r]   r*   r$   r^   r$   r$   r%   split      zBaseExceptionGroup.split`tuple[BaseExceptionGroup[_BaseExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  r]   r*   r$   r^   r$   r$   r%   ri      rj   ctuple[BaseExceptionGroup[_BaseExceptionT_co] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  r]   r*   r$   r^   r$   r$   r%   ri      s   r(   !  tuple[ExceptionGroup[_ExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None] | tuple[BaseExceptionGroup[_BaseExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None] | tuple[BaseExceptionGroup[_BaseExceptionT_co] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c           
      C  s   t |}|| r| d fS g }g }| jD ]0}t|tr4||\}}|d ur*|| |d ur3|| q||r>|| q|| qd }|rMt| |}d }	|rVt| |}	||	fS r*   )r4   rY   r/   r   ri   rT   r=   )
r<   rZ   r'   Zmatching_exceptionsZnonmatching_exceptionsr   ZmatchingZnonmatchingZmatching_groupZnonmatching_groupr$   r$   r%   ri      s2   




_BaseExceptionGroup__excsSequence[_ExceptionT]ExceptionGroup[_ExceptionT]c                 C  r]   r*   r$   r<   rn   r$   r$   r%   r6     s   zBaseExceptionGroup.deriveSequence[_BaseExceptionT]#BaseExceptionGroup[_BaseExceptionT]c                 C  r]   r*   r$   rq   r$   r$   r%   r6     r`   c                 C  s   t | j|S r*   )r   rW   rq   r$   r$   r%   r6     s   c                 C  s4   t | jdkr	dnd}| j dt | j d| dS )N    sz (z sub-exceptionrS   )lenrJ   rW   )r<   suffixr$   r$   r%   __str__  s   zBaseExceptionGroup.__str__c                 C  s&   | j j d| jd d| jd dS )N(r   z, rt   rS   )r"   rG   rN   rV   r$   r$   r%   __repr__  s   &zBaseExceptionGroup.__repr__)r#   r>   r?   r@   rA   rB   r   r   )r?   r@   rA   rB   rN   rO   r   rP   )rR   r@   r   rP   )r   r@   )r   rX   )rZ   r[   r   r\   )rZ   ra   r   rb   )rZ   rc   r   rd   )rZ   re   r   rb   )rZ   r[   r   rh   )rZ   ra   r   rk   )rZ   rc   r   rl   )rZ   r(   r   rm   )rn   ro   r   rp   )rn   rr   r   rs   )rG   
__module____qualname____doc__rI   rQ   rU   propertyrW   rY   r   r_   ri   r6   ry   r{   __classcell__r$   r$   rM   r%   r   @   s<    
(

!
2

c                      s   e Zd Zd fd	d
ZerBed ddZed!ddZed"ddZd# fddZed$ddZ	ed%ddZ	d& fddZ	  Z
S   Z
S )'r   r#   type[_ExceptionGroupSelf]_ExceptionGroup__messager@   _ExceptionGroup__exceptionsSequence[_ExceptionT_co]r   r   c                   s   t  | ||S r*   )rH   rI   )r#   r   r   rM   r$   r%   rI     s   zExceptionGroup.__new__;tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...]c                 C  r]   r*   r$   rV   r$   r$   r%   rY   #  r`   zExceptionGroup.exceptions_ExceptionGroup__conditionr[   r\   c                 C  r]   r*   r$   r<   r   r$   r$   r%   r_   (  r`   zExceptionGroup.subgroup6Callable[[_ExceptionT_co | _ExceptionGroupSelf], bool]%ExceptionGroup[_ExceptionT_co] | Nonec                 C  r]   r*   r$   r   r$   r$   r%   r_   -  r`   Ttype[_ExceptionT] | tuple[type[_ExceptionT], ...] | Callable[[_ExceptionT_co], bool]c                      t  |S r*   )rH   r_   r   rM   r$   r%   r_   2  s   Ptuple[ExceptionGroup[_ExceptionT] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  r]   r*   r$   r   r$   r$   r%   ri   :     zExceptionGroup.splitStuple[ExceptionGroup[_ExceptionT_co] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  r]   r*   r$   r   r$   r$   r%   ri   A  r   r<   c                   r   r*   )rH   ri   r   rM   r$   r%   ri   H  s   )r#   r   r   r@   r   r   r   r   )r   r   )r   r[   r   r\   )r   r   r   r   )r   r   r   r\   )r   r[   r   r   )r   r   r   r   )r<   r   r   r   r   r   )rG   r|   r}   rI   r   r   rY   r   r_   ri   r   r$   r$   rM   r%   r     s     )r   r   r   r   r   r    )r'   r(   r   r)   )!
__future__r   syscollections.abcr   r   	functoolsr   inspectr   r   typingr   r	   r
   r   r   r   version_infoZtyping_extensionsr   r   r   rC   r   r   r   r   r&   r4   r=   r   r   r$   r$   r$   r%   <module>   s0     



 Z