
    7g                        U d dl mZ d dlZd dlmZmZmZmZ d dlm	Z	 erd dl
mZmZ d dlmZ d dlmZ  G d d	      Z e       Zd
ed<    G d d      Z G d de      Z G d de      ZddZddZ	 d	 	 	 	 	 ddZy)    )annotationsN)TYPE_CHECKINGAnyFinalLiteral)InferenceError)basesnodes)InferenceContext)InferenceResultc                  >    e Zd ZdZddZeZd	dZd
dZddZeZ	d Z
y)UninferableBasezSpecial inference object, which is returned when inference fails.

    This is meant to be used as a singleton. Use astroid.util.Uninferable to access it.
    c                     y)NUninferable selfs    ,lib/python3.12/site-packages/astroid/util.py__repr__zUninferableBase.__repr__   s        c                    |dk(  rt        d      |j                  d      r'|j                  d      rt        j	                  | |      S |dk(  rt        j	                  | |      S | S )Nnextz next method should not be called__accept)AttributeError
startswithendswithobject__getattribute__)r   names     r   r   z UninferableBase.__getattribute__   s_    6> !CDD??4 T]]4%8**4668**466r   c                    | S Nr   )r   argskwargss      r   __call__zUninferableBase.__call__'   s    r   c                     y)NFr   r   s    r   __bool__zUninferableBase.__bool__*   s    r   c                $    |j                  |       S r"   )visit_uninferable)r   visitors     r   r   zUninferableBase.accept/   s    ((..r   N)returnzLiteral['Uninferable'])r    strr+   r   )r#   r   r$   r   r+   r   )r+   zLiteral[False])__name__
__module____qualname____doc__r   __str__r   r%   r'   __nonzero__r   r   r   r   r   r      s.    
 G K/r   r   r   r   c                      e Zd ZdZy)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   r4   r4   6   s    r   r4   c                  4    e Zd ZdZd Zed        Zd ZddZy)BadUnaryOperationMessagez8Object which describes operational failures on UnaryOps.c                .    || _         || _        || _        y r"   )operandoperror)r   r8   r9   r:   s       r   __init__z!BadUnaryOperationMessage.__init__A   s    
r   c                &    ddl m} |j                  S )Nr   )helpers)astroidr=   object_type)r   r=   s     r   _object_type_helperz,BadUnaryOperationMessage._object_type_helperF   s    #"""r   c                J    | j                  |      }t        |t              ry |S r"   )r@   
isinstancer   )r   objobjtypes      r   _object_typez%BadUnaryOperationMessage._object_typeL   s$    **3/g/r   c                    t        | j                  d      r| j                  j                  }nD| j                  | j                        }t        |d      r|j                  }n|j	                         }d}|j                  | j                  |      S )Nr    z!bad operand type for unary {}: {})hasattrr8   r    rE   	as_stringformatr9   )r   operand_typer?   msgs       r   r1   z BadUnaryOperationMessage.__str__S   sr    4<<(<<,,L++DLL9K{F+*//  +4461zz$''<00r   Nr+   r,   )	r-   r.   r/   r0   r;   propertyr@   rE   r1   r   r   r   r6   r6   >   s(    B
 # #
1r   r6   c                      e Zd ZdZd ZddZy)BadBinaryOperationMessagez.Object which describes type errors for BinOps.c                .    || _         || _        || _        y r"   )	left_type
right_typer9   )r   rQ   r9   rR   s       r   r;   z"BadBinaryOperationMessage.__init__e   s    "$r   c                    d}|j                  | j                  | j                  j                  | j                  j                        S )Nz1unsupported operand type(s) for {}: {!r} and {!r})rI   r9   rQ   r    rR   )r   rK   s     r   r1   z!BadBinaryOperationMessage.__str__j   s2    Azz$''4>>#6#68L8LMMr   NrL   )r-   r.   r/   r0   r;   r1   r   r   r   rO   rO   b   s    8
Nr   rO   c                    | j                   }|j                  }||u xs t        ||      }t        j                  | j                  j
                  d|j
                  dt        d       |S )Nz: is deprecated and slated for removal in astroid 2.0, use z instead   )
stacklevel)__wrapped__	__class__
issubclasswarningswarnr-   PendingDeprecationWarning)clsotherwrapped	other_clsis_instance_ofs        r   _instancecheckrb   o   s_    ooGI	)KZ	7-KNMM!$!7!79I9I	K!	 r   c                 B    t        d t        j                  D              S )zReturn True if any other than the default DeprecationWarning filter is enabled.

    https://docs.python.org/3/library/warnings.html#default-warning-filter
    c              3  j   K   | ]+  }t        t        |d          xr |d   dk7  xr |d   dk7   - yw)rU   r   ignore   __main__N)rY   DeprecationWarning).0filters     r   	<genexpr>z(check_warnings_filter.<locals>.<genexpr>   sO       'F 	%vay1 	$1I!	$1I#	$ 's   13)anyrZ   filtersr   r   r   check_warnings_filterrn   |   s&    
   &&	  r   c                    t        | t              r| S 	 | j                  |      }t        |      }	 t        |       y# t        t
        f$ r Y yw xY w# t        $ r Y yt
        $ r |cY S w xY w)zReturn 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).
    )contextN)rB   r   inferr   r   StopIteration)noderp   inferitvalues       r   
safe_inferrv      sy     $(**W*-WW	 M* 
   s&   > A AA	A+
A+*A+)r+   boolr"   )rs   z,nodes.NodeNG | bases.Proxy | UninferableBaserp   zInferenceContext | Noner+   zInferenceResult | None)
__future__r   rZ   typingr   r   r   r   astroid.exceptionsr   r>   r	   r
   astroid.contextr   astroid.typingr   r   r   __annotations__r4   r6   rO   rb   rn   rv   r   r   r   <module>r~      s    #  5 5 -$0./ /@ %&U & !12 !1H
N 3 
N

 (,
6$ r   