bg΢dZddlmZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZmZmZmZmZddlmZddlmZdd lmZdd lmZmZmZmZmZdd lmZm Z m!Z!m"Z"dd l#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,dd l-m.Z.ddl/m0Z0m1Z1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:ddl;mm?Z?ddl@mAZAddlBmCZCmDZDmEZEejFdkr ddl mGZGddl mHZHn ddlImHZHddlJmKZGerddlmLZLdZMeNddhZOejPdZQeNhdZRedZSd ZTdCd%ZUd&ZVd'ZWGd(d)e=ZXGd*d+e<ZYGd,d-e<ZZGd.d/e<Z[Gd0d1e<Z\d2Z]Gd3d4e9j^e=Z_Gd5d6e9j`e9jae_ZbGd7d8ebZcdDdEd<ZddDdFd>ZedDd?Zfd@ZgGdAdBe9j^e=e9jaZhdS)Gz This module contains the classes for "scoped" node, i.e. which are opening a new local scope in the language definition : Module, ClassDef, FunctionDef (and Lambda, GeneratorExp, DictComp and SetComp to some extent). ) annotationsN) GeneratorIterator) lru_cache) TYPE_CHECKINGClassVarNoReturnTypeVaroverloadbases) decorators)util)IS_PYPYPY38 PY38_PLUS PY39_PLUSPYPY_7_3_11_PLUS) CallContextInferenceContextbind_context_to_node copy_context) AstroidBuildingErrorAstroidTypeErrorAttributeInferenceErrorDuplicateBasesErrorInconsistentMroErrorInferenceErrorMroErrorStatementMissingTooManyLevelsError)lookup) ClassModel FunctionModel ModuleModel)AstroidManager) ArgumentsConstNodeNG _base_nodes node_classes)ComprehensionScopeLocalsDictNodeNG)builtin_lookup)Position) InferBinaryOpInferenceResultSuccessfulInferenceResult))cached_property)Literal)cachedproperty)nodes)__iter__ __getitem__ Exception BaseExceptionobjects> classmethod staticmethodbuiltins.classmethodbuiltins.staticmethod_Tcg} d|D}|s|S|D]!}|d}|D]}||ddvrd}nn"|std||||||D]}|d|kr|d=s)zMerges MROs in *sequences* to a single MRO using the C3 algorithm. Adapted from http://www.python.org/download/releases/2.3/mro/. Tcg|]}||SrE).0ss x/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py z_c3_merge..Rs///1Q/Q///rNzTCannot create a consistent method resolution order for MROs {mros} of class {cls!r}.messagemrosclscontext)rappend) sequencesrOrPresults1 candidates2seqs rH _c3_mergerXJs F// ///  M  B1I  122&& $IE' '4    i     C1v""F7rJrRlist[list[ClassDef]]returnNonecV|dd}|d}t|D]!\}}|dkr|}n"dSt|D]'\}}||kr td|Drn(dS||||dS)aA class can inherit from typing.Generic directly, as base, and as base of bases. The merged MRO must however only contain the last entry. To prepare for _c3_merge, remove some typing.Generic entries from sequences if multiple are present. This method will check if Generic is in inferred_bases and also part of bases_mro. If true, remove it from inferred_bases as well as its entry the bases_mro. Format sequences: [[self]] + bases_mro + [inferred_bases] rKtyping.GenericNc3FK|]}|dkVdS)r^NqnamerFbases rH z+clean_typing_generic_mro..s0@@Dtzz||//@@@@@@rJ) enumerateraanypop)rR bases_mroinferred_basesircposition_in_inferred_basesrWs rHclean_typing_generic_mrorlps!B$Ir]N^,,4 ::<<+ + +)* & E , I&&3 * * *  @@C@@@ @ @  E  1222 MM,-----rJc #@K|D]}d|D}tttt||r-|d%|ddkrt d|||fdtt ||DVdS)NcVg|]&}|jr|j|fnd'SN)namelinenorarFnodes rHrIz(clean_duplicates_mro..s@   CG49 >T[$**,, ' '$   rJrz,Duplicates found in MROs {mros} for {cls!r}.rLc<g|]\}\}}| ||k|SrorE)rFrjrsrp last_indexs rHrIz(clean_duplicates_mro..s?   propertyr?) isinstance FunctionDeftyper BoundMethod UnboundMethod)nklasss rHfunction_to_methodrsi![!!* 6] " "$Q.. . 6Z  H 6^ # #&q)) ) HrJc&eZdZUdZdZdZded< dZded< dZded < dZ d ed < e Z hd Z d Z dZded<ded<ded<ded<ejd dRdSfd! ZdTdd"dUd%ZedVd&ZejdWd(Zd)Zd*Zd+ZdXd,ZdYd.ZdZd/Z d[d\d3ZdTd\d4Zd]d6Zed7d8d^d:Z ed_d=Z dd8d`d@Z dAZ!dBZ"dZ#d]dCZ$ dadbdIZ%dcdJZ&dKZ'dLZ(dTdddMZ)dNZ*dd8dedQZ+xZ,S)fModulezClass representing an :class:`ast.Module` node. >>> import astroid >>> node = astroid.extract_node('import astroid') >>> node >>> node.parent )doc_nodebodyr Literal[0] fromlinenorqNzstr | bytes | None file_bytes str | None file_encoding>__doc____file____name____path__ __package__)rpdocfilepathpackage pure_pythonfuture_imports)localsglobalsr[ col_offset end_linenoend_col_offsetparent'Use the postinit arg 'doc_node' insteadrTrpstrrrrlist[str] | Noner bool | NonerrZc||_ ||_ ||_ ||_||_ ||_ | ix|_|_ g|_ d|_ t|_ t d|dS)a :param name: The name of the module. :param doc: The module docstring. :param file: The path to the file that this ast has been extracted from. :param path: :param package: Whether the node represents a package or a module. :param parent: The parent node in the syntax tree. :param pure_python: Whether the ast was built from source. Nr)rqr)rp_docrrrrrrrrsetrsuper__init__) selfrprrrrrr __class__s rHrzModule.__init__s4 % #    @&4 :U%'' dlS68 )&* 5(+. &11111rJ)rr Const | NonecB||_||_|r|j|_dSdS)zDo some setup after initialisation. :param body: The contents of the module. :type body: list(NodeNG) or None :param doc_node: The doc node associated with this node. N)rrvaluer)rrrs rHpostinitzModule.postinit+s1    ' DIII ' 'rJcHtjdtd|jS)zThe module docstring.zHThe 'Module.doc' attribute is deprecated, use 'Module.doc_node' instead. stacklevelwarningswarnDeprecationWarningrrs rHrz Module.doc7s2   -      yrJrcLtjdtd||_dS)NzPSetting the 'Module.doc' attribute is deprecated, use 'Module.doc_node' instead.rrrrrs rHrz Module.docBs3  -       rJc|jtj|jS|jt |jd}|SdS)Nrb)rioBytesIOropen)rstreams rH _get_streamzModule._get_streamLs? ? &:do.. . 9 $)T**FMtrJc*|S)zaGet a stream to the underlying file or bytes. :type: file or io.BytesIO or None )rrs rHrz Module.streamUs !!!rJc|j|jfS)zGet a range from where this node starts to where this node ends. :param lineno: Unused. :type lineno: int :returns: The range of line numbers that this node belongs to. :rtype: tuple(int, int) rtolinenorrqs rH block_rangezModule.block_range\ --rJc||jvr5||jvr, |||fS#t$r|dfcYSwxYw||||S)atLookup 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. :type name: str :param offset: The line offset to filter statements up to. :type offset: int :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)) rE) scope_attrsrgetattrr _scope_lookup)rrsrpoffsets rH scope_lookupzModule.scope_lookupgsz$ 4# # #DK(?(? T\\$////*   Rx !!$f555s +<<Literal['builtins.module']cdS)eGet the name of the type that this node represents. :returns: The name of the type. zbuiltins.modulerErs rHpytypez Module.pytypes ! rJcdS)jA human readable type of this node. :returns: The type of this node. :rtype: str rrErs rH display_typezModule.display_types xrJFrPInferenceContext | Nonec|st|||g}||jv}||jvr |s|s|j|g}n_|s|r|j|}nM|jrF ||dg}n,#t tf$r}t||||d}~wwxYwd|D}|r|St|||)Ntarget attributerPT) relative_onlycFg|]}t|tj|SrE)rr+DelNamerFrs rHrIz"Module.getattr..*OOO:a9M+N+NO!OOOrJ)rrspecial_attributesr"r import_moduler SyntaxError)rrprP ignore_localsrSname_in_localsexcs rHrzModule.getattrs, X)wWWW W, 4* * *= * *-44T::;FF > [&FF \  ,,T,FFG(+6   -4 POVOOO  M%TT7SSSSs#A<<B% B  B%ct|}||_ tj|||||S#t $r&}t t|||||d}~wwxYw)zInfer the possible values of the given variable. :param name: The name of the variable to infer. :type name: str :returns: The inferred possible values. :rtype: iterable(NodeNG) or None framerN)r lookupnamer _infer_stmtsrrrrrrprPerrors rHigetattrzModule.igetattrsw''! %dll4&A&A7RVWWW W&    E 44  s*A A3 !A..A3boolcH|jduo|jdS)zCheck if this module has been build from a .py file. If so, the module contains a complete representation, including the code. :returns: Whether the module has been built from a .py file. Nz.py)rendswithrs rH fully_definedzModule.fully_defineds&y$B););E)B)BBrJ.futurercdSrorErrs rH statementzModule.statement rJ Literal[True]r cdSrorErs rHrzModule.statementrrJLiteral[None, True]Module | NoReturncb|rt|tjdtd|S)aJThe first parent node, including self, marked as statement node. When called on a :class:`Module` with the future parameter this raises an error. TODO: Deprecate the future parameter and only raise StatementMissing :raises StatementMissing: If no self has no parent attribute and future is True )rzIn astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement or raise a StatementMissing exception. nodes.Module will no longer be considered a statement. This behaviour can already be triggered by passing 'future=True' to a statement() call.rr)r rrrrs rHrzModule.statementsJ  0"$/// /  >       rJcdS)zThe previous sibling statement. :returns: The previous sibling statement node. :rtype: NodeNG or None NrErs rHprevious_siblingzModule.previous_siblingrJcdS)z|The next sibling statement node. :returns: The next sibling statement node. :rtype: NodeNG or None NrErs rH next_siblingzModule.next_siblingrrJc|jS)zWhether :pep:`328` absolute import behaviour has been enabled. :returns: Whether :pep:`328` has been enabled. )_absolute_import_activatedrs rHabsolute_import_activatedz Module.absolute_import_activateds ..rJmodnamerlevel int | None use_cachec|r|d}|||} t||S#t$r|rYnwxYwt|S)axGet the ast for a given module as if imported from this module. :param modname: The name of the module to "import". :param relative_only: Whether to only consider relative imports. :param level: The level of relative import. :param use_cache: Whether to use the astroid_cache of modules. :returns: The imported module ast. Nr)r )relative_to_absolute_namer&ast_from_module_namer)rrrrr  absmodnames rHrzModule.import_modules&  U]E33GUCC  !##88i9 $        44W===s"A AAc@|r||S|rE|jr'|dz }|jd|d}n|jrt jt j|jddzsnt jt j|jddz|ddzr|dz }d}n!|jd|d}|r4|j d|krt||jn0|jr|j}n!|jddd}|r |s|S|d|S|S) aGet the absolute module name for a relative import. The relative import can be implicit or explicit. :param modname: The module name to convert. :param level: The level of relative import. :returns: The absolute module name. :raises TooManyLevelsError: When the relative import refers to a module too far above this one. NrK.rz /__init__.py/)rrp) rrrprsplitrosexistsdirnamesplitcountr!)rrr package_names rHr z Module.relative_to_absolute_names&  ) ) + +  N  7| ? #y//U;;A>   ?rwty|'D'D~'UVV ?GNNGOODIaL11C7'--:L:LQ:OO ? ! #y//U;;A>  F--55(u49EEEE \ 79LL9++C33A6L  / $##"..W.. .rJcd|D} |d}n#t$r|cYSwxYw t|}n&#tt f$r|cYSt $r|cYSwxYwg} t|}n#tt f$r|cYSwxYwt|tj tj fs|Sdd}|j D]}||r| |j( t|}n#tt f$rY^wxYw||r| |j|S)aThe list of imported names when this module is 'wildcard imported'. It doesn't include the '__builtins__' name which is added by the current CPython implementation of wildcard imports. :returns: The list of imported names. :rtype: list(str) c<g|]}|d|S_ startswithrFrps rHrIz0Module.wildcard_import_names..Ys)LLLDts7K7KL4LLLrJ__all__rZrcjt|tjot|jtSro)rr+r(rr)rss rH str_constz/Module.wildcard_import_names..str_constqs'dL$677WJtzSVB?!EEEc>d|DS)zThe list of the names that are publicly available in this module. :returns: The list of public names. :rtype: list(str) c<g|]}|d|Srrrs rHrIz'Module.public_names..s)IIIDOOC4H4HIIIIrJ)r$rs rH public_nameszModule.public_namess! JIIIIIrJcdS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`Module` this is always ``True``. TrErrPs rH bool_valuezModule.bool_value trJc#$K|jEd{VdSrorrs rH get_childrenzModule.get_childrens&9rJrrBc|SzThe node's frame node. A frame node is a :class:`Module`, :class:`FunctionDef`, :class:`ClassDef` or :class:`Lambda`. :returns: The node itself. rErs rHrz Module.frame  rJ)NNNNNT)rprrrrrrrrrrr[rrrZr[ro)rrrZrrrrZr[r)rZrrZr)NFrPrr#)rr[rZr)rrrZr )rrrZr)FNT) rrrrrrr rrZr)rrrrrZrrPrrZrrrBrrrZrB)-r __module__ __qualname__r_astroid_fieldsr__annotations__rqrrr%rr _other_fields_other_other_fieldsdecorators_moddeprecate_argumentsrrr~rsetterrrrrrrrrrr rrrrrrr r3r6r9r=r __classcell__rs@rHrrs+OJFF@&*J))))8 $M$$$$ %?QPPKLM0LLL'^',UVVV!%##'=2=2=2=2=2=2WV=2B 'd ' ' ' ' ' 'X ZZ""" . . .66662!!!!LQTTTTT2(CCCC*-     X    X :>*      "&////$  > > > > >D0000d000dJJJ:>rJrcZeZdZdZdZdZdZ ddddfd Zddd ZdddZ dZ xZ S) GeneratorExpzClass representing an :class:`ast.GeneratorExp` node. >>> import astroid >>> node = astroid.extract_node('(thing for thing in things if thing)') >>> node elt generatorsrNrrcdi|_ t|||||dSa :param lineno: The line that this node appears on in the source code. :type lineno: int or None :param col_offset: The column that this node appears on in the source code. :type col_offset: int or None :param parent: The parent node in the syntax tree. :type parent: NodeNG or None :param end_lineno: The last line this node appears on in the source code. :type end_lineno: Optional[int] :param end_col_offset: The end column this node appears on in the source code. Note: This is after the last symbol. :type end_col_offset: Optional[int] rqrrrrNrrrrrqrrrrrs rHrzGeneratorExp.__init__I6 S !!)      rJrW list[nodes.Comprehension] | Nonec8||_| g|_dS||_dSzDo some setup after initialisation. :param elt: The element that forms the output of the expression. :type elt: NodeNG or None :param generators: The generators that are looped through. NrUrrVrWs rHrzGeneratorExp.postinit'   DOOO(DOOOrJrPrrZrcdS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`GeneratorExp` this is always ``True``. TrEr8s rHr9zGeneratorExp.bool_valuer:rJc#6K|jV|jEd{VdSrorUrs rHr=zGeneratorExp.get_children1h?"""""""""rJNNNNNrWr`rorPrrZr rrHrIrrJrMrVrrr9r=rQrRs@rHrTrTs,O% C $ $ $ $ $ $ $ $ L ) ) ) ) )#######rJrTcfeZdZdZdZdZdZ dZ ddddfd Z ddd Z ddd Z d Z xZ S)DictCompzClass representing an :class:`ast.DictComp` node. >>> import astroid >>> node = astroid.extract_node('{k:v for k, v in things if k > v}') >>> node keyrrWrXNrYcdi|_ t|||||dSr[r]r^s rHrzDictComp.__init__r_rJrWr`cF||_||_| g|_dS||_dS)aDo some setup after initialisation. :param key: What produces the keys. :type key: NodeNG or None :param value: What produces the values. :type value: NodeNG or None :param generators: The generators that are looped through. Nro)rrprrWs rHrzDictComp.postinit-s.    DOOO(DOOOrJrPrctjS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`DictComp` this is always :class:`Uninferable`. :rtype: Uninferable r Uninferabler8s rHr9zDictComp.bool_valueD rJc#HK|jV|jV|jEd{VdSrorors rHr=zDictComp.get_childrenMs?hj?"""""""""rJrhrjrorE) rrHrIrrJrMrprrrr9r=rQrRs@rHrnrns5O% C E $ $ $ $ $ $ $ $ P 7; ))))).     #######rJrncZeZdZdZdZdZdZ ddddfd Zddd Zddd Z d Z xZ S)SetCompzClass representing an :class:`ast.SetComp` node. >>> import astroid >>> node = astroid.extract_node('{thing for thing in things if thing}') >>> node rUrXNrYcdi|_ t|||||dSr[r]r^s rHrzSetComp.__init__er_rJrWr`c8||_| g|_dS||_dSrbrUrcs rHrzSetComp.postinitrdrJrPrctjS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`SetComp` this is always :class:`Uninferable`. :rtype: Uninferable rtr8s rHr9zSetComp.bool_valuervrJc#6K|jV|jEd{VdSrorUrs rHr=zSetComp.get_childrenrgrJrhrirjrorErlrRs@rHryryTs,O% C $ $ $ $ $ $ $ $ L ) ) ) ) )     #######rJrycZeZdZdZdZdZdZ ddddfd Zddd Zddd Z d Z xZ S)ListCompzClass representing an :class:`ast.ListComp` node. >>> import astroid >>> node = astroid.extract_node('[thing for thing in things if thing]') >>> node rUrXNrYcdi|_ t|||||dS)Nr\r]r^s rHrzListComp.__init__sI L !!)      rJrWr`c8||_| g|_dS||_dS)aDo some setup after initialisation. :param elt: The element that forms the output of the expression. :type elt: NodeNG or None :param generators: The generators that are looped through. :type generators: list(Comprehension) or None NrUrcs rHrzListComp.postinits'   DOOO(DOOOrJrPrctjS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`ListComp` this is always :class:`Uninferable`. :rtype: Uninferable rtr8s rHr9zListComp.bool_valuervrJc#6K|jV|jEd{VdSrorUrs rHr=zListComp.get_childrenrgrJrhrirjrorErlrRs@rHrrs,O% C         ( ) ) ) ) )     #######rJrct|tsdS|jsdS t||jd}n#t $rYdSwxYwt|t jr|j}t|tr.| drdS| drdSt|tr|j sdS|j j D]}t|tjr|jt vr |jcSt|tjrFt|jtjr'|jjdkr|jt vr |jcSdS)z_Detect decorator call chaining and see if the end result is a static or a classmethod. Nr@r>rAr?builtins)rrrr&infer_call_resultrr Instance_proxiedClassDef is_subtype_ofrr8r+NamerpBUILTIN_DESCRIPTORS Attributeexprattrname)rsrS decorators rH_infer_decorator_callchainrs dK ( (t ;td,,T[994@@ tt&%.))!&(##"    6 7 7 ! =    7 8 8 "!>&+&&*  4*0 * *I)\%677 *>%888$>)))9l&<== *y~|/@AA *N':55&*=== )))) 4s(A AAceZdZdZdZdZdZdZeZ d)dZ e d*d Z d+d d d fd Z d,dZd-dZd.dZd/dZd0dZd1d2dZd3dZd1d4dZdZd d d5d%Z d1d6d(ZxZS)7LambdazClass representing an :class:`ast.Lambda` node. >>> import astroid >>> node = astroid.extract_node('lambda arg: arg + 1') >>> node l.1 at 0x7f23b2e41518> argsrrXzTrZrcdS)NrrErs rHimplicit_parameterszLambda.implicit_parameters!qrJLiteral['method', 'function']c|jjrI|jjdjdkr.t|jt rdSdS)zuWhether this is a method or function. :returns: 'method' if this is a method, 'function' otherwise. rrmethodfunction)r argumentsrprrscoperrs rHrz Lambda.type$sR 9  49#6q#9#>&#H#H$+++--x88 xzrJNrYci|_ | g|_ i|_t|||||dSr[)rrinstance_attrsrrr^s rHrzLambda.__init__/sh6 L 4  8: !!)      rJrr'c"||_||_dS)zDo some setup after initialisation. :param args: The arguments that the function takes. :param body: The contents of the function body. :type body: list(NodeNG) Nr)rrrs rHrzLambda.postinit`s  rJ6Literal['bultins.instancemethod', 'builtins.function']cd|jvrdSdS)rrzbuiltins.instancemethodzbuiltins.functionrrs rHrz Lambda.pytypeks ty ,,""rJrcd|jvrdSdS)rrMethodFunctionrrs rHrzLambda.display_typets ty 8zrJrcdS)zWhether this node defines something that is callable. :returns: Whether this defines something that is callable For a :class:`Lambda` this is always ``True``. TrErs rHcallablezLambda.callable~r:rJ list[str]c4|jjrt|jj}ng}|jjr||jj|d|jjDz }|jjr||jj|S)aGet the names of each of the arguments, including that of the collections of variable-length arguments ("args", "kwargs", etc.), as well as positional-only and keyword-only arguments. :returns: The names of the arguments. :rtype: list(str) cg|] }|j SrErp)rFrVs rHrIz#Lambda.argnames..s;;;s#(;;;rJ)rr_rec_get_namesvarargrQ kwonlyargskwarg)rr{s rHargnameszLambda.argnamess 9  "49#677EEE 9  + LL) * * * ;;di&:;;;; 9? * LL ) ) ) rJrPrc6|j|S)zqInfer what the function returns when called. :param caller: Unused :type caller: object )rr*)rcallerrPs rHrzLambda.infer_call_resultsyw'''rJrc||jjvs||jjvr|jd}d}n|}||||S)aaLookup where the given names 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 to find assignments for. :type name: str :param offset: The line offset to filter statements up to. :type offset: int :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)) Trr])rdefaults kw_defaultsrrr)rrsrprrs rHrzLambda.scope_lookupsc$ 49% % %1F)F)FK%%T%22EFFE""4v666rJcdS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`Lambda` this is always ``True``. TrEr8s rHr9zLambda.bool_valuer:rJc#.K|jV|jVdSrorrs rHr=zLambda.get_childrens iirJrrrBrrc|Sr?rErs rHrz Lambda.framer@rJrp list[NodeNG]c|st|||g}||jvr |j|}||jvr-||j||r|St||)Nr)rr)rrrrQr")rrprP found_attrss rHrzLambda.getattrs X)wWWW W 4& & &-d3K 4* * *   t6==dCC D D D   %TTBBBBrJ)rZr)rZrrh)rr')rZrrD)rZr)rZrrorErCrkrG)rprrPrrZr)rrHrIrrJrMrp is_lambdar$rrr~rrrrrrrrrr9r=rrrQrRs@rHrrs'O% DI&AX / / / / / / / / b    ####& ( ( ( ( (77778:>=A C C C C C C C C CrJrceZdZUdZdZdZdZdZded< dZ dZ dZ dZ dZ d ZdZejd  d=ddd d>fdZ d?dddd@dZedAdZejdBdZedCdZedDd ZedEd"Zed#ZdFd%Zd&ZdGdHd)ZdId+Zej dGdHd,Z!dId-Z"dJdId/Z#dId0Z$dGdHd1Z%dKdHd2Z&dGdLd3Z'd4Z(dMfd6 Z)dd7dNd<Z*xZ+S)OrzClass representing an :class:`ast.FunctionDef`. >>> import astroid >>> node = astroid.extract_node(''' ... def my_func(arg): ... return arg + 1 ... ''') >>> node )rrreturnsrrr<Nnode_classes.Decorators | NonerT)rprposition)r_typetype_comment_returnstype_comment_argsrrrYrrc||_ ||_ d|_ i|_t ||||||r.|d}|||dSdS)a :param name: The name of the function. :type name: str or None :param doc: The function docstring. :param lineno: The line that this node appears on in the source code. :type lineno: int or None :param col_offset: The column that this node appears on in the source code. :type col_offset: int or None :param parent: The parent node in the syntax tree. :type parent: NodeNG or None :param end_lineno: The last line this node appears on in the source code. :type end_lineno: Optional[int] :param end_col_offset: The end column this node appears on in the source code. Note: This is after the last symbol. :type end_col_offset: Optional[int] Nr\Tr)rprrrrrr set_local) rrprrqrrrrrrs rHrzFunctionDef.__init__sF   %&* 5  !!)      (LLL--E OOD$ ' ' ' ' ' ( (rJrrrr'rPosition | Nonerrc||_||_||_||_||_||_||_||_|r|j|_ dSdS)aDo some setup after initialisation. :param args: The arguments that the function takes. :param body: The contents of the function body. :type body: list(NodeNG) :param decorators: The decorators that are applied to this method or function. :type decorators: Decorators or None :params type_comment_returns: The return type annotation passed via a type comment. :params type_comment_args: The args type annotation passed via a type comment. :params position: Position of function keyword(s) and name. :param doc_node: The doc node associated with this node. N) rrrrrrrrrr) rrrrrrrrrs rHrzFunctionDef.postinitPs]>  $ $8!!2     ' DIII ' 'rJrZcHtjdtd|jS)zThe function docstring.zRThe 'FunctionDef.doc' attribute is deprecated, use 'FunctionDef.doc_node' instead.rrrrs rHrzFunctionDef.doczs2   2      yrJrr[cLtjdtd||_dS)NzZSetting the 'FunctionDef.doc' attribute is deprecated, use 'FunctionDef.doc_node' instead.rrrrs rHrzFunctionDef.docs3  2       rJlist[node_classes.Call]c\|jd}t|tsgSg}|D]}t|jt jrt|jjt j r|j D]}t|t j s|j |j kr. ||j }t|tr4|d|kr||j#t$rYwxYw|S)aThe extra decorators that this function can have. Additional decorators are considered when they are used as assignments, as in ``method = staticmethod(method)``. The property will return all the callables that are used for decoration. Tr)rrrr_get_assign_nodesrr+Callfuncrtargets AssignNamerprrQr%)rrrassign assign_nodemeths rHextra_decoratorszFunctionDef.extra_decoratorssM !!!..%** I.0 --// < < >% G G&--fl;;;$!!! !s D D('D(rc|jD]#}|jjtvr|jjcS$|jd}d}t |tr)|jdkrdS|jdkrdS|jdkrdSd}|js|S|jj D]}t |tj r|jtvr |jcSt |tj rFt |j tj r'|j jd kr|jtvr |jcSt |tjrT t!|j}n#t$t&f$rYwxYwt)|}||cS |D]}t)|}||ccSt |ts/|D]L}t |ts|d rdS|d rd SM#t$$rYwxYw|S)ztThe function type for this node. Possible values are: method, function, staticmethod, classmethod. Trr__new__r>__init_subclass____class_getitem__rrNr@rAr?)rrrprrrrrrr8r+rrrrrr&r*rr(r ancestorsr) rrr type_namerscurrentrr1ancestors rHrzFunctionDef.types . + +I~"&999 ~****: !!!.. eX & & !yI%%$}y///$}y///$} I  O)* * D$ 122 %9 3339$$$4!788 %ty,*;<< %INj00M%888}$$$$ 122 ! "49??#4#455GG& 6H27;;$ LLL  $ 22H6x@@E($ %h99! $,$6$6$8$822)(H==%$#112HII1#0====#112IJJ2#1>>>>2 22"    s7 &E22FF*I AI(II IIrcn|j}|j&|td|jjDz }|S).sA48  +a/rJ)rqrsumr8rs rHrzFunctionDef.fromlinenosQ  ? & c<@Orr>rrs rHrzFunctionDef.is_boundKs y555rJFc|jrd|jjD]W} t|}n#tt f$rY8wxYw|r|dvrdSX|jD]U}t|tj r|rdS| rdS|ot|tj cS|rdSdS)aCheck if the method is abstract. A method is considered abstract if any of the following is true: * The only statement is 'raise NotImplementedError' * The only statement is 'raise ' and any_raise_is_abstract is True * The only statement is 'pass' and pass_is_abstract is True * The method is annotated with abc.astractproperty/abc.abstractmethod :returns: Whether the method is abstract. >abc.abstractmethodabc.abstractpropertyTF) rr8r&r*rr(rarrr+Raiseraises_not_implementedPass)rpass_is_abstractany_raise_is_abstractrsr1 child_nodes rH is_abstractzFunctionDef.is_abstractRs ? - #DJJLL11HH& 6H  0 05!! 44) R RJ*l&899 ( 444466 44#Q :|?P(Q(Q Q Q Q  4us!9A  A c`tt|dS)zhCheck if this is a generator function. :returns: Whether this is a generator function. F)rr&_get_yield_nodes_skip_lambdasrs rH is_generatorzFunctionDef.is_generatorvs( D;;==uEEFFFrJc#&K|tjD]n}|j,tjd}||_|j|_|V5||kr!|j|Ed{VodS)zInfer what the function yields when called :returns: What the function yields :rtype: iterable(NodeNG or Uninferable) or None Nr) nodes_of_classr+Yieldrr(rrqrr*)rrPyield_consts rHinfer_yield_resultzFunctionDef.infer_yield_result}s)),*<== ? ?F|#$*400% %}  4''!<--g->>>>>>>>> ? ?rJc#K|rAt|tr tj}n tj}||}|VdS|jdkr|t|jjdkrr|jj et|jtr4t|jjd d}nmt|jtr/t|jd d}n$tdt|jt|t r fd|jddD}n1#t"$r$}t%|jdd|d}~wwxYwt!d }d |_||_|d |Dgg| |VdS|} t| d} | sT|jr>|d d rt2jVnt7jdVdSt%dt;j| f| D]_} | jt7jdV | j Ed{VB#t$$rt2jVY\wxYwdS)zInfer what the function returns when called. :returns: What the function returns. :rtype: iterable(NodeNG or Uninferable) or None )generator_initial_contextNwith_metaclassrKrz0caller.args was neither Arguments nor list; got c g|]A}td|DBS)c3RK|]"}t|tr|j|V#dSrorr(rrFbs rHrdz;FunctionDef.infer_call_result...sF !$.q%$8$8>?W_=L___rJr)r&r*clone)rFargrPs rHrIz1FunctionDef.infer_call_result..sg### %(YYw}}Y%G%G###rJrsrPtemporary_classrTcFg|]}t|tj|SrErrUninferableBaserbs rHrIz1FunctionDef.infer_call_result..s; )$0DEErJ)r rr metaclass)rrz0The function does not have any return statements) rrAsyncFunctionDefr AsyncGeneratorrrplenrrr'r&r*list TypeErrorrrr(rhiderr _get_return_nodes_skip_functionsrrrrur+r( itertoolschainr) rrrP generator_clsrSr class_basese new_classr first_return returnnodes ` rHrzFunctionDef.infer_call_resultsx      $ 011 0 % 4 % "]47KKKFLLL F I) ) )"DIN##q((  ,&+y11  !1!!4!:!:7!C!CTJJ FK..  Q!5!5g!>!>EE ZtFKGXGXZZ)X..  W####$*;qrr?###KK%WWW(fk!""owOOOUVVW$*;<<< !% #'  ""$/ !'#    7799GT**  Uy ##TQU#VV3*****&,T22222 !STT T#/>>>>>>>>>%+++******+  + +s*$F F. F))F.) K  K%$K%cdS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`FunctionDef` this is always ``True``. TrEr8s rHr9zFunctionDef.bool_valuer:rJc#vK|j |jV|jV|j |jV|jEd{VdSro)rrrrrs rHr=zFunctionDef.get_childrens] ? &/ ! ! !i < #,   9rJrc|dkr5|jd}t|tr||gfSt |||S)z(Lookup where the given name is assigned.rTr)rrrrrr)rrsrprrrs rHrzFunctionDef.scope_lookupsb ;   K%%T%22E%** %eW}$ww##D$777rJrrrBrrc|Sr?rErs rHrzFunctionDef.framer@rJNNNNNrr)NNNN)rr'rrrrrrrArB)rZrrDrZr)rZrrorEr#)TFrirFrCrG),rrHrIrrJ_multi_line_block_fieldsrrrK is_functiontype_annotationrrrLrMrrNrOrrr~rrPr5rrrrrrrrcachedrrrrr rr9r=rrrQrRs@rHrrsU  LO(G15J5555EK O \/M E'^',UVVV 8(8(8(8(8(8(8(8(WV8(|6:!('%)!%('('('('('('TX ZZ&&&_&PCCC_CJ   _ ""_"++++ . . .     *6666"""""HGGGG?????"R+R+R+R+R+h    8 8 8 8 8 8:>rJrceZdZdZdS)raClass representing an :class:`ast.FunctionDef` node. A :class:`AsyncFunctionDef` is an asynchronous function created with the `async` keyword. >>> import astroid >>> node = astroid.extract_node(''' async def func(things): async for thing in things: print(thing) ''') >>> node >>> node.body[0] N)rrHrIrrErJrHrr srJrr{rrc|g}|D]L}t|tjrt|j|2||jM|S)z#return a list of all argument names)rr+r+rr-rQrp)rr{rs rHrrsa }## c<- . . # 38U + + + + LL " " " " LrJrc|jdkrdS|t}|jD]} |D]}|}||vr||t |tjrdS||urSt |tsi|j dkrdSt||rdS#t$rYwxYwdS)z>Return if the given class can be used as a metaclass. rTNFr) rprr r*rarrrrr _is_metaclassr)rseenrcbaseobj baseobj_names rHr9r9+s  zVt |uu  ::<<  &}} 4''&&&gu~66! 555e##!'844=K//444 $// 444  "    H  5s$AC  'C 4C C  CCc|j|jSt|rd|_n|jdrd|_n|t }|}||vr d|_dS|||dD]<}t||}|dkr$|dkrt|s.|j |_n=|jd|_|jS)z]return a ClassDef node type to differ metaclass and exception from 'regular' classes Nrr; exceptionclassF)recurs) rr9rprrrarr _class_typer)rr klass_namercrps rHrArAKs  {{U!   [ ) )!  I[[]]  " "!EK7 j!!!OO5O11  DtY//Dw;&&}U/C/C&"i   { ;rJc|d}|Qt|ts<|jd}n|jd}|t|t<|S)zGet the class that wraps the given node. We consider that a class wraps a node if the class is a parent for the said node. :returns: The class that wraps the given node :rtype: ClassDef or None TrN)rrrr)rsrs rHget_wrapping_classrDmsq JJdJ # #E  Juh$?$?  < EEL&&d&33E  Juh$?$?  LrJcHeZdZUdZdZdZ eZ dZdZ de d<dZ dZ e edZd Zd ZdZejd  dfddd dgfdZde d<e dhdZejdidZdjdZdZ dkddddld Zdmdnd#ZdZe ed$Zedofd& Zed'Zd(Z dpd*Z!dqd,Z"drd.Z#dmdsd/Z$d0Z%dmdnd1Z&dtd3Z'e d4Z( dudvd8Z)dmdnd9Z*dmdnd:Z+drd;Z,dmdnd<Z-dmdnd=Z.dwd?Z/ dxdydCZ0e1dDEdFZ2dGZ3 dxdzdIZ4dmdsdJZ5dmdndKZ6dLZ7dMZ8dNZ9 dmd{dOZ: d|d}dRZ;dmd{dSZdVZ?ej@dWZAdmdndXZBdmdndYZCdmd~d[ZDdmdd]ZEd^ZFej@d_ZGdd`ddeZHxZIS)ra Class representing an :class:`ast.ClassDef` node. >>> import astroid >>> node = astroid.extract_node(''' class Thing: def my_meth(self, arg): return arg + self.offset ''') >>> node )rr keywordsrrN NodeNG | None _metaclassFz\The class type for this node. Possible values are: class, metaclass, exception. :type: strr)rpr is_dataclassr)r _newstylerrYrrci|_i|_ g|_ g|_ g|_ ||_ ||_ d|_ d|_ t ||||||*| d ||| D]\}} || |dS)a :param name: The name of the class. :type name: str or None :param doc: The class docstring. :param lineno: The line that this node appears on in the source code. :type lineno: int or None :param col_offset: The column that this node appears on in the source code. :type col_offset: int or None :param parent: The parent node in the syntax tree. :type parent: NodeNG or None :param end_lineno: The last line this node appears on in the source code. :type end_lineno: Optional[int] :param end_col_offset: The end column this node appears on in the source code. Note: This is after the last symbol. :type end_col_offset: Optional[int] NFr\Tr)rrrFr rrprrrIrrrrimplicit_localsadd_local_node) rrprrqrrrr local_namersrs rHrzClassDef.__init__s F! L  $& +     "&* 5"'0 !!)       LLL % % / /d ; ; ; $ 4 4 6 6 2 2 J   j 1 1 1 1 2 2rJz!ClassVar[InferBinaryOp[ClassDef]]infer_binary_oprZcHtjdtd|jS)zThe class docstring.zLThe 'ClassDef.doc' attribute is deprecated, use 'ClassDef.doc_node' instead.rrrrs rHrz ClassDef.docs2   /      yrJrr[cLtjdtd||_dS)NzZSetting the 'ClassDef.doc' attribute is deprecated, use 'ClassDef.doc_node.value' instead.rrrrs rHrz ClassDef.docs3  5       rJ Literal[1]cdS)NrKrErs rHrzClassDef.implicit_parametersrrJcHd|jjff}|d|jjffz }|S)zGet implicitly defined class definition locals. :returns: the the name and Const pair for each local :rtype: tuple(tuple(str, node_classes.Const), ...) rHrI)rattr___module__attr___qualname__)rlocals_s rHrLzClassDef.implicit_localss4 !$"9"IJL^T%<%NOQQrJrrrrrrc|||_||_||_||_|||_|||_||_||_|r|j|_ dSdS)aDo some setup after initialisation. :param bases: What the class inherits from. :type bases: list(NodeNG) :param body: The contents of the class body. :type body: list(NodeNG) :param decorators: The decorators that are applied to this class. :type decorators: Decorators or None :param newstyle: Whether this is a new style class or not. :type newstyle: bool or None :param metaclass: The metaclass of this class. :param keywords: The keywords given to the class definition. :type keywords: list(Keyword) or None :param position: Position of class keyword and name. :param doc_node: The doc node associated with this node. N) rFr rrrJrHrrrr) rr rrnewstylerrFrrs rHrzClassDef.postinit+snF  $DM  $  %DN  'DO     ' DIII ' 'rJrPrcb|t}|j|jS|d|D] }||r d|_n!|}|/t |t r|||_|jd|_|jS)NFr@rPT)rrJr_newstyle_impldeclared_metaclassrr)rrPrcrs rHr\zClassDef._newstyle_impl\s ?&((G > %> !NN%NAA  D""7++ !% ''))  E8! !"DN~rJz=Whether this is a new style class or not :type: bool or NonerctrtrDtr=ts6|j}|j&|t d|jjDz }|Stj S)rNc3:K|]}|j|jz dzVdSrrrrs rHrdz&ClassDef.fromlineno..}sA8* *rJc|j|jfSrrrs rHrzClassDef.block_rangerrJ-Literal['builtins.type', 'builtins.classobj']c|jrdSdS)r builtins.typezbuiltins.classobj)rYrs rHrzClassDef.pytypes = #"?""rJrcdS)rClassrErs rHrzClassDef.display_types wrJrcdS)zWhether this node defines something that is callable. :returns: Whether this defines something that is callable. For a :class:`ClassDef` this is always ``True``. TrErs rHrzClassDef.callabler:rJc|krdStfd||DS)zWhether this class is a subtype of the given type. :param type_name: The name of the type of check against. :type type_name: str :returns: Whether this class is a subtype of the given type. Tc3HK|]}|kVdSror`)rFancrs rHrdz)ClassDef.is_subtype_of..s0WW399;;)+WWWWWWrJr)rarfr)rrrPs ` rHrzClassDef.is_subtype_ofsN ::<<9 $ $4WWWWt~~g~7V7VWWWWWWrJc t|jd|}n/#t$r"}t |jd||d}~wwxYwt |t jr"t |jtr|j}n tj St|} t|jd|}n/#t$r"}t |jd||d}~wwxYwt |t j t jfrkg}|D]L} t| |d} | r$|jt j| | M||_n tj S t|jd|} n#ttf$rd} YnwxYw| rkt | t jrQ| jD]I\} } t | t jr*t | jtr| g|j| j<J|j|_|S)NrrrKr)originalrr)r&rr*r(rrr+r(rrrrurr+r,iteredrQEvaluatedObjectr Dictitemsrr)rrrP name_noder'rprSr&r rcr1membersattrrs rH_infer_type_callzClassDef._infer_type_calls NV[^11'::;;II N N N fk!ngFFFA M N i!3 4 4 $ OS: :  $?DD# #$ Nv{1~33G<<==KK N N N fk!ngFFFA M N kL$6 8I#J K K $E#**,,   7 ; ;TBB EL$4d(SSS!FLL # # 6;q>//8899GG .   GGG   8z'<+<== 8&} 8 8 edL$6778JtzSV-0 AAA7-C%% D/D  D2-G G65G6c#0K|d|r4t|jdkr|||}|VdSd} ||}|,d|jvr#t |d|}n#ttf$rYnwxYw|rR| dkr:t||}||j _ |||Ed{VdS|VdS)z+infer what a class is returning when calledrdr3Nr__call__zbuiltins.type.__call__)rrrrtrrr&rrr(rar callcontextcalleerinstantiate_class)rrrPrS dunder_callrs rHrzClassDef.infer_call_resultsU   ow 7 7 C .( s8LL 4t 4 4LLLLLLrJTrr]) rrr+ Decoratorsr&builtins_modulerfr rr)rrsrprlookup_upper_framers ` rHrzClassDef.scope_lookup s. t{L$; < < 9((88  LLLLLLL L L ! "K%%T%22EFFE""4v666rJc$d|jDS)zThe names of the parent classes Names are given in the order they appear in the class definition. :type: list(str) c6g|]}|SrE) as_string)rFbnodes rHrIz&ClassDef.basenames..H s":::e!!:::rJr rs rH basenameszClassDef.basenames@ s;:tz::::rJTr@Generator[ClassDef, None, None]c#K|h}|t}|js7|dkrtdddVdS|jD]}|5 ||D]}t |ts#t |tjr|j }n:|j s||vrF| ||V|sb| d|D]&}||urn||vr | ||V'n#t$rYdddwxYw dddn #1swxYwYdS)zIterate over the base classes in prefixed depth first order. :param recurs: Whether to recurse or return direct ancestors only. :returns: The base classes Nbuiltins.objectobjectrKrTr[)rr rar. restore_pathr*rrrrr!rrr)rr@rPyieldedstmtr;grandpas rHrzClassDef.ancestorsJ s& ?&((Gz djjll.??? **1-a0 0 0 0 FJ  D%%''  #'::g#6#6**)'8<<))'5>BB)*1*: (&|*&'11 (#KK000")MMM%%$'.'8'8g'8'V'V**G&$ %&'11 (#KK000")MMMM)**&1       .+*                 s72E4B6D+*E+ E5EEEE E c#K ||dd}n&#t$r||}YnwxYw|D] }||vr|V dS)zIterate over the parents that define the given name. :param name: The name to find definitions for. :type name: str :returns: The parents that define the given name. :rtype: iterable(NodeNG) rKNr)mrorr)rrprPrastroids rHlocal_attr_ancestorszClassDef.local_attr_ancestorsw s 8))!""-II 8 8 8w77III 8!  Gw   s" AAc#VK||D]}||jvr|VdS)aIterate over the parents that define the given name as an attribute. :param name: The name to find definitions for. :type name: str :returns: The parents that define the given name as an instance attribute. :rtype: iterable(NodeNG) rN)rr)rrprPrs rHinstance_attr_ancestorsz ClassDef.instance_attr_ancestors sG~~g~66  Gw---   rJc||jvS)zWhether this class directly inherits from the given node. :param node: The node to check for. :type node: NodeNG :returns: Whether this class directly inherits from the given node. r )rrss rHhas_basezClassDef.has_base stz!!rJcg}||jvr|j|}n3t|||d}|r |j|}d|D}|r|St|||)ahGet the list of assign nodes associated to the given name. Assignments are looked for in both this class and in parents. :returns: The list of assignments to the given name. :rtype: list(NodeNG) :raises AttributeInferenceError: If no attribute with this name can be found in this class or parent classes. NcFg|]}t|tj|SrErr+DelAttrrs rHrIz'ClassDef.local_attr.. rrJr)rr&rr)rrprPrS class_nodes rH local_attrzClassDef.local_attr s 4;  [&FFd77gFFMMJ 1#*40OOVOOO  M%TT7SSSSrJct|j|g}|||D]}||j|z }d|D}|r|St |||)akGet the list of nodes associated to the given attribute name. Assignments are looked for in both this class and in parents. :returns: The list of assignments to the given name. :rtype: list(NodeNG) :raises AttributeInferenceError: If no attribute with this name can be found in this class or parent classes. cFg|]}t|tj|SrErrs rHrIz*ClassDef.instance_attr.. rrJr)rrgetrr)rrprPvaluesrs rH instance_attrzClassDef.instance_attr sd)--dB778866tWEE 6 6J j/5 5FFOOVOOO  M%TT7SSSSrJbases.Instancec td|Drt|Sn#t$rYnwxYwt j|S)zGet an :class:`Instance` of the :class:`ClassDef` node. :returns: An :class:`Instance` of the :class:`ClassDef` node c32K|]}|jtvVdSro)rpEXCEPTION_BASE_CLASSES)rFrOs rHrdz-ClassDef.instantiate_class.. s*LL#3855LLLLLLrJ)rfrr=ExceptionInstancerr rrs rHryzClassDef.instantiate_class sy  LLLLLLL 700666 7    D ~d###sAA AArp class_contextlist[SuccessfulInferenceResult]c|st|||t|j|g}|d|D] }||j|gz }!||jvr,|r*|s(|j|g}|dkr||z }|S|r||||z }|D]{}t|tj r_| d}t|tj r/|j(|||||st||||S)aGet an attribute from this class, using Python's attribute semantic. This method doesn't look in the :attr:`instance_attrs` dictionary since it is done by an :class:`Instance` proxy at inference time. It may return an :class:`Uninferable` object if the attribute has not been found, but a ``__getattr__`` or ``__getattribute__`` method is defined. If ``class_context`` is given, then it is considered that the attribute is accessed from a class context, e.g. ClassDef.attribute, otherwise it might have been accessed from an instance as well. If ``class_context`` is used in that case, then a lookup in the implicit metaclass and the explicit metaclass will be done. :param name: The attribute to look for. :param class_context: Whether the attribute can be accessed statically. :returns: The attribute. :raises AttributeInferenceError: If the attribute cannot be inferred. rTr[ __bases__r)rrrrrrr"_metaclass_lookup_attributecopyrr+rr AnnAssignrrgindex) rrprPrr classnoderSrrs rHrzClassDef.getattr s8 X)wWWW W37t{tR7P7P2Q2QtWEE 5 5I i&**444 4FF 4* * *} *V *-44T::;F{""& M  F d66tWEE EF[[]] 4 4E%!899 4d33dL$:;;4 @RJJv||E22333 X)wWWW W rJi)maxsizecNt}|}t|}||}||fD]X}|rT||krNt |t r9||||}|t|Y|S)zASearch the given name in the implicit and the explicit metaclass.r)rimplicit_metaclassrrrr_get_attribute_from_metaclassupdate)rrprPattrs implicit_metarrOcls_attributess rHrz$ClassDef._metaclass_lookup_attribute s//11 w''NN7N33 !9- 2 2C 2sd{{z#x'@'@{!%!C!CCw!W!W S00111 rJc#K |||d}n#t$rYdSwxYwtj|||D]}t |t s|Vt |t jr|V;|jdkr)t|p|}tj ||Vo|jdkr|Vtj ||VdS)NT)rPrrr>r?) rrr rrrr=PropertyrrDr)rrOrprPrrsrs rHrz&ClassDef._get_attribute_from_metaclass& s# KKgTKJJEE&    FF &ugSAAA 4 4DdK00  $ 011  yM)) +4008D'e444444n,, 'd333333' 4 4s  ++Iterator[InferenceResult]c#T Kt|}||_||} ||||}t |dkr8|d|dd}}| |g fd|Dz}t j|||D] }t|tj sYt|t j r? |j d|tjVb#t$r|VYrwxYwt|t jrg|j}|s||| Ed{V|r9|j|ur||| Ed{V|Vt+||V dS#t$re} |d s$||rtjVn!t1t3| ||| | Yd} ~ dSd} ~ wwxYw) zInfer the possible values of the given variable. :param name: The name of the variable to infer. :returns: The inferred possible values. r)rrKrNc\g|](}|jr|jk&|)SrE)rr)rFrs first_scopes rHrIz%ClassDef.igetattr..[ sH---{-(,{'8'8':':k'I'I'I'I'IrJr__get__)rrP__r)rrrrrrr rrr+r(rrrrurr=rrrrrrhas_dynamic_getattrrr) rrprPrr attributes first_attrr1rrrs @rHrzClassDef.igetattrA sw''!NN7N33 6 dG=QQJ:"")3A 122J (..00 (\---- *--- ".z7$OOO = =!(L,>??=JenEE=/ )11)WEEE#.....3'''&' '*:;;='0H('#+#=#=#'$>$$#'x'<'<'>'>)'K'K$,#=#=#'$>$$',Xt<<<<<B1F8#D >F8 DF8DBF88 H'AH""H'cd} ||d|dS#t$r= |d|d}||cYS#t$rYnwxYwYnwxYwdS)a0Check if the class has a custom __getattr__ or __getattribute__. If any such method is found and it is not from builtins, nor from an extension module, then the function will return True. :returns: Whether the class has a custom __getattr__ or __getattribute__. cb|}|jdkot|ddS)Nrr)rootrpr)rsrs rH_valid_getattrz4ClassDef.has_dynamic_getattr.._valid_getattr s-99;;D9 *Qwt]D/Q/Q QrJ __getattr__r__getattribute__F)rr)rrPr getattributes rHrzClassDef.has_dynamic_getattr s R R R !>$,,}g"F"Fq"IJJ J&    #||,>HHK %~l33333*      us2$* A1&AA1 A+(A1*A++A10A1c t|d}nu#t$rh}t|tr7 |d}n2#t$rt |||wxYwt |||Yd}~nd}~wwxYw|d}t ||}t|g||_ t| ||tj S#t$r?t|tjr#|dkr t"r|cYSt$$rtj cYSwxYw)aAReturn the inference of a subscript. This is basically looking up the method in the metaclass and calling it. :returns: The inferred value of a subscript to this class. :rtype: NodeNG :raises AstroidTypeError: If this class does not define a ``__getitem__`` method. r:rrNr)rrxrd)r"rrrrrrrrwr&rrrur)r+ EmptyNoderrr)rrrPmethodsrr new_contexts rHgetitemzClassDef.getitem s LT=11GG& L L L$)) L P"ll+>??GG/PPP*gFFFCOP'D'BBBKGGGG L +7D99 "-E76"J"J"J  $00{CCTEUVV V   6<#9:: KKMM_445  $ $ $# # # # $sD BBA B A&&BB8-C&&AE-EEc#Ki}tjt|f|D]1}|D]}|j|vr d||j<|V2dS)zIterate over all of the method defined in this class and its parents. :returns: The methods defined on the class. :rtype: iterable(FunctionDef) N)r#r$iterr mymethodsrp)rdonerrs rHrzClassDef.methods s  tTG}}dnn6F6FGG  G))++  9$$"&TY    rJc#jK|D]}t|tr|VdS)zIterate over all of the method defined in this class only. :returns: The methods defined on the class. :rtype: iterable(FunctionDef) N)rrr)rmembers rHrzClassDef.mymethods sE kkmm  F&+..    rJcJ|jrtdddSdS)a<Get the implicit metaclass of the current class. For newstyle classes, this will return an instance of builtins.type. For oldstyle classes, it will simply return None, since there's no implicit metaclass there. :returns: The metaclass. :rtype: builtins.type or None rrKrN)rYr.rs rHrzClassDef.implicit_metaclass s+ = 0!&))!,Q/ /trJct|jD]]} ||D]3}t|tr|jr|j|_d|_n4N#t$rYZwxYw|jrK td|j|DS#ttf$rYdSwxYwdS)aReturn the explicit declared metaclass for the current class. An explicit declared metaclass is defined either by passing the ``metaclass`` keyword argument in the class definition line (Python 3) or (Python 2) by having a ``__metaclass__`` class attribute, or if there are no explicit bases but there is a global ``__metaclass__`` variable. :returns: The metaclass of this class, or None if one could not be found. rTc3NK|] }t|tj|V!dSrorrrs rHrdz.ClassDef.declared_metaclass.. sI%dD,@AArJN) r r*rrr!rH_metaclass_hackrr&r()rrPrcr;s rHr]zClassDef.declared_metaclass s J  D #zz'z::G!'844*1*</3,!     ?   $ 5 5g 5 F F #M2   tt ts$A A A#"A#.1B B54B5r:set[ClassDef] | Nonec|t}||||}|6||D]}||vr||}|n |SNr)rrr]r_find_metaclass)rr:rPrrs rHrzClassDef._find_metaclass$ s <55D '''88 =...99  %%"22488E( rJc.||S)zGet the metaclass of this class. If this class does not define explicitly a metaclass, then the first defined metaclass in ancestors will be used instead. :returns: The metaclass of this class. r)rr8s rHrzClassDef.metaclass4 s##G#444rJc|jSro)rrs rHhas_metaclass_hackzClassDef.has_metaclass_hack? s ##rJc#Kd|jvrdS|dD];}tD])} ||n#t$rY&wxYw5t |t jr |jr|V[t|dslt |t j rd|j D}n| }t |tjr|s|cS|D]k} |D]C}t |t jrt |jt s7|js?|VD\#t"$rYhwxYw=dS)z+Return an iterator with the inferred slots. __slots__Nrmcg|] }|d SrCrE)rFitems rHrIz$ClassDef._islots..\ s:::d$q':::rJ)rr ITER_METHODSrrrr+r(rhasattrrorprmrrr*rr)rslotsrrrVr1s rH_islotszClassDef._islotsB s dk ) )4]];//+ + E$  MM$'''E.H%!344 ; KKK5(++ %!233 (::ek:::&$"677      $'IIKK'')$l&8  %!+HNC!@!@%%'~%$&'&H ts$A AA5AE EEc|jstd|} t|}n@#t$r3}|jr!|jddvr|jdcYd}~SYd}~dSd}~wwxYw|gt |zS)N8The concept of slots is undefined for old-style classes.r)rN)rYNotImplementedErrorrr&r(rr)rrfirstrs rH_slotszClassDef._slotsu s} %J   KKEE   x #CHQKz99x{""""""44444   we$$s< A9"A4(A94A9cJd d}|jstd |}n"#t$r}td|d}~wwxYwt ||}t d |DsdSt t|d S) aYGet all the slots for this node. :returns: The names of slots for this class. If the class doesn't define any slot, through the ``__slots__`` variable, then this function will return a None. Also, it will return None in the case the slots were not inferred. :rtype: list(str) or None rlist[ClassDef]rZ$Iterator[node_classes.NodeNG | None]c3K|D]P}|dkr |}n#t$rY=wxYw| |Ed{VLdVQdS)Nr)rarr)rrO cls_slotss rH grouped_slotsz%ClassDef.slots..grouped_slots s  99;;"333 # II*H((((((((((JJJJ  s6 AArz)Cannot get slots while parsing mro fails.Nc3K|]}|duV dSrorE)rFslots rHrdz!ClassDef.slots.. s'664t#666666rJc|jSro)r)rs rHz ClassDef.slots.. s4:rJ)rp)rrrZr)rYrrrrallsortedr)rrrr'rs rHrzClassDef.slots s     } %J  ((**CC   %;   ]]3''((6666666 4c%jj&=&=>>>>s1 AA  Ac# K|t}|js7|dkrtdddVdS|jD]} t d||D}n#ttf$rYVwxYwt|tj r|j }t|ts|j s|V|jEd{VdS)NrrrKrc3RK|]"}t|tr|j|V#dSrorrs rHrdz+ClassDef._inferred_bases.. sF&q%0067W_5D___rJr)rr rar.r&r*rrr(rrrrr!)rrPrr;s rH_inferred_baseszClassDef._inferred_bases sE ?&((Gz djjll.??? **1-a0 0 0 0 FJ ) )D !ZZ Z@@ #M2    '5>22 +!*gx00 < ) "=((((((((# ) )s?BB/.B/ct||}g}|D]{}||ur ||}||4#t$r;t||}||YxwxYw|gg|z|gz}tt |||}t|t|||Sr) rr _compute_mrorQrrr|rlrX)rrPrirhrcrr unmerged_mros rHrzClassDef._compute_mro sd2272CCDD " , ,Dt|| ,'''88  %%%%& , , , !!@!@AA   +++++ ,x)+~.>> 0tWMMNN  ...tW555s+AAB! B!rc.||S)a*Get the method resolution order, using C3 linearization. :returns: The list of ancestors, sorted by the mro. :rtype: list(NodeNG) :raises DuplicateBasesError: Duplicate bases in the same class base :raises InconsistentMroError: A class' MRO is inconsistent r)rr8s rHrz ClassDef.mro s   111rJrcdS)zDetermine the boolean value of this node. :returns: The boolean value of this node. For a :class:`ClassDef` this is always ``True``. TrEr8s rHr9zClassDef.bool_value r:rJc#K|j |jV|jEd{V|j |jEd{V|jEd{VdSro)rr rFrrs rHr=zClassDef.get_children sx ? &/ ! ! !: = $} $ $ $ $ $ $ $9rJc|d|jD}ttj|S)Nc3>K|]}|VdSro)r)rFrs rHrdz-ClassDef._get_assign_nodes.. s?! ! /9J ( ( * *! ! ! ! ! ! rJ)rrr#r$ from_iterable)rchildren_assign_nodess rHrzClassDef._get_assign_nodes sD! ! =AY! ! ! IO112GHHIIIrJrrrBrrc|Sr?rErs rHrzClassDef.frame r@rJr/r0rArB)rZrRrh)rrGrrrrrorEr1)rZrbrDr#rFrC)TN)r@rrPrrZr)rZr)NT)rprrPrrrrZr)rprrPrrrrZr)rPrrZrGri)r:rrPrrZrG)rPrrZrrkrG)JrrHrIrrJrr#rrrHrKrr!r~rArrLrMrJrNrOrrrPrrLrr\rYr5rrrrrrrrtrrrrrrrrrryrrrrrrrrrrr]rrrrrr5rrrrr9r=rrrQrRs@rHrrs   NOJ$ E $J$$$$O D 8    D@M1I'^',UVVV Q2Q2Q2Q2Q2Q2Q2Q2WVQ2f7666 X ZZ   "#'/'%)!%/'/'/'/'/'/'b$Ix QH  " " " " "_ "_ . . .#### X X X X X...`+++++:17171717f;;X;GK+++++Z*     """"TTTTT.TTTTT, $ $ $ $ ,0" 99999vYt   444<,0" HHHHHT23$3$3$3$3$j      26#####LUY 5 5 5 5 5$$$111f%%%"*?*?*?X%)%)%)%)%)N66666022222JJJ :>rJr)rRrYrZr[ro)r{rrZrr#)ir __future__rrr#rsysrcollections.abcrr functoolsrtypingrrr r r rr rrNr astroid.constrrrrrastroid.contextrrrrastroid.exceptionsrrrrrrrr r!!astroid.interpreter.dunder_lookupr"astroid.interpreter.objectmodelr#r$r%astroid.managerr& astroid.nodesr'r(r)r*r+ astroid.nodes.scoped_nodes.mixinr,r- astroid.nodes.scoped_nodes.utilsr.astroid.nodes.utilsr/astroid.typingr0r1r2 version_infor5r6typing_extensionsastroid.decoratorsr7r8r frozensetr lazy_importr=rrBrXrlr|rrrTrnryrrFilterStmtsBaseNoderMultiLineBlockNode Statementrrrr9rArDrrErJrHrs  #"""""  ////////GGGGGGGGGGGGGG000000OOOOOOOOOOOOOO                      544444RRRRRRRRRR******MMMMMMMMMMMMMMQQQQQQQQ;;;;;;((((((TTTTTTTTTTv))))))))))))DDDDDD+ "K#ABB $ 9 % %iTTT WT]]###L!.!.!.!.H   (   hhhhh hhhVP#P#P#P#P#%P#P#P#f`#`#`#`#`#!`#`#`#FQ#Q#Q#Q#Q# Q#Q#Q#hA#A#A#A#A#!A#A#A#H"""JRCRCRCRCRC[ ,.>RCRCRCjccccc+0+2GcccL{&     @D([[[[[#%5{7L[[[[[rJ