
    yIf                        d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlmZ ddlmZmZ erdd	lmZ  ed
          Z G d dej                  Z G d de          ZdS )z4This module contains mixin classes for scoped nodes.    )annotations)TYPE_CHECKINGTypeVaroverload)ParentMissingError)_filter_stmts)_base_nodesscoped_nodes)builtin_lookup)InferenceResultSuccessfulInferenceResult)nodes_Tc                      e Zd ZU dZded<   	 d*dZd+d	Z	 d,d-dZ	 d,d-dZd.dZ	e	Z
d/dZe	 d0d1d            Zed2d            Zd3d4d Zd5d#Zd$ Zd% Zd& Zd' Zd6d)ZdS )7LocalsDictNodeNGzthis class provides locals handling common to Module, FunctionDef
    and ClassDef nodes, including a dict like interface for direct access
    to locals information
    z dict[str, list[InferenceResult]]localsreturnstrc                    | j         | j        S 	 | j                                                                          d| j         S # t          $ r
 | j        cY S w xY w)zGet the 'qualified' name of the node.

        For example: module.name, module.class.name ...

        :returns: The qualified name.
        :rtype: str
        N.)parentnameframeqnamer   selfs    T/var/www/piapp/venv/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/mixin.pyr   zLocalsDictNodeNG.qname!   sr     ;9	k''))//11??DI???! 	 	 	9	s   4A AAr   r   c                    | S )zThe first parent node defining a new scope.

        :returns: The first parent scope node.
        :rtype: Module or FunctionDef or ClassDef or Lambda or GenExpr
         r   s    r   scopezLocalsDictNodeNG.scope1   s	         r   node_base_nodes.LookupMixInr   offsetint+tuple[LocalsDictNodeNG, list[nodes.NodeNG]]c                    t           )a  Lookup where the given variable is assigned.

        :param node: The node to look for assignments up to.
            Any assignments after the given node are ignored.

        :param name: The name of the variable to find assignments for.

        :param offset: The line offset to filter statements up to.

        :returns: This scope node and the list of assignments associated to the
            given name according to the scope where it has been found (locals,
            globals or builtin).
        )NotImplementedError)r   r"   r   r$   s       r   scope_lookupzLocalsDictNodeNG.scope_lookup9   s
      "!r!   c                v   	 t          || j        |         | |          }n# t          $ r d}Y nw xY w|r| |fS | j        o| j                                        }|Rt          |t          j                  s|                    ||          S |j        o|j                                        }|Rt          |          S )z+XXX method for interfacing the scope lookupr   )
r   r   KeyErrorr   r    
isinstancer
   ClassDefr)   r   )r   r"   r   r$   stmtspscopes         r   _scope_lookupzLocalsDictNodeNG._scope_lookupK   s    	!$D(94HHEE 	 	 	EEE	 	; 4!2!2!4!4 fl&;<< 7**4666]<v}':':'<'<F   d###s     //stmtnodes.NodeNGNonec                b    | j                             |g                               |           dS )zDefine that the given name is declared in the given statement node.

        .. seealso:: :meth:`scope`

        :param name: The name that is being defined.

        :param stmt: The statement that defines the given name.
        N)r   
setdefaultappend)r   r   r1   s      r   	set_localzLocalsDictNodeNG.set_locala   s0     	tR((//55555r!   childc                H    | j                             |           | |_        dS )z&append a child, linking it in the treeN)bodyr6   r   )r   r8   s     r   _append_nodezLocalsDictNodeNG._append_nodeo   s%     		r!   .
child_nodenodes.ClassDef
str | Nonec                    d S Nr   r   r<   r   s      r   add_local_nodezLocalsDictNodeNG.add_local_nodex   s	     sr!   c                    d S r@   r   rA   s      r   rB   zLocalsDictNodeNG.add_local_node}   s    KN3r!   Nc                v    |dk    r|                      |           |                     |p|j        |           dS )zAppend a child that should alter the locals of this scope node.

        :param child_node: The child node that will alter locals.

        :param name: The name of the local that will be altered by
            the given child node.
        	__class__N)r;   r7   r   rA   s      r   rB   zLocalsDictNodeNG.add_local_node   sD     ;j)))t.z
;;;;;r!   itemr   c                (    | j         |         d         S )zThe first node the defines the given local.

        :param item: The name of the locally defined object.

        :raises KeyError: If the name is not defined.
        r   r   )r   rF   s     r   __getitem__zLocalsDictNodeNG.__getitem__   s     {4 ##r!   c                D    t          |                                           S )zIterate over the names of locals defined in this scoped node.

        :returns: The names of the defined locals.
        :rtype: iterable(str)
        )iterkeysr   s    r   __iter__zLocalsDictNodeNG.__iter__   s     DIIKK   r!   c                N    t          | j                                                  S )zThe names of locals defined in this scoped node.

        :returns: The names of the defined locals.
        :rtype: list(str)
        )listr   rL   r   s    r   rL   zLocalsDictNodeNG.keys   s      DK$$&&'''r!   c                D      fd                                  D             S )zThe nodes that define the locals in this scoped node.

        :returns: The nodes that define locals.
        :rtype: list(NodeNG)
        c                     g | ]
}|         S r   r   ).0keyr   s     r   
<listcomp>z+LocalsDictNodeNG.values.<locals>.<listcomp>   s    111cS	111r!   )rL   r   s   `r   valueszLocalsDictNodeNG.values   s'     2111TYY[[1111r!   c                    t          t          |                                 |                                                     S )zGet the names of the locals and the node that defines the local.

        :returns: The names of locals and their associated node.
        :rtype: list(tuple(str, NodeNG))
        )rO   ziprL   rU   r   s    r   itemszLocalsDictNodeNG.items   s,     C		T[[]]33444r!   boolc                    || j         v S )zCheck if a local is defined in this scope.

        :param name: The name of the local to check for.
        :type name: str

        :returns: Whether this node has a local of the given name,
        rH   )r   r   s     r   __contains__zLocalsDictNodeNG.__contains__   s     t{""r!   )r   r   )r   r   r   r   )r   )r"   r#   r   r   r$   r%   r   r&   )r   r   r1   r2   r   r3   )r8   r2   r   r3   ).)r<   r=   r   r>   r   r3   )r<   r2   r   r   r   r3   r@   )r<   r2   r   r>   r   r3   )rF   r   r   r   )r   rY   )__name__
__module____qualname____doc____annotations__r   r    r)   r0   r7   __setitem__r;   r   rB   rI   rM   rL   rU   rX   r[   r   r!   r   r   r      s          -,,,O        GH" " " " "& GH$ $ $ $ $,
6 
6 
6 
6 K    =@    X NNN XN< < < < <$ $ $ $! ! !( ( (	2 	2 	25 5 5# # # # # #r!   r   c                  ,    e Zd ZU dZej        Zded<   dS )ComprehensionScopez.Scoping for different types of comprehensions.zlist[nodes.Comprehension]
generatorsN)r\   r]   r^   r_   r   r0   r)   r`   r   r!   r   rc   rc      s,         88#1L))))11r!   rc   N)r_   
__future__r   typingr   r   r   astroid.exceptionsr   astroid.filter_statementsr   astroid.nodesr	   r
    astroid.nodes.scoped_nodes.utilsr   astroid.typingr   r   astroidr   r   LookupMixInr   rc   r   r!   r   <module>rn      s5  
 ; : " " " " " " 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ; ; ; ; ; ; E E E E E E E E WT]]j# j# j# j# j#{. j# j# j#Z2 2 2 2 2) 2 2 2 2 2r!   