B
    a                 @   s~   d dl 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S )    Nc             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   0/tmp/pip-unpacked-wheel-mm06h1t3/astroid/util.pyr      s    z0lazy_descriptor.<locals>.DescriptorProxy.__get__)N)__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>       zlazy_import.<locals>.<lambda>)r   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   s   dS )Nr   r   )r   r   r   r   __repr__%   s    zUninferable.__repr__c             C   sH   |dkrt d|dr0|dr0t| |S |dkrDt| |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 )Nr   )r   argskwargsr   r   r   __call__3   s    zUninferable.__call__c             C   s   dS )NFr   )r   r   r   r   __bool__6   s    zUninferable.__bool__c             C   s
   | | S )N)Zvisit_uninferable)r   Zvisitorr   r   r   r   ;   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   r'   r   r   r   r   r*   ?   s   r*   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 )N)operandoperror)r   r,   r-   r.   r   r   r   __init__J   s    z!BadUnaryOperationMessage.__init__c             C   s   t d}|jS )Nhelpers)r   object_type)r   r0   r   r   r   _object_type_helperO   s    z,BadUnaryOperationMessage._object_type_helperc             C   s   |  |}|tkrd S |S )N)r2   r   )r   r   Zobjtyper   r   r   _object_typeT   s    
z%BadUnaryOperationMessage._object_typec             C   sN   t | jdr| jj}n&| | j}t |dr4|j}n| }d}|| j|S )Nr"   z!bad operand type for unary {}: {})hasattrr,   r"   r3   	as_stringformatr-   )r   Zoperand_typer1   msgr   r   r   r(   [   s    

z BadUnaryOperationMessage.__str__N)	r	   r
   r   r'   r/   propertyr2   r3   r(   r   r   r   r   r+   G   s
   r+   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 )N)	left_type
right_typer-   )r   r:   r-   r;   r   r   r   r/   m   s    z"BadBinaryOperationMessage.__init__c             C   s   d}| | j| jj| jjS )Nz1unsupported operand type(s) for {}: {!r} and {!r})r6   r-   r:   r"   r;   )r   r7   r   r   r   r(   r   s    z!BadBinaryOperationMessage.__str__N)r	   r
   r   r'   r/   r(   r   r   r   r   r9   j   s   r9   c             C   s@   | j }|j}||k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   _instancecheckw   s    rF   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 )Nr   r   )	node_typer   r   r      r   zproxy_alias.<locals>.<lambda>)typer   r   r    __dict__rF   )Z
alias_namerH   proxyr   )rH   r   proxy_alias   s    
rL   )r   r@   r   r   r   r    __new__r   r*   r+   r9   rF   rL   r   r   r   r   <module>   s   #