
    c                       U d Z ddlmZ ddlZddlmZ ddl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 ej        eej        ej        ej        e	j                 f         Zi Zd	ed
<   ddZej        dd            ZdddZdS )z,Transform utilities (filters and decorator).    )annotationsN)Iterator)basesutil)InferenceOverwriteErrorUseInferenceDefault)NodeNG)InferFnz7dict[tuple[InferFn, NodeNG], list[InferOptions] | None]_cachereturnNonec                 8    t                                            dS )zClear the inference tips cache.N)r   clear     5lib/python3.11/site-packages/astroid/inference_tip.pyclear_inference_tip_cacher      s    
LLNNNNNr   funcr
   instanceargs
typing.AnykwargsIterator[InferOptions]c                    |d         }	 t           | |f         }|t                      nA# t          $ r4 dt           | |f<   t           | |i |          x}t           | |f<   |sJ Y nw xY wt	          |          S )z(Cache decorator used for inference tips.r   N)r   r   KeyErrorlistiter)r   r   r   r   noderesults         r   _inference_tip_cachedr       s    
 7D	d
#  	(%'''	(   !tTz&*44+@+@+@&A&AAd
# <<s   * ;A('A(Finfer_functionraise_on_overwriteboolc                    | 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	   r!   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   formatr    )r   r!   r"   s     r   	transformz inference_tip.<locals>.transformH   s}    	(	 (>	
 *FFLf'5"&": GM G G   $9#H#H r   )r   r	   r!   r
   r   r	   r   )r!   r"   r*   s    ` r   inference_tipr+   2   s4    , ;I       $ r   )r   r   )
r   r
   r   r   r   r   r   r   r   r   )F)r!   r
   r"   r#   r   r
   )__doc__
__future__r   typingcollections.abcr   wraptastroidr   r   astroid.exceptionsr   r   astroid.nodesr	   astroid.typingr
   UnionInstanceUnboundMethodTypeUninferableInferOptionsr   __annotations__r   	decoratorr    r+   r   r   r   <module>r=      s/  
 3 2 2 " " " " " "  $ $ $ $ $ $          K K K K K K K K             " " " " " "|
ENE/T=M1NN CE D D D D   
    $( ( ( ( ( ( (r   