a
    xd,&                     @  s   d dl m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rhd dl
mZ ededd	Zed
edZededd	ZededZddddddZdddddZG dd deee ZG dd dee eZdS )    )annotations)CallableSequence)partial)getmroisclass)TYPE_CHECKINGGenericTypeTypeVarcastoverload)Self_BaseExceptionT_coT)bound	covariant_BaseExceptionT)r   _ExceptionT_co_ExceptionTBaseExceptionztuple[type[BaseException]]bool)excparentsreturnc                 C  s*   t | jd d D ]}||v r dS qdS )NTF)r   	__class__)r   r   cls r   R/var/www/html/Ranjet/env/lib/python3.9/site-packages/exceptiongroup/_exceptions.pycheck_direct_subclass   s    r   `type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] | Callable[[_BaseExceptionT_co], bool]$Callable[[_BaseExceptionT_co], bool])	conditionr   c                 C  sr   t | r*tttt | tr*tt| fdS t| trTt	dd | D rftt| dS nt
| rftd| S tdd S )N)r   c                 s  s    | ]}t |ot|tV  qd S N)r   
issubclassr   ).0xr   r   r   	<genexpr>%       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    


r.   c                      s  e Zd ZdZdddd fddZddd	d
dZeddddZeddddZe	dddddZ
e	ddddddZ
ddddddZ
e	dddddd Ze	ddd!dd"d Zddd#dd$d Zdddd%d&d'Zddd(d)Zddd*d+Z  ZS ),BaseExceptionGroupz/A combination of multiple unrelated exceptions.strzSequence[_BaseExceptionT_co]r   )_BaseExceptionGroup__message_BaseExceptionGroup__exceptionsr   c                   s   t |tstdt| t |ts.td|s:tdt|D ]"\}}t |tsBtd| dqB| tu rt	dd |D rt
} t| tr|D ]0}t |ts| t
u rtdqtd	| jqt | ||}||_||_|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'   C   r(   z-BaseExceptionGroup.__new__.<locals>.<genexpr>z/Cannot nest BaseExceptions in an ExceptionGroupzCannot nest BaseExceptions in )r)   r0   r-   typer   
ValueError	enumerater   r/   r+   ExceptionGroupr$   r3   __name__super__new___message_exceptions)r   r1   r2   ir   instancer   r   r   r:   0   s<    






zBaseExceptionGroup.__new__None)noter   c                 C  sF   t |ts&td|dt|j dt| ds6g | _| j| d S )NzExpected a string, got note=z (type )	__notes__)r)   r0   r-   r4   r8   hasattrrC   append)selfrA   r   r   r   add_noteW   s    

zBaseExceptionGroup.add_noter   c                 C  s   | j S r#   )r;   rF   r   r   r   messageb   s    zBaseExceptionGroup.messagezGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]c                 C  s
   t | jS r#   )r*   r<   rI   r   r   r   
exceptionsf   s    zBaseExceptionGroup.exceptionsz9type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...]z*BaseExceptionGroup[_BaseExceptionT] | None)_BaseExceptionGroup__conditionr   c                 C  s   d S r#   r   rF   rL   r   r   r   subgroupl   s    zBaseExceptionGroup.subgroupr!   Self | None)rF   rL   r   c                 C  s   d S r#   r   rM   r   r   r   rN   r   s    r    z1BaseExceptionGroup[_BaseExceptionT] | Self | Nonec                 C  s   t |}d}|| r| S g }| jD ]P}t|trZ||}|d urL|| ||urrd}q"||rn|| q"d}q"|s|| S |r| |}| j|_| j|_| j	|_	|S d S d S )NFT)
r.   rK   r)   r/   rN   rE   derive	__cause____context____traceback__)rF   rL   r"   modifiedrK   r   rN   groupr   r   r   rN   x   s0    




z>tuple[BaseExceptionGroup[_BaseExceptionT] | None, Self | None]c                 C  s   d S r#   r   rM   r   r   r   split   s    zBaseExceptionGroup.splittuple[Self | None, Self | None]c                 C  s   d S r#   r   rM   r   r   r   rV      s    z`tuple[BaseExceptionGroup[_BaseExceptionT] | None, Self | None] | tuple[Self | None, Self | None]c           
      C  s   t |}|| r| d fS g }g }| jD ]`}t|trh||\}}|d urT|| |d ur|| q&||r||| q&|| q&d }|r| |}| j|_| j|_| j	|_	d }	|r| |}	| j|	_| j|	_| j	|	_	||	fS r#   )
r.   rK   r)   r/   rV   rE   rP   rQ   rR   rS   )
rF   rL   r"   Zmatching_exceptionsZnonmatching_exceptionsr   ZmatchingZnonmatchingZmatching_groupZnonmatching_groupr   r   r   rV      s8    	




)rF   _BaseExceptionGroup__excsr   c                 C  s&   t | j|}t| dr"t| j|_|S )NrC   )r/   rJ   rD   listrC   )rF   rX   Zegr   r   r   rP      s    
zBaseExceptionGroup.derivec                 C  s4   t | jdkrdnd}| j dt | j d| dS )N    sz (z sub-exceptionrB   )lenr<   rJ   )rF   suffixr   r   r   __str__   s    zBaseExceptionGroup.__str__c                 C  s   | j j d| jd| jdS )N(z, rB   )r   r8   rJ   r<   rI   r   r   r   __repr__   s    zBaseExceptionGroup.__repr__)r8   
__module____qualname____doc__r:   rG   propertyrJ   rK   r   rN   rV   rP   r_   ra   __classcell__r   r   r?   r   r/   -   s(   '$,r/   c                      s   e Zd Zdddd fddZereddd	d
ZedddddZeddddddZdddd fddZeddddddZ	eddddddZ	dddd fddZ	  Z
S )r7   r0   zSequence[_ExceptionT_co]r   )_ExceptionGroup__message_ExceptionGroup__exceptionsr   c                   s   t  | ||S r#   )r9   r:   )r   rg   rh   r?   r   r   r:      s    zExceptionGroup.__new__z;tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...]rH   c                 C  s   d S r#   r   rI   r   r   r   rK      s    zExceptionGroup.exceptionsz1type[_ExceptionT] | tuple[type[_ExceptionT], ...]z"ExceptionGroup[_ExceptionT] | None)_ExceptionGroup__conditionr   c                 C  s   d S r#   r   rF   ri   r   r   r   rN      s    zExceptionGroup.subgroupz Callable[[_ExceptionT_co], bool]rO   )rF   ri   r   c                 C  s   d S r#   r   rj   r   r   r   rN      s    zTtype[_ExceptionT] | tuple[type[_ExceptionT], ...] | Callable[[_ExceptionT_co], bool]z)ExceptionGroup[_ExceptionT] | Self | Nonec                   s   t  |S r#   )r9   rN   rj   r?   r   r   rN      s    z6tuple[ExceptionGroup[_ExceptionT] | None, Self | None]c                 C  s   d S r#   r   rj   r   r   r   rV     s    zExceptionGroup.splitrW   c                 C  s   d S r#   r   rj   r   r   r   rV     s    zXtuple[ExceptionGroup[_ExceptionT] | None, Self | None] | tuple[Self | None, Self | None]c                   s   t  |S r#   )r9   rV   rj   r?   r   r   rV     s    	)r8   rb   rc   r:   r   re   rK   r   rN   rV   rf   r   r   r?   r   r7      s   r7   N)
__future__r   collections.abcr   r   	functoolsr   inspectr   r   typingr   r	   r
   r   r   r   r   r   r   r   r3   r   r   r   r.   r/   r7   r   r   r   r   <module>   s    
 9