§
    ñyIfŽ.  ã                  ó.  — d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZmZ ddlmZmZmZmZmZ ddlmZ dd	lmZ dd
lmZ 	 d2d3d„Zd4d„Zd5d„Z	 d2d6d„Z	 d2d7d„Z 	 d2d8d#„Z!	 d2d9d$„Z"	 d2d:d&„Z#d2d;d(„Z$d<d)„Z%d<d*„Z&d<d+„Z'd=d.„Z(d2d>d/„Z)d?d1„Z*dS )@zVarious helper utilities.é    )ÚannotationsN)Ú	Generator)ÚbasesÚmanagerÚnodesÚobjectsÚraw_buildingÚutil)ÚCallContextÚInferenceContext)ÚAstroidTypeErrorÚAttributeInferenceErrorÚInferenceErrorÚMroErrorÚ_NonDeducibleTypeHierarchy)Úscoped_nodes)ÚInferenceResult)Ú
safe_inferÚnodeú1nodes.NodeNG | bases.Proxy | util.UninferableBaseÚcontextúInferenceContext | NoneÚreturnúInferenceResult | Nonec                ó\   — t          j        dt          d¬¦  «         t          | |¬¦  «        S )NzRImport safe_infer from astroid.util; this shim in astroid.helpers will be removed.é   )Ú
stacklevel©r   )ÚwarningsÚwarnÚDeprecationWarningÚreal_safe_infer©r   r   s     úC/var/www/piapp/venv/lib/python3.11/site-packages/astroid/helpers.pyr   r      s;   € õ
 „MØ\ÝØðñ ô ð õ
 ˜4¨Ð1Ñ1Ô1Ð1ó    Úcls_nameÚstrÚbuiltinsúnodes.Moduleúnodes.ClassDefc                ó<   — t          j        | ¦  «        }||_        |S ©N)r	   Úbuild_classÚparent)r&   r(   Úproxys      r$   Ú_build_proxy_classr0   '   s   € ÝÔ$ XÑ.Ô.€EØ€E„LØ€Lr%   Úfunctionú6nodes.Lambda | nodes.FunctionDef | bases.UnboundMethodc                óò   — t          | t          j        t          j        f¦  «        r#|                      ¦   «         j        dk    rd}n"d}nt          | t          j        ¦  «        rd}nd}t          ||¦  «        S )Nr(   Úbuiltin_function_or_methodr1   Úmethod)	Ú
isinstancer   ÚLambdaÚFunctionDefÚrootÚnamer   ÚBoundMethodr0   )r1   r(   r&   s      r$   Ú_function_typer<   -   sv   € õ �(�\Ô0µ,Ô2JÐKÑLÔLð Ø�=Š=‰?Œ?Ô :Ò-Ð-Ø3ˆHˆHà!ˆHˆHÝ	�H�eÔ/Ñ	0Ô	0ð ØˆˆàˆÝ˜h¨Ñ1Ô1Ð1r%   r   ú-Generator[InferenceResult | None, None, None]c              #  ód  K  — t          j        ¦   «         }|j        }|pt          ¦   «         }|                      |¬¦  «        D �]k}t          |t          j        ¦  «        rB|j        r| 	                    |¬¦  «        }|r|V — ŒA| 
                    d¦  «        d         V — Œ_t          |t          j        t          j        t          j        f¦  «        rt          ||¦  «        V — Œ£t          |t          j        ¦  «        rt#          d|¦  «        V — ŒÐt          |t$          j        ¦  «        rt(          ‚t          |t*          j        ¦  «        r|V — �Œt          |t          j        t$          j        t2          j        f¦  «        r|j        V — �ŒMt9          dt;          |¦  «        › d�¦  «        ‚d S )Nr   Útyper   ÚmodulezWe don't handle z
 currently)r   ÚAstroidManagerÚbuiltins_moduler   Úinferr6   r   ÚClassDefÚnewstyleÚ	metaclassÚgetattrr7   r   ÚUnboundMethodr8   r<   ÚModuler0   r   ÚUnknownr   r
   ÚUninferableBaseÚProxyÚSlicer   ÚSuperÚ_proxiedÚAssertionErrorr?   )r   r   Úastroid_managerr(   ÚinferredrF   s         r$   Ú_object_typerS   =   sÈ  è è € õ Ô,Ñ.Ô.€OØÔ.€HØÐ+Õ)Ñ+Ô+€Gà—J’J w�JÑ/Ô/ð Pñ PˆÝ�h¥Ô 5Ñ6Ô6ð 	PØÔ ð Ø$×.Ò.°wÐ.Ñ?Ô?�	Øð Ø#�O�O�OØØ×"Ò" 6Ñ*Ô*¨1Ô-Ð-Ð-Ð-Ð-ÝØÝÔ ¥%Ô"5µ|Ô7OÐPñ
ô 
ð 	Põ ! ¨8Ñ4Ô4Ð4Ð4Ð4Ð4Ý˜¥,Ô"5Ñ6Ô6ð 		PÝ$ X¨xÑ8Ô8Ð8Ð8Ð8Ð8Ý˜¥%¤-Ñ0Ô0ð 	PÝ Ð Ý˜¥$Ô"6Ñ7Ô7ð 	PØˆNˆNˆN‰NÝ˜¥5¤;µ´½W¼]Ð"KÑLÔLð 	PØÔ#Ð#Ð#Ð#Ñ#å Ð!NµD¸±N´NÐ!NÐ!NÐ!NÑOÔOÐOð-Pð Pr%   c                óò   — 	 t          t          | |¦  «        ¦  «        }n# t          $ r t          j        cY S w xY wt          |¦  «        dk    s|st          j        S t          t          |¦  «        ¦  «        S )aV  Obtain the type of the given node.

    This is used to implement the ``type`` builtin, which means that it's
    used for inferring type calls, as well as used in a couple of other places
    in the inference.
    The node will be inferred first, so this function can support all
    sorts of objects, as long as they support inference.
    é   )ÚsetrS   r   r
   ÚUninferableÚlenÚnextÚiter)r   r   Útypess      r$   Úobject_typer\   ]   sz   € ð Ý•L  wÑ/Ô/Ñ0Ô0ˆˆøÝð  ð  ð  ÝÔÐÐÐð øøøå
ˆ5�z„z�A‚~€~˜U€~ÝÔÐÝ•�U‘”ÑÔÐs   ‚   9¸9Úobj_typeÚclass_or_seqúlist[InferenceResult]úutil.UninferableBase | boolc                ó<  — t          | t          j        ¦  «        st          | t          j        ¦  «        st          j        S d„ |D ¦   «         }|D ]L}t          |t          j        ¦  «        rt          d¦  «        ‚|                      ¦   «         D ]}||k    r  dS ŒŒMdS )Nc                ó^   — g | ]*}t          |t          j        ¦  «        s|nt          j        ‘Œ+S © )r6   r   ÚInstancer
   rW   )Ú.0Úitems     r$   ú
<listcomp>z,_object_type_is_subclass.<locals>.<listcomp>}   s@   € ð ð ð àõ ˜t¥U¤^Ñ4Ô4ÐJˆˆ½$Ô:Jðð ð r%   z&arg 2 must be a type or tuple of typesTF)r6   r
   rK   r   rD   rW   r   Úmro)r]   r^   r   Ú	class_seqÚklassÚobj_subclasss         r$   Ú_object_type_is_subclassrl   r   sÌ   € õ
 �(�DÔ0Ñ1Ô1ð  ½Ø•%”.ñ:ô :ð  õ ÔÐðð à ðñ ô €Ið ð ð ˆÝ�e�TÔ1Ñ2Ô2ð 	MÝ"Ð#KÑLÔLÐLà$ŸLšL™NœNð 	ð 	ˆLØ˜uÒ$Ð$Ø�t�t�tð %ð	ð ˆ5r%   c                ó’   — t          | |¦  «        }t          |t          j        ¦  «        rt          j        S t          |||¬¦  «        S )zˆCheck if a node 'isinstance' any node in class_or_seq.

    :raises AstroidTypeError: if the given ``classes_or_seq`` are not types
    r   )r\   r6   r
   rK   rW   rl   )r   r^   r   r]   s       r$   Úobject_isinstancern   Ž   sF   € õ ˜4 Ñ)Ô)€HÝ�(�DÔ0Ñ1Ô1ð  ÝÔÐÝ# H¨lÀGÐLÑLÔLÐLr%   únodes.NodeNGc                ó~   — t          | t          j        ¦  «        st          | › d�¦  «        ‚t	          | ||¬¦  «        S )zþCheck if a type is a subclass of any node in class_or_seq.

    :raises AstroidTypeError: if the given ``classes_or_seq`` are not types
    :raises AstroidError: if the type of the given node cannot be inferred
        or its type's mro doesn't work
    z needs to be a ClassDef noder   )r6   r   rD   Ú	TypeErrorrl   )r   r^   r   s      r$   Úobject_issubclassrr   �   sD   € õ �d�EœNÑ+Ô+ð ?Ý˜4Ð=Ð=Ð=Ñ>Ô>Ð>Ý# D¨,ÀÐHÑHÔHÐHr%   Úboolc                óì   — 	 | j         S # t          $ r Y nw xY w| j        D ]L}t          ||¬¦  «        }t	          |t
          j        ¦  «        r|| u st          ||¬¦  «        s
d| _          dS ŒMd| _         dS )z=Return whether all base classes of a class could be inferred.r   FT)Ú_all_bases_knownÚAttributeErrorr   r"   r6   r   rD   Úhas_known_bases)rj   r   ÚbaseÚresults       r$   rw   rw   ­   s­   € ðØÔ%Ð%øÝð ð ð Øˆðøøøà”ð 	ð 	ˆÝ  ¨wÐ7Ñ7Ô7ˆõ ˜6¥<Ô#8Ñ9Ô9ð	à˜ˆˆÝ" 6°7Ð;Ñ;Ô;ð ð &+ˆEÔ"Ø�5�5ð	 ð
 "€EÔØˆ4s   ‚	 ‰
•c                ó  — t          t          t          | |f¦  «        ¦  «        st          ‚t          | j        |j        g¦  «        sdS 	 | |                     ¦   «         d d…         v S # t          $ r}t          |‚d }~ww xY w)NFéÿÿÿÿ)ÚallÚmaprw   r   rE   rh   r   )Útype1Útype2Úes      r$   Ú_type_checkr�   Á   sŒ   € Ý�s•? U¨E NÑ3Ô3Ñ4Ô4ð )Ý(Ð(å�” ¤Ð/Ñ0Ô0ð Øˆuð0Ø˜Ÿ	š	™œ C R CÔ(Ð(Ð(øÝð 0ð 0ð 0å(¨aÐ/øøøøð0øøøs   Á
A( Á(
A?Á2A:Á:A?c                ó$   — t          || ¬¦  «        S )z)Check if *type1* is a subtype of *type2*.©r~   r   ©r�   rƒ   s     r$   Ú
is_subtyper…   Î   s   € å˜U¨%Ð0Ñ0Ô0Ð0r%   c                ó"   — t          | |¦  «        S )z+Check if *type2* is a supertype of *type1*.r„   rƒ   s     r$   Úis_supertyper‡   Ó   s   € å�u˜eÑ$Ô$Ð$r%   úbases.Instanceúnodes.Const | Nonec                ó’  — t          ¦   «         }	 |                      d|¬¦  «        D ]Ž}t          |t          j        ¦  «        sŒ| |_        t          g |¬¦  «        |_        |                     | |¬¦  «        D ]<}t          |t          j
        ¦  «        r t          |j        t          ¦  «        r|c c S Œ=Œ�n# t          $ r Y nw xY wdS )zêGet the value as an index for the given instance.

    If an instance provides an __index__ method, then it can
    be used in some scenarios where an integer is expected,
    for instance when multiplying or subscripting a list.
    Ú	__index__r   )ÚargsÚcalleeN)r   Úigetattrr6   r   r;   Ú	boundnoder   ÚcallcontextÚinfer_call_resultr   ÚConstÚvalueÚintr   )r   r   rR   ry   s       r$   Úclass_instance_as_indexr•   Ø   sñ   € õ Ñ Ô €GðØŸš k¸7˜ÑCÔCð 	"ð 	"ˆHÝ˜h­Ô(9Ñ:Ô:ð Øà $ˆGÔÝ"-°2¸hÐ"GÑ"GÔ"GˆGÔØ"×4Ò4°TÀ7Ð4ÑKÔKð "ð "�Ý˜f¥e¤kÑ2Ô2ð "µzÀ&Ä,ÕPSÑ7TÔ7Tð "Ø!�M�M�M�M�Møð"ð	"øõ ð ð ð Øˆðøøøàˆ4s   �B#B7 Â4B7 Â7
CÃCc                óL  — ddl m} t          | |¬¦  «        }|                      ¦   «         }t	          |t
          j        ¦  «        rv|j        dk    rkt	          |t          j	        ¦  «        rQ|j
        |j        k    rAd                     | j        |                      ¦   «         j        ¦  «        }t!          |¦  «        ‚|�t	          |t"          j        ¦  «        rt!          | ¬¦  «        ‚t	          |t&          j        ¦  «        r5t	          |j        t,          t.          f¦  «        rt1          |j        ¦  «        S t	          |t&          j        t&          j        t&          j        |f¦  «        rt1          |j        ¦  «        S t	          |t&          j        ¦  «        rt1          |j        ¦  «        S t?          ||¬¦  «        }|st!          | ¬¦  «        ‚	 tA          | !                    d|¬¦  «        ¦  «        }nb# tD          $ r"}tG          t/          |¦  «        ¦  «        |‚d}~wtH          $ r+}tG          d| %                    ¦   «         › d	�¦  «        |‚d}~ww xY w| &                    | |¦  «        }	t	          |	t"          j        ¦  «        rt!          | |¬
¦  «        ‚tA          |	d¦  «        }
t	          |
t&          j        ¦  «        r|
 %                    ¦   «         dk    r|
j        S |
�/t	          |
t          j'        ¦  «        r|
 (                    d¦  «        rdS tG          d|
› d�¦  «        ‚)að  Infer length of given node object.

    :param Union[nodes.ClassDef, nodes.Instance] node:
    :param node: Node to infer length of

    :raises AstroidTypeError: If an invalid node is returned
        from __len__ method or no __len__ method exists
    :raises InferenceError: If the given node cannot be inferred
        or if multiple nodes are inferred or if the code executed in python
        would result in a infinite recursive check for length
    :rtype int: Integer length of node
    r   )Ú	FrozenSetr   Ú__len__zNSelf referential __len__ function will cause a RecursionError on line {} of {}N)r   zobject of type 'z' has no len()r#   zbuiltins.intú'z,' object cannot be interpreted as an integer))Úastroid.objectsr—   r"   Úframer6   r   r8   r:   r   rL   rO   r.   ÚformatÚlinenor9   Úfiler   r
   rK   r   r’   r“   Úbytesr'   rX   ÚListÚSetÚTupleÚeltsÚDictÚitemsr\   rY   rŽ   ÚStopIterationr   r   Úpytyper‘   rd   Úis_subtype_of)r   r   r—   Úinferred_nodeÚ
node_frameÚmessageÚ	node_typeÚlen_callr€   rR   Úresult_of_lens              r$   Ú
object_lenr¯   ï   s"  € ð *Ð)Ð)Ð)Ð)Ð)å# D°'Ð:Ñ:Ô:€Mð —’‘”€Jå�:�|Ô7Ñ8Ô8ð&àŒO˜yÒ(Ð(Ý�}¥e¤kÑ2Ô2ð )àÔ" jÔ&7Ò7Ð7ð6ß6<²fØ”˜TŸYšY™[œ[Ô-ñ7ô 7ð 	õ ˜WÑ%Ô%Ð%àÐ¥
¨=½$Ô:NÑ OÔ OÐÝ $Ð'Ñ'Ô'Ð'Ý�-¥¤Ñ-Ô-ð (µ*ØÔ�e¥S˜\ñ3ô 3ð (õ �=Ô&Ñ'Ô'Ð'Ý�-¥%¤*­e¬i½¼ÀiÐ!PÑQÔQð 'Ý�=Ô%Ñ&Ô&Ð&Ý�-¥¤Ñ,Ô,ð (Ý�=Ô&Ñ'Ô'Ð'å˜M°7Ð;Ñ;Ô;€IØð (Ý $Ð'Ñ'Ô'Ð'ðÝ˜	×*Ò*¨9¸gÐ*ÑFÔFÑGÔGˆˆøÝð .ð .ð .Ý�s 1™vœvÑ&Ô&¨AÐ-øøøøÝ"ð ð ð ÝØA˜y×/Ò/Ñ1Ô1ÐAÐAÐAñ
ô 
àð	øøøøðøøøð
 ×)Ò)¨$°Ñ8Ô8€HÝ�(�DÔ0Ñ1Ô1ð 9Ý $°Ð8Ñ8Ô8Ð8Ý˜ 4Ñ(Ô(€Må�=¥%¤+Ñ.Ô.ð#à× Ò Ñ"Ô" nÒ4Ð4àÔ"Ð"àÐÝ�m¥U¤^Ñ4Ô4ð 	à×'Ò'¨Ñ7Ô7ð 	ð
 ˆqÝ
ØGˆMÐGÐGÐGñô ð s$   Ç$G4 Ç4
IÇ>HÈIÈ(&IÉIúnodes.FunctionDef | Nonec                óÐ   — | }|j         rLt          |j         t          j        ¦  «        s-|j         }|j         rt          |j         t          j        ¦  «        ¯-|r|j         r|j         S dS )a«  Search for the first function which encloses the given
    scope.

    This can be used for looking up in that function's
    scope, in case looking up in a lower scope for a particular
    name fails.

    :param node: A scope node.
    :returns:
        ``None``, if no parent function scope was found,
        otherwise an instance of :class:`astroid.nodes.scoped_nodes.Function`,
        which encloses the given node.
    N)r.   r6   r   r8   )r   Úcurrents     r$   Ú_higher_function_scoper³   ?  sp   € ð €GØ
Œ.ð !¥¨G¬N½EÔ<MÑ!NÔ!Nð !Ø”.ˆð Œ.ð !¥¨G¬N½EÔ<MÑ!NÔ!Nð !àð �7”>ð ØŒ~ÐØˆ4r%   r,   )r   r   r   r   r   r   )r&   r'   r(   r)   r   r*   )r1   r2   r(   r)   r   r*   )r   r   r   r   r   r=   )r   r   r   r   r   r   )r]   r   r^   r_   r   r   r   r`   )r   r   r^   r_   r   r   r   r`   )r   ro   r^   r_   r   r   r   r`   )r   r   r   rs   )r   rs   )r   rˆ   r   r‰   )r   r   )r   ro   r   r°   )+Ú__doc__Ú
__future__r   r   Úcollections.abcr   Úastroidr   r   r   r   r	   r
   Úastroid.contextr   r   Úastroid.exceptionsr   r   r   r   r   Úastroid.nodesr   Úastroid.typingr   Úastroid.utilr   r"   r0   r<   rS   r\   rl   rn   rr   rw   r�   r…   r‡   r•   r¯   r³   rc   r%   r$   ú<module>r½      s”  ðð
  Ð à "Ð "Ð "Ð "Ð "Ð "à €€€Ø %Ð %Ð %Ð %Ð %Ð %à FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 'Ð &Ð &Ð &Ð &Ð &Ø *Ð *Ð *Ð *Ð *Ð *Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6ð
 (,ð
2ð 
2ð 
2ð 
2ð 
2ðð ð ð ð2ð 2ð 2ð 2ð" ?CðPð Pð Pð Pð PðB ?Cðð ð ð ð ð0 (,ðð ð ð ð ð> (,ðMð Mð Mð Mð Mð$ (,ðIð Ið Ið Ið Ið ð ð ð ð ð(
0ð 
0ð 
0ð 
0ð1ð 1ð 1ð 1ð
%ð %ð %ð %ð
ð ð ð ð.Mð Mð Mð Mð Mð`ð ð ð ð ð r%   