0,dZddlmZddlmZmZmZddlmZddl m Z m Z ddl m Z ddlmZerddlmZed ZGd d e jZGd d eZdS)z4This module contains mixin classes for scoped nodes.) annotations) TYPE_CHECKINGTypeVaroverload) _filter_stmts) node_classes scoped_nodes)builtin_lookup)SuccessfulInferenceResult)nodes_TceZdZUdZiZded< d'dZd(d Zd)d*dZd)dZ d+dZ e Z d,dZ e d-d.dZe d/dZd0d1dZd2d Zd!Zd"Zd#Zd$Zd3d&ZdS)4LocalsDictNodeNGzthis 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[SuccessfulInferenceResult]]localsreturnstrc|j|jS|jdd|jS)zGet the 'qualified' name of the node. For example: module.name, module.class.name ... :returns: The qualified name. :rtype: str NT)future.)parentnameframeqnameselfs r/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/mixin.pyrzLocalsDictNodeNG.qname!sI ; 9 +##4#006688FF49FFFrr 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 rs rscopezLocalsDictNodeNG.scope.s  rrroffsetintct)aBLookup where the given variable is assigned. :param node: The node to look for assignments up to. Any assignments after the given node are ignored. :type node: NodeNG :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). :rtype: tuple(str, list(NodeNG)) )NotImplementedError)rnoderr!s r scope_lookupzLocalsDictNodeNG.scope_lookup6s "!rcv t||j|||}n#t$rd}YnwxYw|r||fS|jo|j}|Rt |t js|||S|jo|j}|Rt|S)z+XXX method for interfacing the scope lookupr) rrKeyErrorrr isinstancer ClassDefr&r )rr%rr!stmtspscopes r _scope_lookupzLocalsDictNodeNG._scope_lookupHs !$ D(94HHEE   EEE   ; 4!2!2!4!4 fl&;<< 7**4666]s rr?zLocalsDictNodeNG.add_local_nodeys rNcv|dkr||||p|j|dS)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)r8r4rr>s rr?zLocalsDictNodeNG.add_local_node}sD ;     j ) ) ) t.z ;;;;;ritemr c(|j|dS)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. rr)rrCs r __getitem__zLocalsDictNodeNG.__getitem__s{4 ##rcDt|S)zIterate over the names of locals defined in this scoped node. :returns: The names of the defined locals. :rtype: iterable(str) )iterkeysrs r__iter__zLocalsDictNodeNG.__iter__s DIIKK   rcNt|jS)zThe names of locals defined in this scoped node. :returns: The names of the defined locals. :rtype: list(str) )listrrIrs rrIzLocalsDictNodeNG.keyss DK$$&&'''rcDfdDS)zThe nodes that define the locals in this scoped node. :returns: The nodes that define locals. :rtype: list(NodeNG) c g|] }| Srr).0keyrs r z+LocalsDictNodeNG.values..s111cS 111r)rIrs`rvalueszLocalsDictNodeNG.valuess'2111TYY[[1111rctt||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)) )rLziprIrRrs ritemszLocalsDictNodeNG.itemss, C T[[]]33444rboolc||jvS)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, rE)rrs r __contains__zLocalsDictNodeNG.__contains__st{""r)rr)rr rr )r)rrr!r")rrr.r/rr0)r5r/rr0).)r9r:rr;rr0)r9r/rrrr0r=)r9r/rr;rr0)rCrrr )rrV)__name__ __module__ __qualname____doc__r__annotations__rr r&r-r4 __setitem__r8rr?rFrJrIrRrUrXrrrrrs:rjs ;:""""""333333333333333344444444;;;;;;444444 WT]]h#h#h#h#h#|/h#h#h#V22222)22222r