o
    "i                     @   s   d Z ddlmZmZ ddlmZmZmZ ddgZde	dee
d	f d
efddZdefdeeee	f dedee	ee
d	f gef d
ee fddZd	S )zCattrs validation.    )CallableUnion   )ClassValidationErrorForbiddenExtraKeysErrorIterableValidationErrorformat_exceptiontransform_errorexctypeNreturnc                 C   s  t | tr	d}|S t | tr)|dur%t|dr|jnt|}d| }|S d}|S t | trY|du rF| jd dr>d}|S d	|  d
}|S t|drN|jnt|}d| }|S t | t	rjdd
| j d
}|S t | tr{| jd dr{d}|S d|  d
}|S )a  The default exception formatter, handling the most common exceptions.

    The following exceptions are handled specially:

    * `KeyErrors` (`required field missing`)
    * `ValueErrors` (`invalid value for type, expected <type>` or just `invalid value`)
    * `TypeErrors` (`invalid value for type, expected <type>` and a couple special
      cases for iterables)
    * `cattrs.ForbiddenExtraKeysError`
    * some `AttributeErrors` (special cased for structing mappings)
    zrequired field missingN__name__z!invalid value for type, expected zinvalid valuer   zobject is not iterablez,invalid value for type, expected an iterablezinvalid type ()zextra fields found (z, zobject has no attribute 'items'zexpected a mappingzunknown error ()
isinstanceKeyError
ValueErrorhasattrr   repr	TypeErrorargsendswithr   joinextra_fieldsAttributeError)r
   r   restn r   H/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/v.pyr      s<   





	$pathc                 C   sX  g }t | trP|  \}}|D ],\} }| d|jd}t | ttfr-|t| || q||| |j d|  q|D ]} ||| d d|  q>|S t | tr|  \}}|D ]+\} }| d|j	 }t | ttfrz|t| || q]||| |j d|  q]|D ]} ||| d d|  q|S ||| d d|  |S )a  Transform an exception into a list of error messages.

    To get detailed error messages, the exception should be produced by a converter
    with `detailed_validation` set.

    By default, the error messages are in the form of `{description} @ {path}`.

    While traversing the exception and subexceptions, the path is formed:

    * by appending `.{field_name}` for fields in classes
    * by appending `[{int}]` for indices in iterables, like lists
    * by appending `[{str}]` for keys in mappings, like dictionaries

    :param exc: The exception to transform into error messages.
    :param path: The root path to use.
    :param format_exception: A callable to use to transform `Exceptions` into
        string descriptions of errors.

    .. versionadded:: 23.1.0
    []z @ N.)
r   r   group_exceptionsindexr   extendr	   appendr   name)r
   r   r   errors
with_noteswithoutnotepr   r   r   r	   8   s.   

)__doc__typingr   r   r(   r   r   r   __all__BaseExceptionr   strr   listr	   r   r   r   r   <module>   s$    ,