U
    Qh                     @  s   d Z ddlmZ ddlZddl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mZmZ dd	lmZ d
Ze
rddlmZ ededef dZdZdddddZedddddddddZedddddZd#ddddddd d!d"dZdS )$z(Decorator for validating function calls.    )annotationsN)partial)BuiltinFunctionType)TYPE_CHECKINGAnyCallableTypeVarcastoverload   )_generate_schema_typing_extra_validate_call)PydanticUserError)validate_call)
ConfigDictAnyCallableT.)Zboundzvalidate-call-typeobjectNonefunctionreturnc              
   C  sj  t | tjrztttj|  W n( tk
rJ   td|  dt	dY nX t | t
rz"t t
jt
rltdt| j W nB tk
r } z$td| j d| j dt	d|W 5 d}~X Y nX dS t | trtd	|  d
t	dt | tttfrt| j}td| d| dt	dt| r4td|  dt	dt| rRtd|  dt	dtd|  dt	ddS )zDCheck if the input function is a supported type for `validate_call`.zInput function `z ` doesn't have a valid signature)codezPartial of partialzPartial of `z"` is invalid because the type of `z%` is not supported by `validate_call`NzInput built-in function `z` is not supportedzThe `@z<` decorator should be applied after `@validate_call` (put `@z	` on top)zUnable to validate z~: `validate_call` should be applied to functions, not classes (put `@validate_call` on top of `__init__` or `__new__` instead)z: `validate_call` should be applied to functions, not instances or other callables. Use `validate_call` explicitly on `__call__` instead.za: `validate_call` should be applied to one of the following: function, method, partial, or lambda)
isinstancer   ZVALIDATE_CALL_SUPPORTED_TYPESinspectZ	signaturer	   ValidateCallSupportedTypes
ValueErrorr   _INVALID_TYPE_ERROR_CODEr   funcAssertionError_check_function_typer   classmethodstaticmethodpropertytype__name__Zisclasscallable)r   ename r)   F./venv/lib/python3.8/site-packages/pydantic/validate_call_decorator.pyr       sT    
 






r    Fconfigvalidate_returnzConfigDict | Noneboolz&Callable[[AnyCallableT], AnyCallableT])r,   r-   r   c                 C  s   d S Nr)   r+   r)   r)   r*   r   H   s    r   )r   r   c                C  s   d S r/   r)   )r   r)   r)   r*   r   N   s    zAnyCallableT | Nonez5AnyCallableT | Callable[[AnyCallableT], AnyCallableT])r   r,   r-   r   c                 s8   t  ddd fdd}| dk	r0|| S |S dS )a  Usage docs: https://docs.pydantic.dev/2.10/concepts/validation_decorator/

    Returns a decorated wrapper around the function that validates the arguments and, optionally, the return value.

    Usage may be either as a plain decorator `@validate_call` or with arguments `@validate_call(...)`.

    Args:
        func: The function to be decorated.
        config: The configuration dictionary.
        validate_return: Whether to validate the return value.

    Returns:
        The decorated function.
    r   r   c                   s.   t |  tttj|  }t| |jS r/   )r    r   ZValidateCallWrapperr	   r   r   Zupdate_wrapper_attributes__call__)r   Zvalidate_call_wrapperr,   Zparent_namespacer-   r)   r*   validatei   s    
   zvalidate_call.<locals>.validateN)r   Zparent_frame_namespace)r   r,   r-   r2   r)   r1   r*   r   R   s
    )N)__doc__Z
__future__r   Z_annotationsr   	functoolsr   typesr   typingr   r   r   r   r	   r
   Z	_internalr   r   r   errorsr   __all__r,   r   r   r   r    r   r)   r)   r)   r*   <module>   s0    0  