
    yIf!                    F   d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ dd	lmZ ej        d
k    rddl
mZ nddlmZ  ed          Z ed          Zd ZddZddZ ej                    r	 dddZ	 dddZdS 	 dddZ	 dddZdS ) z(A few useful function/method decorators.    )annotationsN)Callable	Generator)TypeVar)util)InferenceContext)InferenceError)InferenceResult)   
   )	ParamSpec_R_Pc                H    t          j        |           d| fdd            }|S )zReturn the given infer function wrapped to handle the path.

    Used to stop inference if the node has already been looked
    at for a given `InferenceContext` to prevent infinite recursion
    NcontextInferenceContext | Nonereturnr   c              ;     K   |t                      }|                    |           rdS t                      } || |fi |D ]9}|j        j        dk    r|j        }n|}||vr|V  |                    |           :dS )z"Wrapper function handling context.NInstance)r   pushset	__class____name___proxiedadd)noder   _funckwargsyieldedresaress          F/var/www/piapp/venv/lib/python3.11/site-packages/astroid/decorators.pywrappedzpath_wrapper.<locals>.wrapped%   s      
 ?&((G<< 	F%%5w11&11 	" 	"C}%33|7""			D!!!	" 	"    )r   r   r   r   	functoolswraps)funcr#   s     r"   path_wrapperr)      s>     _T15T" " " " "* Nr$   r(   4Callable[_P, Generator[InferenceResult, None, None]]r   c                     d fd}|S )	Nargs_P.argsr   	_P.kwargsr   &Generator[InferenceResult, None, None]c               ?     K    | i |}	 t          |          V  n# t          $ r t          j        V  Y d S w xY w|E d {V  d S )N)nextStopIterationr   Uninferable)r,   r   	generatorr(   s      r"   innerz&yes_if_nothing_inferred.<locals>.innerA   s       D$)&))		y//!!!! 	 	 	""""FF	
 s    ;;r,   r-   r   r.   r   r/    r(   r5   s   ` r"   yes_if_nothing_inferredr9   >   s(          Lr$   c                     d fd}|S )	Nr,   r-   r   r.   r   r/   c               ?  8  K    | i |}	 t          |          V  ns# t          $ r4}|j        rt          di |j        d         |t          d          |d }~wt          $ r*}t          dt          j                     d          |d }~ww xY w|E d {V  d S )Nr   z3StopIteration raised without any error information.z!RecursionError raised with limit .r7   )r1   r2   r,   r	   RecursionErrorsysgetrecursionlimit)r,   r   r4   errorr(   s       r"   r5   z(raise_if_nothing_inferred.<locals>.innerU   s       D$)&))		y//!!!! 	 	 	z A$55uz!}555@ E   	 	 	 NC4I4K4KNNN 	
 s     
B/AB%%B

Br6   r7   r8   s   ` r"   raise_if_nothing_inferredrA   R   s(         ( Lr$   3.0astroid_versionstr	arguments.Callable[[Callable[_P, _R]], Callable[_P, _R]]c                     d fd}|S )a  Decorator which emits a DeprecationWarning if any arguments specified
        are None or not passed at all.

        Arguments should be a key-value mapping, with the key being the argument to check
        and the value being a type annotation as string for the value of the argument.

        To improve performance, only used when DeprecationWarnings other than
        the default one are enabled.
        r(   Callable[_P, _R]r   c                N     t          j                   d fd            }|S )	Decorator function.r,   r-   r   r.   r   r   c                 `   t          t          j                  j                                                  }                                D ]\  }}	 |                    |          }n5# t          $ r( t          d| d| d         j        j	         d          dw xY w||v r||         8||vrx|dk    s.t          |           |k    st          |           |k    rL| |         Dt          j        d| d| d         j        j	         dj         d	 d
| d| dt          d            | i |S )z/Emit DeprecationWarnings if conditions are met.Can't find argument '' for 'r   'Nz#' will be a required argument for 'r<   z' in astroid z ('z' should be of type: 'z')   
stacklevellistinspect	signature
parameterskeysitemsindex
ValueErrorr   __qualname__lenwarningswarnr   DeprecationWarning)	r,   r   rX   argtype_annotationrZ   rE   rC   r(   s	         r"   wrapperz@deprecate_default_argument_values.<locals>.deco.<locals>.wrapper   s    G-d33>CCEEFF,5OO,=,=  (C$ $

3% $ $ $(aCaaQ@Q@^aaa #$$ 6#;+> f,,!RKK"4yyE11 #D		E 1 1d5k6I !P P P $Q 1 >P PAEP P+:P P "%P P =LP P P /'(    tT,V,,,   A**2Br,   r-   r   r.   r   r   r%   r(   rc   rE   rC   s   ` r"   decoz/deprecate_default_argument_values.<locals>.deco   sK     _T""#- #- #- #- #- #- #- #"#-J Nr$   r(   rH   r   rH   r7   rC   rE   rg   s   `` r"   !deprecate_default_argument_valuesrj   q   s/     )	 )	 )	 )	 )	 )	 )	V r$   c                     d fd}|S )a  Decorator which emits a DeprecationWarning if any arguments specified
        are passed.

        Arguments should be a key-value mapping, with the key being the argument to check
        and the value being a string that explains what to do instead of passing the argument.

        To improve performance, only used when DeprecationWarnings other than
        the default one are enabled.
        r(   rH   r   c                N     t          j                   d fd            }|S )	Nr,   r-   r   r.   r   r   c                     t          t          j                  j                                                  }                                D ]\  }}	 |                    |          }n5# t          $ r( t          d| d| d         j        j	         d          d w xY w||v st          |           |k    rAt          j        d| d| d         j        j	         dj         d d| d	t          d
            | i |S )NrL   rM   r   rN   zThe argument 'r<   z/' is deprecated and will be removed in astroid z ()rP   rQ   rS   )	r,   r   rX   ra   noterZ   rE   rC   r(   s	         r"   rc   z2deprecate_arguments.<locals>.deco.<locals>.wrapper   sc   G-d33>CCEEFF!*!2!2  IC$ $

3% $ $ $(aCaaQ@Q@^aaa #$$ f}}D		E(9(9 YS Y Y $Q 1 >Y YAEY Y>MY YQUY Y Y /'(    tT,V,,,rd   re   r%   rf   s   ` r"   rg   z!deprecate_arguments.<locals>.deco   sH    _T""- - - - - - - #"-& Nr$   rh   r7   ri   s   `` r"   deprecate_argumentsrp      s.    	 	 	 	 	 	 	. r$   c                    dd}|S )bPassthrough decorator to improve performance if DeprecationWarnings are
        disabled.
        r(   rH   r   c                    | S rJ   r7   r(   s    r"   rg   z/deprecate_default_argument_values.<locals>.deco       Kr$   rh   r7   ri   s      r"   rj   rj          	 	 	 	 r$   c                    dd}|S )rr   r(   rH   r   c                    | S rt   r7   ru   s    r"   rg   z!deprecate_arguments.<locals>.deco   rv   r$   rh   r7   ri   s      r"   rp   rp      rw   r$   )r(   r*   r   r*   )rB   )rC   rD   rE   rD   r   rF   )__doc__
__future__r   r&   rU   r>   r^   collections.abcr   r   typingr   astroidr   astroid.contextr   astroid.exceptionsr	   astroid.typingr
   version_infor   typing_extensionsr   r   r)   r9   rA   check_warnings_filterrj   rp   r7   r$   r"   <module>r      s  
 / . " " " " " "      



  / / / / / / / /             , , , , , , - - - - - - * * * * * *w       ++++++WT]]Yt__  @   (   : 4   %; ; ; ; ;|  %$ $ $ $ $ $ $R  %      %      r$   