o
    !=jÇ,  ã                   @  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 )NéÿÿÿÿTF)r   Ú	__class__)r   r   Úcls© r$   údC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\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.messageúGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]c                 C  s
   t | jƒS r*   )r0   rJ   rV   r$   r$   r%   Ú
exceptions‚   s   
zBaseExceptionGroup.exceptionsÚ_BaseExceptionGroup__conditionú1type[_ExceptionT] | tuple[type[_ExceptionT], ...]ú"ExceptionGroup[_ExceptionT] | Nonec                 C  ó   d S r*   r$   ©r<   rZ   r$   r$   r%   Úsubgroupˆ   ó   zBaseExceptionGroup.subgroupú9type[_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.subgroupú6Callable[[_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.splitúStuple[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