U
    ={fb(                     @  s<  U d Z ddlmZ ddlmZmZ ddlmZ ddl	m
Z
mZmZmZmZmZ ddlmZ ddlmZmZmZmZ dd	lmZmZ dd
lmZ ddlmZ dZe
r~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#eeee e!e"ej$ej%ej&ej'f	 Z(ee#ej)f Z*ee+eeef e,eef ee f Z-de.d< ede(e-Z/edej)e#e-Z0neZ1edddd d d dd d!d"d"d#d#d#d$d#d%d&d'd(Z2ed)d*d+d#d,d-d.d/Z3ed)d*d+d#d,d0d1d/Z3ed)d*d2d+d#d,d3d4d/Z3ed5ddd d d d6d#d#d#d7d3d8d/Z3dS )9zCOld `@validator` and `@root_validator` function validators from V1.    )annotations)partialpartialmethod)FunctionType)TYPE_CHECKINGAnyCallableTypeVarUnionoverload)warn)LiteralProtocol	TypeAlias
deprecated   )_decorators_decorators_v1)PydanticUserError)PydanticDeprecatedSince20zQ`allow_reuse` is deprecated and will be ignored; it should no longer be necessaryc                   @  s   e Zd ZddddddZdS )_OnlyValueValidatorClsMethodr   )!_OnlyValueValidatorClsMethod__cls#_OnlyValueValidatorClsMethod__valuereturnc                 C  s   d S N )selfr   r   r   r   c/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/pydantic/deprecated/class_validators.py__call__   s    z%_OnlyValueValidatorClsMethod.__call__N__name__
__module____qualname__r   r   r   r   r   r      s   r   c                   @  s    e Zd ZdddddddZdS )_V1ValidatorWithValuesClsMethodr   dict[str, Any])$_V1ValidatorWithValuesClsMethod__cls&_V1ValidatorWithValuesClsMethod__valuevaluesr   c                 C  s   d S r   r   )r   r%   r&   r'   r   r   r   r      s    z(_V1ValidatorWithValuesClsMethod.__call__Nr   r   r   r   r   r#      s   r#   c                   @  s    e Zd ZdddddddZdS )%_V1ValidatorWithValuesKwOnlyClsMethodr   r$   )*_V1ValidatorWithValuesKwOnlyClsMethod__cls,_V1ValidatorWithValuesKwOnlyClsMethod__valuer'   r   c                C  s   d S r   r   )r   r)   r*   r'   r   r   r   r      s    z._V1ValidatorWithValuesKwOnlyClsMethod.__call__Nr   r   r   r   r   r(      s   r(   c                   @  s   e Zd ZddddddZdS )_V1ValidatorWithKwargsClsMethodr   )$_V1ValidatorWithKwargsClsMethod__clskwargsr   c                 K  s   d S r   r   )r   r,   r-   r   r   r   r   "   s    z(_V1ValidatorWithKwargsClsMethod.__call__Nr   r   r   r   r   r+   !   s   r+   c                   @  s    e Zd ZdddddddZdS )(_V1ValidatorWithValuesAndKwargsClsMethodr   r$   )-_V1ValidatorWithValuesAndKwargsClsMethod__clsr'   r-   r   c                 K  s   d S r   r   )r   r/   r'   r-   r   r   r   r   &   s    z1_V1ValidatorWithValuesAndKwargsClsMethod.__call__Nr   r   r   r   r   r.   %   s   r.   c                   @  s   e Zd ZddddddZdS )_V1RootValidatorClsMethodr   z"_decorators_v1.RootValidatorValues)_V1RootValidatorClsMethod__cls!_V1RootValidatorClsMethod__valuesr   c                 C  s   d S r   r   )r   r1   r2   r   r   r   r   *   s    z"_V1RootValidatorClsMethod.__call__Nr   r   r   r   r   r0   )   s   r0   r   _PartialClsOrStaticMethod_V1ValidatorType_V1RootValidatorFunctionTypePydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more detailsN)categoryF)pre	each_itemalwayscheck_fieldsallow_reusestrboolzbool | Nonez.Callable[[_V1ValidatorType], _V1ValidatorType])__fieldfieldsr8   r9   r:   r;   r<   r   c                  s   t dtdd |dkr t tt t| ftd trJtdddntd	d
 D shtddd|dkrtdndddd fdd}|S )a  Decorate methods on the class indicating that they should be used to validate fields.

    Args:
        __field (str): The first field the validator should be called on; this is separate
            from `fields` to ensure an error is raised if you don't pass at least one.
        *fields (str): Additional field(s) the validator should be called on.
        pre (bool, optional): Whether this validator should be called before the standard
            validators (else after). Defaults to False.
        each_item (bool, optional): For complex objects (sets, lists etc.) whether to validate
            individual elements rather than the whole object. Defaults to False.
        always (bool, optional): Whether this method and other validators should be called even if
            the value is missing. Defaults to False.
        check_fields (bool | None, optional): Whether to check that the fields actually exist on the model.
            Defaults to None.
        allow_reuse (bool, optional): Whether to track and raise an error if another validator refers to
            the decorated function. Defaults to False.

    Returns:
        Callable: A decorator that can be used to decorate a
            function to be used as a validator.
    r6   r   
stacklevelTr   z`@validator` should be used with fields and keyword arguments, not bare. E.g. usage should be `@validator('<field_name>', ...)`zvalidator-no-fieldscodec                 s  s   | ]}t |tV  qd S r   )
isinstancer=   ).0fieldr   r   r   	<genexpr>   s     zvalidator.<locals>.<genexpr>z`@validator` fields should be passed as separate string args. E.g. usage should be `@validator('<field_name_1>', '<field_name_2>', ...)`zvalidator-invalid-fieldsbeforeafterr   z(_decorators.PydanticDescriptorProxy[Any]fr   c                   sJ   t | rtdddt | } tj}t j d}t j| ||dS )Nz2`@validator` cannot be applied to instance methodszvalidator-instance-methodrC   )r@   moder9   r:   r;   shim)r   is_instance_method_from_sigr   %ensure_classmethod_based_on_signaturer   Zmake_generic_v1_field_validatorZValidatorDecoratorInfoPydanticDescriptorProxy)rL   wrapZvalidator_wrapper_infor:   r;   r9   r@   rM   r   r   dec   s    
 
zvalidator.<locals>.dec)r   DeprecationWarning_ALLOW_REUSE_WARNING_MESSAGEtuplerE   r   r   all)r?   r8   r9   r:   r;   r<   r@   rU   r   rT   r   	validatorR   s*    $
rZ   .)r<   zLiteral[True]zFCallable[[_V1RootValidatorFunctionType], _V1RootValidatorFunctionType])skip_on_failurer<   r   c                 C  s   d S r   r   )r[   r<   r   r   r   root_validator   s    r\   )r8   r<   r   c                 C  s   d S r   r   )r8   r<   r   r   r   r\      s    zLiteral[False])r8   r[   r<   r   c                 C  s   d S r   r   r8   r[   r<   r   r   r   r\      s    Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more detailsr]   r   c                   s   t dtdd |rt | S |dkr.t tt | dkr:dnd | dkrZ|dk	rZtdd	d
ttj| dddd fdd}|S )a  Decorate methods on a model indicating that they should be used to validate (and perhaps
    modify) data either before or after standard model parsing/validation is performed.

    Args:
        pre (bool, optional): Whether this validator should be called before the standard
            validators (else after). Defaults to False.
        skip_on_failure (bool, optional): Whether to stop validation and return as soon as a
            failure is encountered. Defaults to False.
        allow_reuse (bool, optional): Whether to track and raise an error if another validator
            refers to the decorated function. Defaults to False.

    Returns:
        Any: A decorator that can be used to decorate a function to be used as a root_validator.
    r^   r   rA   TrI   rJ   FzIf you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.zroot-validator-pre-skiprC   )r8   zHCallable[..., Any] | classmethod[Any, Any, Any] | staticmethod[Any, Any]r   rK   c                   s8   t | rtdt | }t j d}t j||dS )Nz7`@root_validator` cannot be applied to instance methods)rM   rN   )r   rP   	TypeErrorrQ   ZRootValidatorDecoratorInforR   )rL   resZdec_inforM   rS   r   r   rU     s
    

zroot_validator.<locals>.dec)r   rV   r\   rW   r   r   r   Zmake_v1_generic_root_validator)r8   r[   r<   Z__argsrU   r   ra   r   r\      s$    

)4__doc__
__future__r   Z_annotations	functoolsr   r   typesr   typingr   r   r   r	   r
   r   warningsr   Ztyping_extensionsr   r   r   r   	_internalr   r   errorsr   r   rW   r   r#   r(   r+   r.   r0   ZV1ValidatorWithValuesZV1ValidatorWithValuesKwOnlyZV1ValidatorWithKwargsZV1ValidatorWithValuesAndKwargsZV1ValidatorZV1RootValidatorFunctionZV1RootValidatorclassmethodstaticmethodr3   __annotations__r4   r5   rV   rZ   r\   r   r   r   r   <module>   s    ,		"L