o
    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 )NTF)r   	__class__)r   r   cls r!   n/var/www/html/construction_image-detection-poc/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   


r1   c                 C  s<   |  |}| j|_| j|_| j|_t| drt| j|_|S )N	__notes__)derive	__cause____context____traceback__hasattrlistr2   )self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(   rB   __name__super__new___message_exceptions)r    r>   r@   ir   instancer   r!   r"   rH   ;   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   rC   rF   r7   r2   append)r9   rN   r!   r!   r"   add_noted   s   

zBaseExceptionGroup.add_notec                 C  s   | j S r'   )rI   r9   r!   r!   r"   messageo   s   zBaseExceptionGroup.messageGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]c                 C  s
   t | jS r'   )r-   rJ   rS   r!   r!   r"   
exceptionss   s   
zBaseExceptionGroup.exceptions_BaseExceptionGroup__condition1type[_ExceptionT] | tuple[type[_ExceptionT], ...]"ExceptionGroup[_ExceptionT] | Nonec                 C     d S r'   r!   r9   rW   r!   r!   r"   subgroupy      zBaseExceptionGroup.subgroup9type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...]*BaseExceptionGroup[_BaseExceptionT] | Nonec                 C  rZ   r'   r!   r[   r!   r!   r"   r\   ~   r]   >Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]-BaseExceptionGroup[_BaseExceptionT_co] | Nonec                 C  rZ   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)r1   rV   r,   r   r\   rQ   r<   )r9   rW   r$   modifiedrV   r   r\   groupr!   r!   r"   r\      s,   




Xtuple[ExceptionGroup[_ExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  rZ   r'   r!   r[   r!   r!   r"   split      zBaseExceptionGroup.split`tuple[BaseExceptionGroup[_BaseExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  rZ   r'   r!   r[   r!   r!   r"   rf      rg   ctuple[BaseExceptionGroup[_BaseExceptionT_co] | None, BaseExceptionGroup[_BaseExceptionT_co] | None]c                 C  rZ   r'   r!   r[   r!   r!   r"   rf      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   rV   r,   r   rf   rQ   r<   )
r9   rW   r$   matching_exceptionsnonmatching_exceptionsr   matchingnonmatchingmatching_groupnonmatching_groupr!   r!   r"   rf      s2   




_BaseExceptionGroup__excsSequence[_ExceptionT]ExceptionGroup[_ExceptionT]c                 C  rZ   r'   r!   r9   rq   r!   r!   r"   r3      s   zBaseExceptionGroup.deriveSequence[_BaseExceptionT]#BaseExceptionGroup[_BaseExceptionT]c                 C  rZ   r'   r!   rt   r!   r!   r"   r3      r]   c                 C  s   t | j|S r'   )r   rT   rt   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-exceptionrP   )lenrJ   rT   )r9   suffixr!   r!   r"   __str__  s   zBaseExceptionGroup.__str__c                 C  s   | j j d| jd| jdS )N(z, rP   )r   rF   rT   rJ   rS   r!   r!   r"   __repr__  s   zBaseExceptionGroup.__repr__)r    r=   r>   r?   r@   rA   r   r   )rN   r?   r   rO   )r   r?   )r   rU   )rW   rX   r   rY   )rW   r^   r   r_   )rW   r`   r   ra   )rW   rb   r   r_   )rW   rX   r   re   )rW   r^   r   rh   )rW   r`   r   ri   )rW   r%   r   rj   )rq   rr   r   rs   )rq   ru   r   rv   )rF   
__module____qualname____doc__rH   rR   propertyrT   rV   r   r\   rf   r3   r|   r~   __classcell__r!   r!   rM   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'   )rG   rH   )r    r   r   rM   r!   r"   rH     s   zExceptionGroup.__new__;tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...]c                 C  rZ   r'   r!   rS   r!   r!   r"   rV     r]   zExceptionGroup.exceptions_ExceptionGroup__conditionrX   rY   c                 C  rZ   r'   r!   r9   r   r!   r!   r"   r\     r]   zExceptionGroup.subgroup6Callable[[_ExceptionT_co | _ExceptionGroupSelf], bool]%ExceptionGroup[_ExceptionT_co] | Nonec                 C  rZ   r'   r!   r   r!   r!   r"   r\     r]   Ttype[_ExceptionT] | tuple[type[_ExceptionT], ...] | Callable[[_ExceptionT_co], bool]c                      t  |S r'   )rG   r\   r   rM   r!   r"   r\   #  s   Ptuple[ExceptionGroup[_ExceptionT] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  rZ   r'   r!   r   r!   r!   r"   rf   +     zExceptionGroup.splitStuple[ExceptionGroup[_ExceptionT_co] | None, ExceptionGroup[_ExceptionT_co] | None]c                 C  rZ   r'   r!   r   r!   r!   r"   rf   2  r   r9   c                   r   r'   )rG   rf   r   rM   r!   r"   rf   9  s   )r    r   r   r?   r   r   r   r   )r   r   )r   rX   r   rY   )r   r   r   r   )r   r   r   rY   )r   rX   r   r   )r   r   r   r   )r9   r   r   r   r   r   )rF   r   r   rH   r   r   rV   r   r\   rf   r   r!   r!   rM   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   rB   r   r   r   r   r#   r1   r<   r   r   r!   r!   r!   r"   <module>   s"     


 S