o
    Ú­j)(  ã                
   @  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mZ ddlmZ ddl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/„ƒZ2ed0d1œd?d5d6„ƒZ3ed0d1œd@d7d6„ƒZ3ed0d1œdAd9d6„ƒZ3ed:dd�d d d d;œdBd=d6„ƒZ3dS )CzCOld `@validator` and `@root_validator` function validators from V1.é    )Úannotations)ÚpartialÚpartialmethod)ÚFunctionType)ÚTYPE_CHECKINGÚAnyÚCallableÚLiteralÚTypeVarÚUnionÚoverload)Úwarn)ÚProtocolÚ	TypeAliasÚ
deprecatedé   )Ú_decoratorsÚ_decorators_v1)ÚPydanticUserError)ÚPydanticDeprecatedSince20zQ`allow_reuse` is deprecated and will be ignored; it should no longer be necessaryc                   @  ó   e Zd Zddd„ZdS )	Ú_OnlyValueValidatorClsMethodÚ!_OnlyValueValidatorClsMethod__clsr   Ú#_OnlyValueValidatorClsMethod__valueÚreturnc                 C  ó   d S ©N© )Úselfr   r   r   r   úa/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pydantic/deprecated/class_validators.pyÚ__call__   ó    z%_OnlyValueValidatorClsMethod.__call__N)r   r   r   r   r   r   ©Ú__name__Ú
__module__Ú__qualname__r    r   r   r   r   r      ó    r   c                   @  ó   e Zd Zd
dd„Zd	S )Ú_V1ValidatorWithValuesClsMethodÚ$_V1ValidatorWithValuesClsMethod__clsr   Ú&_V1ValidatorWithValuesClsMethod__valueÚvaluesúdict[str, Any]r   c                 C  r   r   r   )r   r)   r*   r+   r   r   r   r       r!   z(_V1ValidatorWithValuesClsMethod.__call__N)r)   r   r*   r   r+   r,   r   r   r"   r   r   r   r   r(      r&   r(   c                   @  r'   )Ú%_V1ValidatorWithValuesKwOnlyClsMethodÚ*_V1ValidatorWithValuesKwOnlyClsMethod__clsr   Ú,_V1ValidatorWithValuesKwOnlyClsMethod__valuer+   r,   r   c                C  r   r   r   )r   r.   r/   r+   r   r   r   r       r!   z._V1ValidatorWithValuesKwOnlyClsMethod.__call__N)r.   r   r/   r   r+   r,   r   r   r"   r   r   r   r   r-      r&   r-   c                   @  r   )	Ú_V1ValidatorWithKwargsClsMethodÚ$_V1ValidatorWithKwargsClsMethod__clsr   Úkwargsr   c                 K  r   r   r   )r   r1   r2   r   r   r   r       r!   z(_V1ValidatorWithKwargsClsMethod.__call__N)r1   r   r2   r   r   r   r"   r   r   r   r   r0      r&   r0   c                   @  r'   )Ú(_V1ValidatorWithValuesAndKwargsClsMethodÚ-_V1ValidatorWithValuesAndKwargsClsMethod__clsr   r+   r,   r2   r   c                 K  r   r   r   )r   r4   r+   r2   r   r   r   r    "   r!   z1_V1ValidatorWithValuesAndKwargsClsMethod.__call__N)r4   r   r+   r,   r2   r   r   r   r"   r   r   r   r   r3   !   r&   r3   c                   @  s   e Zd Zd	dd„ZdS )
Ú_V1RootValidatorClsMethodÚ_V1RootValidatorClsMethod__clsr   Ú!_V1RootValidatorClsMethod__valuesú"_decorators_v1.RootValidatorValuesr   c                 C  r   r   r   )r   r6   r7   r   r   r   r    %   s   z"_V1RootValidatorClsMethod.__call__N)r6   r   r7   r8   r   r8   r"   r   r   r   r   r5   $   r&   r5   r   Ú_PartialClsOrStaticMethodÚ_V1ValidatorTypeÚ_V1RootValidatorFunctionTypeú©Pydantic 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Ú__fieldÚstrÚfieldsr>   Úboolr?   r@   rA   úbool | NonerB   r   ú.Callable[[_V1ValidatorType], _V1ValidatorType]c                  s’   t dtdd� |du rt ttdd� | gˆ¢R ‰tˆd tƒr%tddd�‚td	d
„ ˆD ƒƒs4tddd�‚|du r:dn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.
    r<   r   ©Ú
stacklevelTr   z`@validator` should be used with fields and keyword arguments, not bare. E.g. usage should be `@validator('<field_name>', ...)`zdecorator-missing-arguments©Úcodec                 s  s   � | ]}t |tƒV  qd S r   )Ú
isinstancerD   )Ú.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decorator-invalid-fieldsÚbeforeÚafterÚfr   r   ú(_decorators.PydanticDescriptorProxy[Any]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-methodrK   )rE   Úmoder?   r@   rA   ©Úshim)r   Úis_instance_method_from_sigr   Ú%ensure_classmethod_based_on_signaturer   Úmake_generic_v1_field_validatorÚValidatorDecoratorInfoÚPydanticDescriptorProxy)rS   ÚwrapÚvalidator_wrapper_info©r@   rA   r?   rE   rU   r   r   ÚdecŠ   s   
ÿ
ûzvalidator.<locals>.decN)rS   r   r   rT   )r   ÚDeprecationWarningÚ_ALLOW_REUSE_WARNING_MESSAGErM   r   r   Úall)rC   r>   r?   r@   rA   rB   rE   r`   r   r_   r   Ú	validatorL   s*   $ûýýrd   .)rB   Úskip_on_failureúLiteral[True]úFCallable[[_V1RootValidatorFunctionType], _V1RootValidatorFunctionType]c                 C  r   r   r   )re   rB   r   r   r   Úroot_validatorž   ó   
rh   c                 C  r   r   r   )r>   rB   r   r   r   rh   «   ri   úLiteral[False]c                 C  r   r   r   ©r>   re   rB   r   r   r   rh   ¸   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 detailsrk   r   c                   s€   t dtdd� |rtƒ |Ž S |du rt ttdd� | du rdnd‰ | du r/|dur/tdd	d
�‚ttj| 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.
    rl   r   rI   TrQ   rR   Fz¼If 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-skiprK   )r>   rS   úHCallable[..., Any] | classmethod[Any, Any, Any] | staticmethod[Any, Any]r   r   c                   s8   t  | ¡r	tdƒ‚t  | ¡}t jˆ d�}t j||ˆd�S )Nz7`@root_validator` cannot be applied to instance methods)rU   rV   )r   rX   Ú	TypeErrorrY   ÚRootValidatorDecoratorInfor\   )rS   ÚresÚdec_info©rU   r]   r   r   r`   ø   s
   

zroot_validator.<locals>.decN)rS   rm   r   r   )r   ra   rh   rb   r   r   r   Úmake_v1_generic_root_validator)r>   re   rB   Ú__argsr`   r   rr   r   rh   Æ   s$   û
ý)rC   rD   rE   rD   r>   rF   r?   rF   r@   rF   rA   rG   rB   rF   r   rH   )re   rf   rB   rF   r   rg   )r>   rf   rB   rF   r   rg   )r>   rj   re   rf   rB   rF   r   rg   )r>   rF   re   rF   rB   rF   r   r   )4Ú__doc__Ú
__future__r   Ú_annotationsÚ	functoolsr   r   Útypesr   Útypingr   r   r   r	   r
   r   r   Úwarningsr   Útyping_extensionsr   r   r   Ú	_internalr   r   Úerrorsr   r   rb   r   r(   r-   r0   r3   r5   ÚV1ValidatorWithValuesÚV1ValidatorWithValuesKwOnlyÚV1ValidatorWithKwargsÚV1ValidatorWithValuesAndKwargsÚV1ValidatorÚV1RootValidatorFunctionÚV1RootValidatorÚclassmethodÚstaticmethodr9   Ú__annotations__r:   r;   ra   rd   rh   r   r   r   r   Ú<module>   sŽ    $øÿÿÿ,ü	ü	ùLûûúüü