
    /~h+                    >   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      Z ed	e
      Z eded      Z ede
      Z edd
      Z edd
      Z	 	 	 	 	 	 ddZ	 	 	 	 ddZd Z G d deee         Z G d dee   e      Zy)    )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BaseExceptionGroupc                J    t        | j                        d d D ]  }||v s y y)NTF)r   	__class__)excparentsclss      c/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/exceptiongroup/_exceptions.pycheck_direct_subclassr       s2     cmm$Sb) '>     c                0   t        |       r7t        t        t        t           |       t              rt        t        | f      S t        | t              r#t        d | D              r(t        t        |       S t        |       rt        d|       S t        d      )N)r   c              3  V   K   | ]!  }t        |      xr t        |t               # y wN)r   
issubclassBaseException).0xs     r   	<genexpr>z'get_condition_filter.<locals>.<genexpr>%   s#     Nqwqz:jM::Ns   ')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)	conditions    r   get_condition_filterr0      s~    
 yjT- ),m ,ylCC	Iu	%NINN0)DD	)	5yAA
U
VVr!   c                    | j                  |      }| j                  |_        | j                  |_        | j                  |_        t	        | d      rt        | j                        |_        |S )N	__notes__)derive	__cause____context____traceback__hasattrlistr2   )selfexcsegs      r   _derive_and_copy_attributesr<   -   sU    	T	B>>BL%%BN))Bt[!DNN+Ir!   c                  l    e Zd ZdZ	 	 	 	 	 	 	 	 d fdZddZedd       Ze	 	 dd       Ze		 	 	 	 dd       Z
e		 	 	 	 dd       Z
e		 	 	 	 dd       Z
	 	 	 	 dd	Z
e		 	 	 	 dd
       Ze		 	 	 	 dd       Ze		 	 	 	 dd       Z	 	 	 	 ddZe	dd       Ze		 	 	 	 d d       Z	 	 	 	 d dZddZddZ xZS )!r   z/A combination of multiple unrelated exceptions.c                ,   t        |t              st        dt        |             t        |t              st        d      |st        d      t        |      D ]$  \  }}t        |t              rt        d| d       | t        u rt        d |D              rt        } t        | t              rB|D ]=  }t        |t              r| t        u rt        d      t        d| j                         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              3  <   K   | ]  }t        |t                y wr$   )r*   	Exception)r'   r   s     r   r)   z-BaseExceptionGroup.__new__.<locals>.<genexpr>P   s     F#:c9-Fs   z/Cannot nest BaseExceptions in an ExceptionGroupzCannot nest BaseExceptions in )r*   strr.   typer   
ValueError	enumerater&   r   r,   r   r%   r@   __name__super__new___message_exceptions)r   _BaseExceptionGroup__message_BaseExceptionGroup__exceptionsir   instancer   s         r   rG   zBaseExceptionGroup.__new__;   s.   
 )S):4	?:KLMM,1MNNK   - 	FAsc=1 A3RS 	 $$FFF$c9%# 	!#y1n,'M  (<S\\<LM 	 7?3	<@%+r!   c                    t        |t              s%t        d|dt        |      j                   d      t        | d      sg | _        | j                  j                  |       y )NzExpected a string, got note=z (type )r2   )r*   rA   r.   rB   rE   r7   r2   append)r9   notes     r   add_notezBaseExceptionGroup.add_noted   s\    $$.thgd4j>Q>Q=RRST  t[)(*DNd#r!   c                    | j                   S r$   )rH   r9   s    r   messagezBaseExceptionGroup.messageo   s    }}r!   c                ,    t        | j                        S r$   )r+   rI   rT   s    r   
exceptionszBaseExceptionGroup.exceptionss   s     T%%&&r!   c                     y r$    r9   _BaseExceptionGroup__conditions     r   subgroupzBaseExceptionGroup.subgroupy   s     .1r!   c                     y r$   rY   rZ   s     r   r\   zBaseExceptionGroup.subgroup~   s     69r!   c                     y r$   rY   rZ   s     r   r\   zBaseExceptionGroup.subgroup   s     9<r!   c                0   t        |      }d} ||       r| S g }| j                  D ]Z  }t        |t              r,|j	                  |      }||j                  |       ||us<d}? ||      r|j                  |       Yd}\ |s| S |rt        | |      }|S y )NFT)r0   rW   r*   r   r\   rP   r<   )r9   r[   r/   modifiedrW   r   r\   groups           r   r\   zBaseExceptionGroup.subgroup   s     )5	T?K*,
?? 	 C#12<<4'%%h/3&#H3!!#&	  K/jAELr!   c                     y r$   rY   rZ   s     r   splitzBaseExceptionGroup.split        r!   c                     y r$   rY   rZ   s     r   rc   zBaseExceptionGroup.split   rd   r!   c                     y r$   rY   rZ   s     r   rc   zBaseExceptionGroup.split   s     r!   c                   t        |      } ||       r| d fS g }g }| j                  D ]y  }t        |t              r<|j	                  |      \  }}||j                  |       |=|j                  |       O ||      r|j                  |       i|j                  |       { d }|rt        | |      }d }	|rt        | |      }	||	fS r$   )r0   rW   r*   r   rc   rP   r<   )
r9   r[   r/   matching_exceptionsnonmatching_exceptionsr   matchingnonmatchingmatching_groupnonmatching_groups
             r   rc   zBaseExceptionGroup.split   s    & )5	T?:3568?? 	3C#12(+		)(<%+''..x8**11+>3#**3/&--c2	3 :>8?RSN<@! ;,! 000r!   c                     y r$   rY   r9   _BaseExceptionGroup__excss     r   r3   zBaseExceptionGroup.derive   s    TWr!   c                     y r$   rY   ro   s     r   r3   zBaseExceptionGroup.derive   s     /2r!   c                .    t        | j                  |      S r$   )r   rU   ro   s     r   r3   zBaseExceptionGroup.derive   s     "$,,77r!   c                    t        | j                        dk(  rdnd}| j                   dt        | j                         d| dS )N    sz (z sub-exceptionrO   )lenrI   rU   )r9   suffixs     r   __str__zBaseExceptionGroup.__str__  sD    4++,1s,,r#d&6&6"7!8vhaPPr!   c                h    | j                   j                   d| j                  d| j                  dS )N(z, rO   )r   rE   rU   rI   rT   s    r   __repr__zBaseExceptionGroup.__repr__  s3    ..))*!DLL+;2d>N>N=QQRSSr!   )r   ztype[_BaseExceptionGroupSelf]rJ   rA   rK   zSequence[_BaseExceptionT_co]returnr   )rQ   rA   r}   None)r}   rA   )r}   zGtuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...])r[   1type[_ExceptionT] | tuple[type[_ExceptionT], ...]r}   "ExceptionGroup[_ExceptionT] | None)r[   9type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...]r}   *BaseExceptionGroup[_BaseExceptionT] | None)r[   >Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]r}   z-BaseExceptionGroup[_BaseExceptionT_co] | None)r[   zztype[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] | Callable[[_BaseExceptionT_co | _BaseExceptionGroupSelf], bool]r}   r   )r[   r   r}   zXtuple[ExceptionGroup[_ExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None])r[   r   r}   z`tuple[BaseExceptionGroup[_BaseExceptionT] | None, BaseExceptionGroup[_BaseExceptionT_co] | None])r[   r   r}   zctuple[BaseExceptionGroup[_BaseExceptionT_co] | None, BaseExceptionGroup[_BaseExceptionT_co] | None])r[   `type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] | Callable[[_BaseExceptionT_co], bool]r}   a!  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])rp   zSequence[_ExceptionT]r}   zExceptionGroup[_ExceptionT])rp   zSequence[_BaseExceptionT]r}   z#BaseExceptionGroup[_BaseExceptionT])rE   
__module____qualname____doc__rG   rR   propertyrU   rW   r   r\   rc   r3   ry   r|   __classcell__r   s   @r   r   r   8   s   9'*'' 3' 
!	'R	$   '	P' '
 1L1	+1 1 9T9	39 9 <S< 
7< <
I
 
4B L
  T
  S
 01/01	
01d W W2/2	,2 28/8	,8
QTr!   c                       e Zd Z	 	 	 	 	 	 	 	 d	 fdZerYe	 	 d
d       Ze	 	 	 	 dd       Ze	 	 	 	 dd       Z	 	 	 	 d fdZe	 	 	 	 dd       Z	e	 	 	 	 dd       Z		 	 	 	 	 	 d fdZ	 xZ
S  xZ
S )r   c                &    t         |   | ||      S r$   )rF   rG   )r   _ExceptionGroup__message_ExceptionGroup__exceptionsr   s      r   rG   zExceptionGroup.__new__  s    
 wsI|<<r!   c                     y r$   rY   rT   s    r   rW   zExceptionGroup.exceptions  s	     KNr!   c                     y r$   rY   r9   _ExceptionGroup__conditions     r   r\   zExceptionGroup.subgroup  s     25r!   c                     y r$   rY   r   s     r   r\   zExceptionGroup.subgroup  s     58r!   c                "    t         |   |      S r$   )rF   r\   r9   r   r   s     r   r\   zExceptionGroup.subgroup#  s     7#K00r!   c                     y r$   rY   r   s     r   rc   zExceptionGroup.split+      
 r!   c                     y r$   rY   r   s     r   rc   zExceptionGroup.split2  r   r!   c                "    t         |   |      S r$   )rF   rc   r   s     r   rc   zExceptionGroup.split9  s     7=--r!   )r   ztype[_ExceptionGroupSelf]r   rA   r   zSequence[_ExceptionT_co]r}   r   )r}   z;tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...])r   r   r}   r   )r   6Callable[[_ExceptionT_co | _ExceptionGroupSelf], bool]r}   z%ExceptionGroup[_ExceptionT_co] | None)r   Ttype[_ExceptionT] | tuple[type[_ExceptionT], ...] | Callable[[_ExceptionT_co], bool]r}   r   )r   r   r}   zPtuple[ExceptionGroup[_ExceptionT] | None, ExceptionGroup[_ExceptionT_co] | None])r   r   r}   Stuple[ExceptionGroup[_ExceptionT_co] | None, ExceptionGroup[_ExceptionT_co] | None])r9   r   r   r   r}   r   )rE   r   r   rG   r	   r   rW   r   r\   rc   r   r   s   @r   r   r   
  s'   =&== /= 
	= 		NH	N 
	N 
	5P	5/	5 
	5 
	8U	82	8 
	8	1/	1
 0	1 
	P	
	 
	 
	U	
	 
		.%	./	.

	. 	.O r!   N)r   r&   r   ztuple[type[BaseException]]r}   bool)r/   r   r}   z$Callable[[_BaseExceptionT_co], bool])
__future__r   collections.abcr   r   	functoolsr   inspectr   r   typingr	   r
   r   r   r   r   r&   r   r   r@   r   r   r   r   r    r0   r<   r   r   rY   r!   r   <module>r      s    " .  # H H1RVW +=A)dKm953;KL !";CWX 	!;	W+W *	W$OT0B(C OTd7.'7 7.r!   