o
    b                     @   s   d dl Z d dlmZ d dlZd dlZdd Zdd ZejG dd dZ	G d	d
 d
Z
G dd de
ZG dd de
Zdd Zdd Zdd ZdS )    N)islicec                 C   s   G dd dt j}|| S )Nc                   @   s   e Zd ZdddZdS )z(lazy_descriptor.<locals>.DescriptorProxyNc                 S   s   | j | |S N)	__class____get__)selfinstanceowner r	   K/var/www/secure340b-portal/env/lib/python3.10/site-packages/astroid/util.pyr      s   z0lazy_descriptor.<locals>.DescriptorProxy.__get__r   )__name__
__module____qualname__r   r	   r	   r	   r
   DescriptorProxy   s    r   lazy_object_proxyProxy)objr   r	   r	   r
   lazy_descriptor   s   r   c                    s   t  fddS )Nc                      s   t d  dS )N.Zastroid)	importlibimport_moduler	   module_namer	   r
   <lambda>   s    zlazy_import.<locals>.<lambda>r   r   r	   r   r
   lazy_import   s   
r   c                   @   s@   e Zd ZdZdd ZeZdd Zdd Zdd	 ZeZ	d
d Z
dS )UninferablezASpecial inference object, which is returned when inference fails.c                 C      dS )Nr   r	   r   r	   r	   r
   __repr__"      zUninferable.__repr__c                 C   sH   |dkrt d|dr|drt| |S |dkr"t| |S | S )Nnextz next method should not be called__accept)AttributeError
startswithendswithobject__getattribute__)r   namer	   r	   r
   r'   '   s   zUninferable.__getattribute__c                 O   s   | S r   r	   )r   argskwargsr	   r	   r
   __call__0   r   zUninferable.__call__c                 C   r   )NFr	   r   r	   r	   r
   __bool__3   r   zUninferable.__bool__c                 C   s   t |d}|| S )NZvisit_uninferable)getattr)r   visitorfuncr	   r	   r
   r"   8   s   
zUninferable.acceptN)r   r   r   __doc__r   __str__r'   r+   r,   __nonzero__r"   r	   r	   r	   r
   r      s    	r   c                   @   s   e Zd ZdZdS )BadOperationMessagezObject which describes a TypeError occurred somewhere in the inference chain

    This is not an exception, but a container object which holds the types and
    the error which occurred.
    N)r   r   r   r0   r	   r	   r	   r
   r3   =   s    r3   c                   @   s4   e Zd ZdZdd Zedd Zdd Zdd	 Zd
S )BadUnaryOperationMessagez8Object which describes operational failures on UnaryOps.c                 C   s   || _ || _|| _d S r   )operandoperror)r   r5   r6   r7   r	   r	   r
   __init__H      
z!BadUnaryOperationMessage.__init__c                 C   s   t d}|jS )Nhelpers)r   object_type)r   r:   r	   r	   r
   _object_type_helperM   s   z,BadUnaryOperationMessage._object_type_helperc                 C   s   |  |}|tu rd S |S r   )r<   r   )r   r   objtyper	   r	   r
   _object_typeR   s   
z%BadUnaryOperationMessage._object_typec                 C   sN   t | jdr| jj}n| | j}t |dr|j}n| }d}|| j|S )Nr(   z!bad operand type for unary {}: {})hasattrr5   r(   r>   	as_stringformatr6   )r   Zoperand_typer;   msgr	   r	   r
   r1   Z   s   

z BadUnaryOperationMessage.__str__N)	r   r   r   r0   r8   propertyr<   r>   r1   r	   r	   r	   r
   r4   E   s    
r4   c                   @   s    e Zd ZdZdd Zdd ZdS )BadBinaryOperationMessagez.Object which describes type errors for BinOps.c                 C   s   || _ || _|| _d S r   )	left_type
right_typer6   )r   rE   r6   rF   r	   r	   r
   r8   l   r9   z"BadBinaryOperationMessage.__init__c                 C   s   d}| | j| jj| jjS )Nz1unsupported operand type(s) for {}: {!r} and {!r})rA   r6   rE   r(   rF   )r   rB   r	   r	   r
   r1   q   s   z!BadBinaryOperationMessage.__str__N)r   r   r   r0   r8   r1   r	   r	   r	   r
   rD   i   s    rD   c                 C   s@   | j }|j}||u pt||}tjd| jj|jf tdd |S )NzF%r is deprecated and slated for removal in astroid 2.0, use %r instead   )
stacklevel)__wrapped__r   
issubclasswarningswarnr   PendingDeprecationWarning)clsotherwrappedZ	other_clsZis_instance_ofr	   r	   r
   _instancecheckv   s   rQ   c                    s,   t | tjftjd td}| fddS )z7Get a Proxy from the given name to the given node type.r   )r   __instancecheck__c                      s    S r   r	   r	   	node_typer	   r
   r      s    zproxy_alias.<locals>.<lambda>)typer   r   r&   __dict__rQ   )Z
alias_namerT   proxyr	   rS   r
   proxy_alias   s   rX   c                 c   s2    t | |E dH  t| d}|durtV  dS dS )a  Limit inference amount.

    Limit inference amount to help with performance issues with
    exponentially exploding possible results.

    :param iterator: Inference generator to limit
    :type iterator: Iterator(NodeNG)

    :param size: Maximum mount of nodes yielded plus an
        Uninferable at the end if limit reached
    :type size: int

    :yields: A possibly modified generator
    :rtype param: Iterable
    NF)r   r    r   )iteratorsizeZhas_morer	   r	   r
   limit_inference   s   
r[   )rK   	itertoolsr   r   r   r   r   r&   __new__r   r3   r4   rD   rQ   rX   r[   r	   r	   r	   r
   <module>   s   $