o
    0'hˆ+  ã                   @  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dedd�Zed	ed
�Zeded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 )%é    )Úannotations)ÚCallableÚSequence)Úpartial)ÚgetmroÚisclass)ÚTYPE_CHECKINGÚGenericÚTypeÚTypeVarÚcastÚoverloadÚ_BaseExceptionT_coT)ÚboundÚ	covariantÚ_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!   úPC:\Users\shubh\Videos\agent\nova\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   
ÿ
ý
r1   c                 C  s<   |   |¡}| j|_| j|_| j|_t| dƒrt| jƒ|_|S )NÚ	__notes__)ÚderiveÚ	__cause__Ú__context__Ú__traceback__ÚhasattrÚlistr2   )ÚselfZexcsÚegr!   r!   r"   Ú_derive_and_copy_attributes-   s   

r;   c                      sê   e Zd ZdZd9‡ fd
d„Zd:dd„Zed;dd„ƒZed<dd„ƒZe	d=dd„ƒZ
e	d>dd„ƒZ
e	d?dd„ƒZ
d@d!d„Z
e	dAd#d$„ƒZe	dBd&d$„ƒZe	dCd(d$„ƒZdDd+d$„Ze	dEd/d0„ƒZe	dFd3d0„ƒZdFd4d0„Zd;d5d6„Zd;d7d8„Z‡  ZS )Gr   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ƒ  | ||¡}||_||_|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+   P   s   € z-BaseExceptionGroup.__new__.<locals>.<genexpr>z/Cannot nest BaseExceptions in an ExceptionGroupzCannot nest BaseExceptions in )r,   r>   r0   Útyper   Ú
ValueErrorÚ	enumerater   r   r.   r   r(   rA   Ú__name__ÚsuperÚ__new__Ú_messageÚ_exceptions)r    r=   r?   Úir   Úinstance©r   r!   r"   rG   ;   s@   

ÿ

ÿÿ

ÿ
ÿú
zBaseExceptionGroup.__new__ÚnoteÚNonec                 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 ú)r2   )r,   r>   r0   rB   rE   r7   r2   Úappend)r9   rM   r!   r!   r"   Úadd_noted   s   
ÿ
zBaseExceptionGroup.add_notec                 C  s   | j S r'   )rH   ©r9   r!   r!   r"   Úmessageo   s   zBaseExceptionGroup.messageúGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]c                 C  s
   t | jƒS r'   )r-   rI   rR   r!   r!   r"   Ú
exceptionss   s   
zBaseExceptionGroup.exceptionsÚ_BaseExceptionGroup__conditionú1type[_ExceptionT] | tuple[type[_ExceptionT], ...]ú"ExceptionGroup[_ExceptionT] | Nonec                 C  ó   d S r'   r!   ©r9   rV   r!   r!   r"   Úsubgroupy   ó   zBaseExceptionGroup.subgroupú9type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...]ú*BaseExceptionGroup[_BaseExceptionT] | Nonec                 C  rY   r'   r!   rZ   r!   r!   r"   r[   ~   r\   ú>Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]ú-BaseExceptionGroup[_BaseExceptionT_co] | Nonec                 C  rY   r'   r!   rZ   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)r1   rU   r,   r   r[   rP   r;   )r9   rV   r$   ÚmodifiedrU   r   r[   Úgroupr!   r!   r"   r[   ‰   s,   



€
úXtuple[ExceptionGroup[_ExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  rY   r'   r!   rZ   r!   r!   r"   Úsplitª   ó   zBaseExceptionGroup.splitú`tuple[BaseExceptionGroup[_BaseExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  rY   r'   r!   rZ   r!   r!   r"   re   ²   rf   úctuple[BaseExceptionGroup[_BaseExceptionT_co] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  rY   r'   r!   rZ   r!   r!   r"   re   º   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'   )r1   rU   r,   r   re   rP   r;   )
r9   rV   r$   Zmatching_exceptionsZnonmatching_exceptionsr   ZmatchingZnonmatchingZmatching_groupZnonmatching_groupr!   r!   r"   re   Ã   s2   



€
ÿÚ_BaseExceptionGroup__excsúSequence[_ExceptionT]úExceptionGroup[_ExceptionT]c                 C  rY   r'   r!   ©r9   rj   r!   r!   r"   r3   õ   s   zBaseExceptionGroup.deriveúSequence[_BaseExceptionT]ú#BaseExceptionGroup[_BaseExceptionT]c                 C  rY   r'   r!   rm   r!   r!   r"   r3   ø   r\   c                 C  s   t | j|ƒS r'   )r   rS   rm   r!   r!   r"   r3   ý   s   c                 C  s4   t | jƒdkr	dnd}| j› dt | jƒ› d|› d�S )Né   Ú Úsz (z sub-exceptionrO   )ÚlenrI   rS   )r9   Úsuffixr!   r!   r"   Ú__str__  s   zBaseExceptionGroup.__str__c                 C  s   | j j› d| j›d| j›d�S )Nú(z, rO   )r   rE   rS   rI   rR   r!   r!   r"   Ú__repr__  s   zBaseExceptionGroup.__repr__)r    r<   r=   r>   r?   r@   r   r   )rM   r>   r   rN   )r   r>   )r   rT   )rV   rW   r   rX   )rV   r]   r   r^   )rV   r_   r   r`   )rV   ra   r   r^   )rV   rW   r   rd   )rV   r]   r   rg   )rV   r_   r   rh   )rV   r%   r   ri   )rj   rk   r   rl   )rj   rn   r   ro   )rE   Ú
__module__Ú__qualname__Ú__doc__rG   rQ   ÚpropertyrS   rU   r   r[   re   r3   ru   rw   Ú__classcell__r!   r!   rL   r"   r   8   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'   )rF   rG   )r    r~   r   rL   r!   r"   rG     s   zExceptionGroup.__new__ú;tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...]c                 C  rY   r'   r!   rR   r!   r!   r"   rU     r\   zExceptionGroup.exceptionsÚ_ExceptionGroup__conditionrW   rX   c                 C  rY   r'   r!   ©r9   r‚   r!   r!   r"   r[     r\   zExceptionGroup.subgroupú6Callable[[_ExceptionT_co | _ExceptionGroupSelf], bool]ú%ExceptionGroup[_ExceptionT_co] | Nonec                 C  rY   r'   r!   rƒ   r!   r!   r"   r[     r\   úTtype[_ExceptionT] | tuple[type[_ExceptionT], ...] | Callable[[_ExceptionT_co], bool]c                   ó   t ƒ  |¡S r'   )rF   r[   rƒ   rL   r!   r"   r[   #  s   úPtuple[ExceptionGroup[_ExceptionT] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  rY   r'   r!   rƒ   r!   r!   r"   re   +  ó   zExceptionGroup.splitúStuple[ExceptionGroup[_ExceptionT_co] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  rY   r'   r!   rƒ   r!   r!   r"   re   2  r‰   r9   c                   r‡   r'   )rF   re   rƒ   rL   r!   r"   re   9  s   )r    r}   r~   r>   r   r€   r   r   )r   r�   )r‚   rW   r   rX   )r‚   r„   r   r…   )r‚   r†   r   rX   )r‚   rW   r   rˆ   )r‚   r„   r   rŠ   )r9   r   r‚   r†   r   rŠ   )rE   rx   ry   rG   r   r{   rU   r   r[   re   r|   r!   r!   rL   r"   r   
  s     ÙN)r   r   r   r   r   r   )r$   r%   r   r&   )Ú
__future__r   Úcollections.abcr   r   Ú	functoolsr   Úinspectr   r   Útypingr   r	   r
   r   r   r   r   r   r   rA   r   r   r   r   r#   r1   r;   r   r   r!   r!   r!   r"   Ú<module>   s"     


 S