
    g                        d dl mZ d dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
Z
ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZmZmZ ddZddZddZ G d d      Zy)    )annotationsN)partial)Any	AwaitableCallable   )
ConfigDict)create_schema_validator   )ConfigWrapper)GenerateSchemaValidateCallSupportedTypes)MappingNamespace
NsResolverns_for_functionc                    t        | t        j                        rd| j                  j                   dS | j                  S )z:Extract the name of a `ValidateCallSupportedTypes` object.partial())
isinstance	functoolsr   func__name__r   s    V/var/www/openai/venv/lib/python3.12/site-packages/pydantic/_internal/_validate_call.pyextract_function_namer      s7    /9$	@Q@Q/RXdii(()+eX\XeXee    c                    t        | t        j                        rd| j                  j                   dS | j                  S )z>Extract the qualname of a `ValidateCallSupportedTypes` object.r   r   )r   r   r   r   __qualname__r   s    r   extract_function_qualnamer      s7    3=dIDUDU3VXdii,,-Q/m\`\m\mmr   c                    t        j                  |       rt        j                  |       fd       }nt        j                  |       fd       }t	        |       |_        t        |       |_        | |_        |S )ziUpdate the `wrapper` function with the attributes of the `wrapped` function. Return the updated function.c                 0   K    | i | d {   S 7 wN argskwargswrappers     r   wrapper_functionz3update_wrapper_attributes.<locals>.wrapper_function   s      $1&1111s   c                      | i |S r"   r#   r$   s     r   r(   z3update_wrapper_attributes.<locals>.wrapper_function$   s    D+F++r   )	inspectiscoroutinefunctionr   wrapsr   r   r   r   raw_function)wrappedr'   r(   s    ` r   update_wrapper_attributesr/      sv    ""7+		!	2 
"	2 
	!	, 
"	, !6g >$=g$F!$+!r   c                  8    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 ddZddZy)ValidateCallWrapperzoThis is a wrapper around a function that validates the arguments passed to it, and optionally the return value.)__pydantic_validator____return_pydantic_validator__c           	     &   t        |t              r#|j                  }|j                  j                  }n|}|j                  }t	        |      }t        t        ||            }t        |      }	t        |	|      }
|
j                  |
j                  |            }|	j                  |      }t        ||||d||	j                        | _        |rt        j                   |      }|j"                  |j$                  ur|j"                  nt&        }t        |	|      }
|
j                  |
j                  |            }t        ||||d||	j                        t        j(                  |      rdfd}|| _        y j,                  | _        y d | _        y )N)parent_namespace)namespaces_tuple)titlevalidate_callc                B   K   j                  |  d {         S 7 wr"   )validate_python)aw	validators    r   return_val_wrapperz8ValidateCallWrapper.__init__.<locals>.return_val_wrappere   s     $442X>>Xs   	)r;   zAwaitable[Any]returnNone)r   r   r   
__module__r   r   r   r   r   clean_schemagenerate_schemacore_configr
   plugin_settingsr2   r*   	signaturereturn_annotationemptyr   r+   r3   r:   )selffunctionconfigvalidate_returnr5   schema_typemodulequalnamens_resolverconfig_wrapper
gen_schemaschemarC   rE   return_typer=   r<   s                   @r   __init__zValidateCallWrapper.__init__5   sx    h("--K]]--F"K((F,X6 /+`p2qr&v.#NK@
(()C)CH)MN$00x0@&=**'
# ))(3I9B9T9T\e\k\k9k)55qtK'DJ,,Z-G-G-TUF/..I **84? 6H25>5N5N215D.r   c                    | j                   j                  t        j                  ||            }| j                  r| j	                  |      S |S r"   )r2   r:   pydantic_core
ArgsKwargsr3   )rH   r%   r&   ress       r   __call__zValidateCallWrapper.__call__n   sF    ))99-:R:RSWY_:`a--55c::Jr   N)
rI   r   rJ   zConfigDict | NonerK   boolr5   zMappingNamespace | Noner>   r?   )r%   r   r&   r   r>   r   )r   r@   r   __doc__	__slots__rT   rY   r#   r   r   r1   r1   0   sE    yKI76,76 "76 	76
 276 
76rr   r1   )r   r   r>   str)r.   r   r'   zCallable[..., Any])
__future__r   _annotationsr   r*   r   typingr   r   r   rV   rJ   r	   plugin._schema_validatorr
   _configr   _generate_schemar   r   _namespace_utilsr   r   r   r   r   r/   r1   r#   r   r   <module>re      sI    2    + +   > " H K Kf
n
*C Cr   