
    yIf                        U d 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 ddlmZmZ ddlmZ dd	lmZmZmZ  e            Zd
ed<    e            Zded<    e	de          ZddZddZ	 dd dZdS )!z,Transform utilities (filters and decorator).    )annotations)OrderedDict)	Generator)AnyTypeVar)InferenceContext)InferenceOverwriteErrorUseInferenceDefault)NodeNG)InferenceResultInferFnTransformFnzXOrderedDict[tuple[InferFn[Any], NodeNG, InferenceContext | None], list[InferenceResult]]_cachez set[tuple[InferFn[Any], NodeNG]]_CURRENTLY_INFERRING_NodesT)boundreturnNonec                 8    t                                            dS )zClear the inference tips cache.N)r   clear     I/var/www/piapp/venv/lib/python3.11/site-packages/astroid/inference_tip.pyclear_inference_tip_cacher      s    
LLNNNNNr   funcInferFn[_NodesT]c                     	 dd fd
}|S )z(Cache decorator used for inference tips.Nnoder   contextInferenceContext | Nonekwargsr   r   &Generator[InferenceResult, None, None]c              ;  2  K   | f}|t           v r!t                               |           t          ||                                rd }	 t          | |f         E d {V  d S # t
          $ r t                               |           	 t           | |fi |          x}t          | |f<   n# t          $ r}|d d }~ww xY w	 	 t                               |           n# t
          $ r Y nw xY wt          t                    dk    rt          
                    d           ne# 	 t                               |           n# t
          $ r Y nw xY wt          t                    dk    rt          
                    d           w w xY wY nw xY w|E d {V  d S )N@   F)last)r   remover
   is_emptyr   KeyErroraddlist	Exceptionlenpopitem)r   r   r!   partial_cache_keyresulter   s         r   innerz$_inference_tip_cached.<locals>.inner'   s     
 "4L 444 !''(9:::%%7#3#3#5#5G	/dD'122222222F 	/ 	/ 	/ !$$%6777/7;Dw11&118 8 dG 344  " " "T!" 5(//0ABBBB   D v;;##NNN...(//0ABBBB   D v;;##NNN.... $-	/4 s   A# #%F	$B.-D$.
C 8B;;C  D$C F 
C-*F,C--7F$F&E F
E	FE	8FFF)N)r   r   r   r    r!   r   r   r"   r   )r   r1   s   ` r   _inference_tip_cachedr2   $   s3    
 ,0+ + + + + + +Z Lr   Finfer_functionraise_on_overwriteboolTransformFn[_NodesT]c                    | fdfd}|S )a  Given an instance specific inference function, return a function to be
    given to AstroidManager().register_transform to set this inference function.

    :param bool raise_on_overwrite: Raise an `InferenceOverwriteError`
        if the inference tip will overwrite another. Used for debugging

    Typical usage

    .. sourcecode:: python

       AstroidManager().register_transform(Call, inference_tip(infer_named_tuple),
                                  predicate)

    .. Note::

        Using an inference tip will override
        any previously set inference tip for the given
        node. Use a predicate in the transform to prevent
        excess overwrites.
    r   r   r3   r   r   c                    r:| j         3| j         |ur*t          d                    || j         |                     t          |          | _         | S )NzbInference already set to {existing_inference}. Trying to overwrite with {new_inference} for {node})existing_inferencenew_inferencer   )_explicit_inferencer	   formatr2   )r   r3   r4   s     r   	transformz inference_tip.<locals>.transformo   sw     	(4(>>)FFLf'5"&": GM G G   $9#H#H r   )r   r   r3   r   r   r   r   )r3   r4   r=   s    ` r   inference_tipr>   W   s4    2 ;I      & r   N)r   r   )r   r   r   r   )F)r3   r   r4   r5   r   r6   )__doc__
__future__r   collectionsr   collections.abcr   typingr   r   astroid.contextr   astroid.exceptionsr	   r
   astroid.nodesr   astroid.typingr   r   r   r   __annotations__setr   r   r   r2   r>   r   r   r   <module>rJ      sq  
 3 2 2 " " " " " " # # # # # # % % % % % %         , , , , , , K K K K K K K K                      KMM      :=  > > > >
')6
*
*
*   
0 0 0 0h BG+ + + + + + +r   