o
    ¨Ýj?(  ã                
   @  s
  U d Z ddlm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 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f e-eef B ee B Z.de/d< ede)e.ƒZ0edej*e$e.ƒZ1neZ2eddd �d!d!d!dd!d"œd?d/d0„ƒZ3ed1d2œd@d6d7„ƒZ4ed1d2œdAd8d7„ƒZ4ed1d2œdBd:d7„ƒZ4ed;dd �d!d!d!d<œdCd>d7„ƒZ4dS )DzCOld `@validator` and `@root_validator` function validators from V1.é    )Úannotations)ÚCallable)ÚpartialÚpartialmethod)ÚFunctionType)ÚTYPE_CHECKINGÚAnyÚLiteralÚ	TypeAliasÚTypeVarÚUnionÚoverload)Úwarn)ÚProtocolÚ
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   ú_/var/www/html/chatgpt/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   Zmake_generic_v1_field_validatorZValidatorDecoratorInfoÚPydanticDescriptorProxy)rS   ÚwrapZ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   Ú	validatorM   s*   $ûýýra   .)rB   Úskip_on_failureúLiteral[True]úFCallable[[_V1RootValidatorFunctionType], _V1RootValidatorFunctionType]c                 C  r   r   r   )rb   rB   r   r   r   Úroot_validatorŸ   ó   
re   c                 C  r   r   r   )r>   rB   r   r   r   re   ¬   rf   úLiteral[False]c                 C  r   r   r   ©r>   rb   rB   r   r   r   re   ¹   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 detailsrh   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.
    ri   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   ZRootValidatorDecoratorInforZ   )rS   ÚresZdec_info©rU   r[   r   r   r]   ù   s
   

zroot_validator.<locals>.decN)rS   rj   r   r   )r   r^   re   r_   r   r   r   Zmake_v1_generic_root_validator)r>   rb   rB   Z__argsr]   r   rm   r   re   Ç   s$   û
ý)rC   rD   rE   rD   r>   rF   r?   rF   r@   rF   rA   rG   rB   rF   r   rH   )rb   rc   rB   rF   r   rd   )r>   rc   rB   rF   r   rd   )r>   rg   rb   rc   rB   rF   r   rd   )r>   rF   rb   rF   rB   rF   r   r   )5Ú__doc__Ú
__future__r   Z_annotationsÚcollections.abcr   Ú	functoolsr   r   Útypesr   Útypingr   r   r	   r
   r   r   r   Úwarningsr   Ztyping_extensionsr   r   Ú	_internalr   r   Úerrorsr   r   r_   r   r(   r-   r0   r3   r5   ZV1ValidatorWithValuesZV1ValidatorWithValuesKwOnlyZV1ValidatorWithKwargsZV1ValidatorWithValuesAndKwargsZV1ValidatorZV1RootValidatorFunctionZV1RootValidatorÚclassmethodÚstaticmethodr9   Ú__annotations__r:   r;   r^   ra   re   r   r   r   r   Ú<module>   s�    $øÿÿÿ*ü	ü	ùLûûúüü