o
    "“iø  ã                   @   s¬   d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 G dd„ de
ƒZG dd„ de	ƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ de
ƒZdS )é    )ÚSequence)ÚAnyÚOptionalÚUnion)ÚSelf)ÚExceptionGroupc                       s<   e Zd ZdZdededdf‡ fdd„Zdefdd	„Z‡  ZS )
ÚStructureHandlerNotFoundErrorzk
    Error raised when structuring cannot find a handler for converting inputs into
    :attr:`type_`.
    ÚmessageÚtype_ÚreturnNc                    s   t ƒ  ||¡ || _|| _d S ©N)ÚsuperÚ__init__r	   r
   )Úselfr	   r
   ©Ú	__class__© úM/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/errors.pyr      s   
z&StructureHandlerNotFoundError.__init__c                 C   s   | j S r   )r	   ©r   r   r   r   Ú__str__   s   z%StructureHandlerNotFoundError.__str__)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚtyper   r   Ú__classcell__r   r   r   r   r   	   s    r   c                       sR   e Zd ZU eed< dedee dedef‡ fdd„Z	dee defdd„Z
‡  ZS )	ÚBaseValidationErrorÚclr	   Úexcsr   c                    s   t ƒ  | ||¡}||_|S r   )r   Ú__new__r   )Úclsr	   r   r   Úobjr   r   r   r       s   zBaseValidationError.__new__c                 C   s   |   | j|| j¡S r   )r   r	   r   )r   r   r   r   r   Úderive    ó   zBaseValidationError.derive)r   r   r   r   Ú__annotations__r   r   Ú	Exceptionr   r    r#   r   r   r   r   r   r      s   
 "r   c                   @   sl   e Zd ZU dZeeef ed< eed< dedeeef dede	fdd„Z
deeeeef ef fdd	„Zd
S )ÚIterableValidationNotezNAttached as a note to an exception when an iterable element fails structuring.Úindexr   Ústringr   c                 C   ó   t  | |¡}||_||_|S r   )r   r    r(   r   )r!   r)   r(   r   Úinstancer   r   r   r    *   ó   zIterableValidationNote.__new__c                 C   ó   t | ƒ| j| jfS r   )r   r(   r   r   r   r   r   Ú__getnewargs__0   r$   z%IterableValidationNote.__getnewargs__N)r   r   r   r   r   Úintr   r%   r   r   r    Útupler.   r   r   r   r   r'   $   s   
 "$r'   c                   @   ó6   e Zd ZdZdeeeeef  ee f fdd„ZdS )ÚIterableValidationErrorz$Raised when structuring an iterable.r   c                 C   ód   g }g }| j D ]&}t|dƒr(|jD ]}|jtu r!| ||f¡  nq| |¡ q| |¡ q||fS ©zHSplit the exceptions into two groups: with and without validation notes.Ú	__notes__)Ú
exceptionsÚhasattrr5   r   r'   Úappend©r   Úexcs_with_notesÚ
other_excsÚsubexcÚnoter   r   r   Úgroup_exceptions7   ó   



þ
€z(IterableValidationError.group_exceptionsN)	r   r   r   r   r0   Úlistr&   r'   r>   r   r   r   r   r2   4   ó
    þr2   c                   @   sT   e Zd ZU dZeed< eed< dedededefdd„Zde	eeef fdd	„Z
d
S )ÚAttributeValidationNotezGAttached as a note to an exception when an attribute fails structuring.Únamer   r)   r   c                 C   r*   r   )r   r    rC   r   )r!   r)   rC   r   r+   r   r   r   r    Q   r,   zAttributeValidationNote.__new__c                 C   r-   r   )r   rC   r   r   r   r   r   r.   W   r$   z&AttributeValidationNote.__getnewargs__N)r   r   r   r   r   r%   r   r   r    r0   r.   r   r   r   r   rB   K   s   
 rB   c                   @   r1   )ÚClassValidationErrorz=Raised when validating a class if any attributes are invalid.r   c                 C   r3   r4   )r6   r7   r5   r   rB   r8   r9   r   r   r   r>   ^   r?   z%ClassValidationError.group_exceptionsN)	r   r   r   r   r0   r@   r&   rB   r>   r   r   r   r   rD   [   rA   rD   c                       sH   e Zd ZdZdee dedee ddf‡ fdd„Zdefd	d
„Z	‡  Z
S )ÚForbiddenExtraKeysErrora"  
    Raised when `forbid_extra_keys` is activated and such extra keys are detected
    during structuring.

    The attribute `extra_fields` is a sequence of those extra keys, which were the
    cause of this error, and `cl` is the class which was structured with those extra
    keys.
    r	   r   Úextra_fieldsr   Nc                    s&   || _ || _|| _tƒ  |||¡ d S r   )r	   r   rF   r   r   )r   r	   r   rF   r   r   r   r   |   s   z ForbiddenExtraKeysError.__init__c                 C   s&   | j pd| jj› dd t| jƒ¡› �S )Nz Extra fields in constructor for z: z, )r	   r   r   ÚjoinÚsortedrF   r   r   r   r   r   …   s
   ÿþzForbiddenExtraKeysError.__str__)r   r   r   r   r   r   r   Úsetr   r   r   r   r   r   r   rE   r   s    	ÿÿÿþ	rE   N)Úcollections.abcr   Útypingr   r   r   Útyping_extensionsr   Úcattrs._compatr   r&   r   r   r   r'   r2   rB   rD   rE   r   r   r   r   Ú<module>   s    