Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/astroid/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/astroid/__pycache__/context.cpython-37.pyc

B

��\,�@s\dZddlZddlZddlmZGdd�d�ZGdd�d�Zeeed�d	d
�Zdd�ZdS)
zIVarious context related utilities, including inference and call contexts.�N)�Optionalc@sLeZdZdZdZddd�Zdd�Zdd	�Zd
d�Ze	j
dd
��Zdd�ZdS)�InferenceContextz�Provide context for inference

    Store already inferred nodes to save time
    Account for already visited nodes to infinite stop infinite recursion
    )�path�
lookupname�callcontext�	boundnode�inferred�
extra_contextNcCs2|pt�|_d|_d|_d|_|p$i|_i|_dS)N)�setrrrrrr	)�selfrr�r�@/opt/alt/python37/lib/python3.7/site-packages/astroid/context.py�__init__s

zInferenceContext.__init__cCs,|j}||f|jkrdS|j�||f�dS)z�Push node into inference path

        :return: True if node is already in context path else False
        :rtype: bool

        Allows one to see if the given node has already
        been looked at for this inference contextTF)rr�add)r�node�namerrr
�pushPs
zInferenceContext.pushcCs,t|j|jd�}|j|_|j|_|j|_|S)z�Clone inference path

        For example, each side of a binary operation (BinOp)
        starts with the same context but diverge as each side is inferred
        so the InferenceContext will need be cloned)r)rrrrrr	)r�clonerrr
r_s
zInferenceContext.cloneccs4g}x|D]}|�|�|Vq
Wt|�|j|<dS)zRCache result of generator into dictionary

        Used to cache inference resultsN)�append�tupler)r�key�	generator�results�resultrrr
�cache_generatorls



z InferenceContext.cache_generatorccst|j�}dV||_dS)N)r
r)rrrrr
�restore_pathws
zInferenceContext.restore_pathcs,�fdd��jD�}dt��jd�|�fS)Nc3s2|]*}d|tjt�|�dt|�d�fVqdS)z%s=%s�P)�widthN)�pprint�pformat�getattr�len)�.0�field)rrr
�	<genexpr>sz+InferenceContext.__str__.<locals>.<genexpr>z%s(%s)z,
    )�	__slots__�type�__name__�join)r�stater)rr
�__str__}s

zInferenceContext.__str__)NN)
r'�
__module__�__qualname__�__doc__r%rrrr�
contextlib�contextmanagerrr*rrrr
rs
1
rc@seZdZdZdZddd�ZdS)�CallContextz"Holds information for a call site.)�args�keywordsNcCs(||_|rdd�|D�}ng}||_dS)z�
        :param List[NodeNG] args: Call positional arguments
        :param Union[List[nodes.Keyword], None] keywords: Call keywords
        cSsg|]}|j|jf�qSr)�arg�value)r"r3rrr
�
<listcomp>�sz(CallContext.__init__.<locals>.<listcomp>N)r1r2)rr1r2rrr
r�s
zCallContext.__init__)N)r'r+r,r-r%rrrrr
r0�sr0)�context�returncCs|dk	r|��St�S)z4Clone a context if given, or return a fresh contexxtN)rr)r6rrr
�copy_context�sr8cCst|�}||_|S)a�Give a context a boundnode
    to retrieve the correct function name or attribute value
    with from further inference.

    Do not use an existing context since the boundnode could then
    be incorrectly propagated higher up in the call stack.

    :param context: Context to use
    :type context: Optional(context)

    :param node: Node to do name lookups from
    :type node NodeNG:

    :returns: A new context
    :rtype: InferenceContext
    )r8r)r6rrrr
�bind_context_to_node�sr9)	r-r.r�typingrrr0r8r9rrrr
�<module>	sw