Your IP : 216.73.216.160
�
�hH,���dZddlmZddlmZddlmZmZmZm Z m
Z
mZddlm
Z
mZddlmZmZmZmZmZddlmZddlmZmZd)d�Zd*d�Z d+d,d�Z d+d-d�Z d+d.d�Zd+d.d�Zd+d.d�Z d+d/d �Z!d+d0d"�Z"d1d#�Z#d1d$�Z$d1d%�Z%d2d'�Z&d+d.d(�Z'dS)3zVarious helper utilities.�)�annotations)� Generator)�bases�manager�nodes�objects�raw_building�util)�CallContext�InferenceContext)�AstroidTypeError�AttributeInferenceError�InferenceError�MroError�_NonDeducibleTypeHierarchy)�scoped_nodes)�InferenceResult�SuccessfulInferenceResult�cls_name�str�builtins�nodes.Module�return�nodes.ClassDefc�<�tj|��}||_|S�N)r �build_class�parent)rr�proxys �`/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/astroid/helpers.py�_build_proxy_classr!s���$�X�.�.�E��E�L��L��function�"nodes.Lambda | bases.UnboundMethodc���t|tj��r#|���jdkrd}n"d}nt|t
j��rd}nd}t||��S)Nr�builtin_function_or_methodr#�method)�
isinstancer�Lambda�root�namer�BoundMethodr!)r#rrs r �_function_typer-sn���(�L�/�0�0���=�=�?�?��:�-�-�3�H�H�!�H�H� �H�e�/� 0� 0��������h��1�1�1r"N�noder�context�InferenceContext | None�-Generator[InferenceResult | None, None, None]c#�NK�tj��}|j}|p
t��}|�|���D�]`}t|tj��rB|jr|� |���}|r|V��A|�
d��dV��_t|tjtj
f��rt||��V���t|tj��rt!d|��V���t|t"j��rt&�t|t(j��r|V���t|tjt"jt0jf��r|jV���Bt7dt9|���d����dS)N�r/�typer�modulezWe don't handle z
currently)r�AstroidManager�builtins_moduler�inferr(r�ClassDef�newstyle� metaclass�getattrr)r�
UnboundMethodr-�Moduler!r�Unknownrr
�UninferableBase�Proxy�Slicer�Super�_proxied�AssertionErrorr4)r.r/�astroid_managerr�inferredr;s r �_object_typerH-s������,�.�.�O��.�H��+�)�+�+�G��J�J�w�J�/�/�P�P���h�� 5�6�6� P�� �
�$�.�.�w�.�?�?� ���#�O�O�O���"�"�6�*�*�1�-�-�-�-�-�
��<�#6��8K�"L�
M�
M� 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�Pr"�InferenceResult | Nonec��� tt||����}n#t$rtjcYSwxYwt|��dks|stjSt
|��dS)aVObtain 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.
�r)�setrHrr
�Uninferable�len�list)r.r/�typess r �object_typerQJsv�� ��L��w�/�/�0�0����� � � ������ ����
�5�z�z�A�~�~�U�~������;�;�q�>�s� �9�9c�L�t|ttf��s|f}n|}t|tj��rtjSd�|D��}|D]L}t|tj��rt
d���|���D]}||krdS�
�MdS)Nc�^�g|]*}t|tj��s|ntj��+S�)r(r�Instancer
rM)�.0�items r �
<listcomp>z,_object_type_is_subclass.<locals>.<listcomp>ks@�������t�U�^�4�4�J���$�:J���r"z&arg 2 must be a type or tuple of typesTF)r(�tuplerOr
r@rMr
�mro)�obj_type�class_or_seqr/� class_seq�klass�obj_subclasss r �_object_type_is_subclassr`_s����l�U�D�M�2�2�!�!�O� � � � ��(�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|tj��rtjSt|||���S)z�Check if a node 'isinstance' any node in class_or_seq.
:param node: A given node
:param class_or_seq: Union[nodes.NodeNG, Sequence[nodes.NodeNG]]
:rtype: bool
:raises AstroidTypeError: if the given ``classes_or_seq`` are not types
r3)rQr(r
r@rMr`)r.r\r/r[s r �object_isinstancerb|sF���4��)�)�H��(�D�0�1�1� ����#�H�l�G�L�L�L�Lr"c�~�t|tj��st|�d����t |||���S)asCheck if a type is a subclass of any node in class_or_seq.
:param node: A given node
:param class_or_seq: Union[Nodes.NodeNG, Sequence[nodes.NodeNG]]
:rtype: bool
: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 noder3)r(rr9� TypeErrorr`)r.r\r/s r �object_issubclassre�sD���d�E�N�+�+�?��4�=�=�=�>�>�>�#�D�,��H�H�H�Hr"�nodes.NodeNG | bases.Proxyc��� |�|���}t|��}n#ttf$rYdSwxYw t|��dS#t$rYdSt$r|cYSwxYw)z�Return the inferred value for the given node.
Return None if inference failed or if there is some ambiguity (more than
one node has been inferred).
r3N)r8�nextr�
StopIteration)r.r/�inferit�values r �
safe_inferrl�s�����*�*�W�*�-�-���W�
�
�����M�*�����t�t�������W�
�
�
��t�������t�t������������s$�%(�=�=�A�
A-�A-�,A-�boolc��� |jS#t$rYnwxYw|jD]L}t||���}t |t
j��r||ust||���s
d|_dS�Md|_dS)z=Return whether all base classes of a class could be inferred.r3FT)�_all_bases_known�AttributeErrorrrlr(rr9�has_known_bases)r^r/�base�results r rqrq�s���
��%�%���
�
�
���
������ � ���D�'�2�2�2���6�<�#8�9�9� �����"�6�7�;�;�;��&+�E�"��5�5� �
"�E���4s� �
�c��ttt||f����st�t|j|jg��sdS ||���dd�vS#t$r
}t|�d}~wwxYw)NF���)�all�maprqrr:rZr)�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?�2A:�:A?c�$�t||���S)z)Check if *type1* is a subtype of *type2*.�rxry�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"�nodes.Const | Nonec��t��} |�d|���D]�}t|tj��s�||_t
g|���|_|�||���D]<}t|tj
��r t|jt��r|ccS�=��n#t$rYnwxYwdS)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__r3)�args�calleeN)r�igetattrr(rr,� boundnoder�callcontext�infer_call_resultr�Constrk�intr)r.r/rGrss 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�4B7�7
C�Cc�<�ddlm}t||���}|�d���}t |t
j��rl|jdkrat|d��rQ|j |j
krAd�|j|�
��j��}t|���|�t |t j��rt|�
���t |t$j��r5t |jt*t,f��rt/|j��St |t$jt$jt$j|f��rt/|j��St |t$j��rt/|j��St=||���}|st|�
��� t?|� d|�����}nb#tB$r"}tEt-|����|�d }~wtF$r+}tEd|�$���d���|�d }~wwxYw|�%||��} t | t j��rt||�
���t?| d ��}
t |
t$j��r|
�$��dkr|
jS|
�/t |
tLj'��r|
�(d��rdStEd|
�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)� FrozenSetr3T)�future�__len__rDzNSelf referential __len__ function will cause a RecursionError on line {} of {}N)r.zobject of type 'z' has no len())r.r/zbuiltins.int�'z,' object cannot be interpreted as an integer))�astroid.objectsr�rl�framer(r�FunctionDefr+�hasattrrDr�format�linenor*�filerr
r@rr�rk�bytesrrN�List�Set�Tuple�elts�Dict�itemsrQrhr�rir
r�pytyper�rrU�
is_subtype_of)r.r/r��
inferred_node�
node_frame�message� node_type�len_callrzrG�
result_of_lens r �
object_lenr��s&��*�)�)�)�)�)��t�W�5�5�5�M����4��(�(�J��:�|�7�8�8�&��O�y�(�(��M�:�.�.�
)��"�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$�$G,�,
I�6H�
I� &I�I)rrrrrr)r#r$rrrrr)r.rr/r0rr1)r.rr/r0rrI)r/r0)r.rfr/r0rrI)r/r0rrm)rrm)r.rrr�)(�__doc__�
__future__r�collections.abcr�astroidrrrrr r
�astroid.contextrr�astroid.exceptionsr
rrrr�
astroid.nodesr�astroid.typingrrr!r-rHrQr`rbrerlrqr{rr�r�r�rTr"r �<module>r�sg��
��"�"�"�"�"�"�%�%�%�%�%�%�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�9�9�9�9�9�9�9�9���������������'�&�&�&�&�&�E�E�E�E�E�E�E�E�����2�2�2�2� IM�P�P�P�P�P�<IM������,@D������:M�M�M�M�M�
I�
I�
I�
I�
I�"JN������,�����(
0�
0�
0�
0�1�1�1�1�
%�%�%�%�
����.M�M�M�M�M�M�Mr"
?>