o
    MK&h,                     @  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/var/www/html/venv/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   )selfexcs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/   rB   r3   typer   
ValueError	enumerater   r   r1   r   r+   rE   __name__super__new__r0   _exceptions)r#   rA   rC   ir   instancer"   r$   r%   rK   C   s>   








zBaseExceptionGroup.__new__argsobjectNonec                 G  s   t j| ||g|R   d S r*   )r   __init__)r<   rA   rC   rP   r$   r$   r%   rS   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/   rB   r3   rF   rI   r:   r5   append)r<   rT   r$   r$   r%   add_notes   s   

zBaseExceptionGroup.add_notec                 C  s
   | j d S )Nr   )rP   r<   r$   r$   r%   message~   s   
zBaseExceptionGroup.messageGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]c                 C  s
   t | jS r*   )r0   rL   rX   r$   r$   r%   
exceptions   s   
zBaseExceptionGroup.exceptions_BaseExceptionGroup__condition1type[_ExceptionT] | tuple[type[_ExceptionT], ...]"ExceptionGroup[_ExceptionT] | Nonec                 C     d S r*   r$   r<   r\   r$   r$   r%   subgroup      zBaseExceptionGroup.subgroup9type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...]*BaseExceptionGroup[_BaseExceptionT] | Nonec                 C  r_   r*   r$   r`   r$   r$   r%   ra      rb   >Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]-BaseExceptionGroup[_BaseExceptionT_co] | Nonec                 C  r_   r*   r$   r`   r$   r$   r%   ra      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   r[   r/   r   ra   rV   r?   )r<   r\   r'   modifiedr[   r   ra   groupr$   r$   r%   ra      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%   rk      rl   ctuple[BaseExceptionGroup[_BaseExceptionT_co] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  r_   r*   r$   r`   r$   r$   r%   rk      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   r[   r/   r   rk   rV   r?   )
r<   r\   r'   matching_exceptionsnonmatching_exceptionsr   matchingnonmatchingmatching_groupnonmatching_groupr$   r$   r%   rk      s2   




_BaseExceptionGroup__excsSequence[_ExceptionT]ExceptionGroup[_ExceptionT]c                 C  r_   r*   r$   r<   rv   r$   r$   r%   r6     s   zBaseExceptionGroup.deriveSequence[_BaseExceptionT]#BaseExceptionGroup[_BaseExceptionT]c                 C  r_   r*   r$   ry   r$   r$   r%   r6     rb   c                 C  s   t | j|S r*   )r   rY   ry   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-exceptionrU   )lenrL   rY   )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, r|   rU   )r"   rI   rP   rX   r$   r$   r%   __repr__  s   &zBaseExceptionGroup.__repr__)r#   r@   rA   rB   rC   rD   r   r   )rA   rB   rC   rD   rP   rQ   r   rR   )rT   rB   r   rR   )r   rB   )r   rZ   )r\   r]   r   r^   )r\   rc   r   rd   )r\   re   r   rf   )r\   rg   r   rd   )r\   r]   r   rj   )r\   rc   r   rm   )r\   re   r   rn   )r\   r(   r   ro   )rv   rw   r   rx   )rv   rz   r   r{   )rI   
__module____qualname____doc__rK   rS   rW   propertyrY   r[   r   ra   rk   r6   r   r   __classcell__r$   r$   rO   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__messagerB   _ExceptionGroup__exceptionsSequence[_ExceptionT_co]r   r   c                   s   t  | ||S r*   )rJ   rK   )r#   r   r   rO   r$   r%   rK     s   zExceptionGroup.__new__;tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...]c                 C  r_   r*   r$   rX   r$   r$   r%   r[   #  rb   zExceptionGroup.exceptions_ExceptionGroup__conditionr]   r^   c                 C  r_   r*   r$   r<   r   r$   r$   r%   ra   (  rb   zExceptionGroup.subgroup6Callable[[_ExceptionT_co | _ExceptionGroupSelf], bool]%ExceptionGroup[_ExceptionT_co] | Nonec                 C  r_   r*   r$   r   r$   r$   r%   ra   -  rb   Ttype[_ExceptionT] | tuple[type[_ExceptionT], ...] | Callable[[_ExceptionT_co], bool]c                      t  |S r*   )rJ   ra   r   rO   r$   r%   ra   2  s   Ptuple[ExceptionGroup[_ExceptionT] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  r_   r*   r$   r   r$   r$   r%   rk   :     zExceptionGroup.splitStuple[ExceptionGroup[_ExceptionT_co] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  r_   r*   r$   r   r$   r$   r%   rk   A  r   r<   c                   r   r*   )rJ   rk   r   rO   r$   r%   rk   H  s   )r#   r   r   rB   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   )rI   r   r   rK   r   r   r[   r   ra   rk   r   r$   r$   rO   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_infotyping_extensionsr   r   r   rE   r   r   r   r   r&   r4   r?   r   r   r$   r$   r$   r%   <module>   s0     



 Z