o
    j                     @   sT  d dl Z d dl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mZ d dlmZ d dlmZ d dlmZ ejd	krDd d
l mZ nd d
lmZ dedef dB defddZdedef dedef fddZeddG dd dZeeeeef f ZdZG dd dZdede e! fddZ"dddededB defdd Z#dd!ded"edB defd#d$Z$dedefd%d&Z%dedefd'd(Z&eed)d*edefd+d,Z'dedef dB defd-d.Z(eed)d*edefd/d0Z)dedef dB defd1d2Z*eed)d*edefd3d4Z+dedef dB defd5d6Z,dede!dB fd7d8Z-dS )9    N)Callable)	dataclassfield)	lru_cachepartial)AnyLiteral)
ModelField)SecurityBase)DependencyCacheKey)      )iscoroutinefunctioncall.returnc                 C   s   | d u r| S t t| }|S N)inspectunwrap
_impartial)r   	unwrapped r   Y/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/fastapi/dependencies/models.py_unwrapped_call   s   r   funcc                 C   s   t | tr| j} t | ts| S r   )
isinstancer   r   )r   r   r   r   r      s   

r   T)slotsc                   @   sr  e Zd ZU eedZee ed< eedZee ed< eedZ	ee ed< eedZ
ee ed< eedZee ed< eedZed  ed< dZedB ed	< dZed
ef dB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZee dB ed< dZee dB ed< dZeed< dZedB ed< dZed dB ed< dS )	Dependant)default_factorypath_paramsquery_paramsheader_paramscookie_paramsbody_paramsdependenciesNname.r   request_param_namewebsocket_param_namehttp_connection_param_nameresponse_param_namebackground_tasks_param_namesecurity_scopes_param_nameown_oauth_scopesparent_oauth_scopesT	use_cachepath)functionrequestscope)__name__
__module____qualname__r   listr   r	   __annotations__r   r    r!   r"   r#   r$   strr   r   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   boolr.   r1   r   r   r   r   r   r      s(   
 r   i   c                   @   sJ   e Zd ZdZdedef ddfddZdefdd	Zd
e	de
fddZdS )_CallIdentityr   r   .r   Nc                 C   s
   || _ d S r   r:   )selfr   r   r   r   __init__=      
z_CallIdentity.__init__c                 C   s
   t | jS r   )idr   )r;   r   r   r   __hash__@   r=   z_CallIdentity.__hash__otherc                 C   s   t |to
| j|ju S r   )r   r9   r   )r;   r@   r   r   r   __eq__C   s   z_CallIdentity.__eq__)r2   r3   r4   	__slots__r   r   r<   intr?   objectr8   rA   r   r   r   r   r9   :   s
    r9   	dependantc                 C   s:   | j r| j  ng }| jpg D ]}||vr|| q|S r   )r,   copyr+   append)rE   scopesr1   r   r   r   _get_oauth_scopesG   s   
rI   )uses_scopes_cacherJ   c                 C   s<   t | |drtttt| dnd}| j|t| dpdfS )NrE   cacherE   r    )_uses_scopestuplesortedsetrI   r   _get_computed_scope)rE   rJ   scopes_for_cacher   r   r   _get_cache_keyR   s   
rU   rL   rL   c                    s    d u ri  t | } |}|d ur|d | u r|d S | jr#d}n| jd ur+d}nt| dr3d}nt fdd| jD }| |f |< |S )Nr      TrM   c                 3   s    | ]	}t | d V  qdS )rK   N)rO   ).0sub_deprV   r   r   	<genexpr>s   s
    

z_uses_scopes.<locals>.<genexpr>)r>   getr+   r*   _is_security_schemeanyr#   )rE   rL   	cache_keycachedresultr   rV   r   rO   c   s"   


rO   c                 C   s"   | j d u rdS t| j }t|tS NF)r   r   r   r
   rE   r   r   r   r   r\   {   s   


r\   c                 C   s   t | j}t|tsJ |S r   )r   r   r   r
   rb   r   r   r   _get_security_scheme   s   
rc   )maxsizecall_identityc                 C      | j }tt|stt|rdS tt|rdS tt|dd }|d u r*dS tt|s8tt|r:dS tt|dd }|d u rHdS tt|pUtt|S NTF__call__)r   r   isgeneratorfunctionr   r   isclassgetattrre   r   dunder_calldunder_unwrapped_callr   r   r   _is_gen_callable_cached   0   ro   c                 C      | d u rdS t t| S ra   )ro   r9   r:   r   r   r   _is_gen_callable      rr   c                 C   rf   rg   )r   r   isasyncgenfunctionr   r   rj   rk   rl   r   r   r   _is_async_gen_callable_cached   rp   ru   c                 C   rq   ra   )ru   r9   r:   r   r   r   _is_async_gen_callable   rs   rv   c                 C   s   | j }tt|rtt|rdS tt|r!tt|r!dS tt|r*dS tt|dd }|d u r8dS tt|sDtt|rFdS tt|dd }|d u rTdS tt|p_tt|S rg   )r   r   	isroutiner   r   r   rj   rk   rl   r   r   r   _is_coroutine_callable_cached   s0   
rx   c                 C   rq   ra   )rx   r9   r:   r   r   r   _is_coroutine_callable   rs   ry   c                 C   s(   | j r| j S t| jst| jrdS d S )Nr0   )r1   rr   r   rv   rM   r   r   r   rS      s
   rS   ).r   syscollections.abcr   dataclassesr   r   	functoolsr   r   typingr   r   fastapi._compatr	   fastapi.security.baser
   fastapi.typesr   version_infor   asyncior   r   r   dictrC   rP   r8   _UsesScopesCache#_CALLABLE_CLASSIFICATION_CACHE_SIZEr9   r5   r7   rI   rU   rO   r\   rc   ro   rr   ru   rv   rx   ry   rS   r   r   r   r   <module>   s`    
"

