TL i+GrdZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZdd lmZdd lmZeZGd d eZGddZGddeZd"dZGddeZGddeZGddeZGddeZGddZ dZ!Gdd Z"e"gZ#d!Z$y)#a4 Values are the "values" that Python would return. However Values are at the same time also the "values" that a user is currently sitting in. A ValueSet is typically used to specify the return of a function or any other static analysis operation. In jedi there are always multiple returns and not just one. )reduce)add) zip_longest)Name)debug)clean_scope_docstringSimpleGetItemNotFound) safe_property)%inference_state_as_method_param_cache)memoize_methodc eZdZy) HasNoContextN)__name__ __module__ __qualname___/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/base_value.pyrrsrrc|eZdZdZdZdZdZdZddZdZ dd Z dd Z d Z d Z dd ZdZdZedZy)HelperValueMixincv|}|j|jS |j|S|j}N)parent_context as_context)selfvalues rget_root_contextz!HelperValueMixin.get_root_contextsF    '##% %##+ ((Erc<|jj||S)N) argumentsinference_stateexecuterr s rr#zHelperValueMixin.execute(s##++DI+FFrcddlm}||Dcgc]}t|gc}}|jj ||Scc}w)Nr)ValuesArguments)jedi.inference.argumentsr&ValueSetr"r#)r value_listr&rr s rexecute_with_valuesz$HelperValueMixin.execute_with_values+s@<#J$O5Xug%6$OP ##++D)<<%PsAc"|jSrr*rs rexecute_annotationz#HelperValueMixin.execute_annotation0s''))rct|gSrr(r-s rgather_annotation_classesz*HelperValueMixin.gather_annotation_classes3srNcZtjd|j||DS)Nc3<K|]}|jywrinfer.0 lazy_values r z:HelperValueMixin.merge_types_of_iterate..7s!"     " r( from_setsiterate)rcontextualized_nodeis_asyncs rmerge_types_of_iteratez'HelperValueMixin.merge_types_of_iterate6s.!!" "ll+>I"   rc#Kt|tr|nd}|j|Ed{|jr6ddlm}|t |hD]}|jEd{yy7K7 w)N) origin_scoper)convert_values) isinstancer get_filtersis_stub!jedi.inference.gradual.conversionrCr()r name_or_strrBrCcs r_get_value_filtersz#HelperValueMixin._get_value_filters<ss&0d&C{ ###>>> <<> H#HdV$45 +==?** +  ? +s"*A<A8AA</A:0 A<:A<cddlm}|j|}|j||}t j d||||S)Nr)finderzcontext.goto %s in (%s): %s)jedi.inferencerLrJ filter_namerdbg)rrH name_contextanalysis_errorsrLfiltersnamess rgotozHelperValueMixin.gotoEs?)))+6""7K8 /dEJ rcZ||}|j|||}tjd|D}|s/t|tr |j n|}|j |}|s-|s+|r)t|trddlm}|j|||tjd|||S)zZ :param position: Position of the last statement -> tuple of line, column c3<K|]}|jywrr4)r7names rr9z6HelperValueMixin.py__getattribute__..Ts#CTDJJL#Cr:ranalysisz context.names_to_types: %s -> %s) rTr(r<rDrrpy__getattribute__alternativesrMrYadd_attribute_errorrrO) rrHrPpositionrQrSvaluesnrYs rpy__getattribute__z#HelperValueMixin.py__getattribute__Ls  L +|_E###CU#CC%/ T%B !! A88;FV+t,3,, $ 5 4eVD rct|jd}|stjd||jS)N __await__z"Tried to run __await__ on value %s)r_rwarningr*)rawait_value_sets r py__await__zHelperValueMixin.py__await__as311+> MM> E2244rc.|jjSr)rW string_namer-s r py__name__zHelperValueMixin.py__name__gsyy$$$rcNtjd||r}ddlm}t ||j dj j dj j dj jgS|j|S)Nz iterate %sr)LazyKnownValues __aiter__ __anext__ra) rrOjedi.inference.lazy_valueriiterr_r*py__stop_iteration_returns py__iter__)rr>r?ris rr=zHelperValueMixin.iteratejs ,%  A++K8LLN++K89L9L9N++K89L9L9N335  233rc&tjd|d|d5|jD]4}|j|stjdddddytjdd dddy#1swYyxYw) Nzsubclass matching of z <=> BLUE)colorzmatched subclass TrueTzmatched subclass FalseF)rincrease_indent_cm py__mro__ is_same_classrO)r class_valueclss ris_sub_class_ofz HelperValueMixin.is_sub_class_ofzs  % %$P[&\,24 ~~' $$[1II5VD     II.f =   s%BB%BBczt|jtjk7r|j|S||k(Sr)typerur)rclass2s rruzHelperValueMixin.is_same_classs6 < % %)9)G)G G''- -v~rc&|j|i|Sr) _as_contextrargskwargss rrzHelperValueMixin.as_contextst000rNF)NT)NNT)rrrrr#r*r.r1r@rJrTr_rdrgr=rxrur rrrrrrsg)G= *  +KO+/*5 %4  11rrceZdZdZdZdZdZd"dZdZdZ d"dZ d"dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZefdZdZdZdZdZdZdZdZ dZ!dZ"e#dZ$d#d Z%d!Z&y)$Valuez* To be implemented by subclasses. Nnot_defined_please_report_bugc ||_||_yr)r"r)rr"rs r__init__zValue.__init__s.,rcrddlm}|j|jd|jd|zt S)NrrXztype-error-not-subscriptablez+TypeError: '%s' object is not subscriptablemessage)rMrYrcontextnode NO_VALUES)rindex_value_setr>rYs r py__getitem__zValue.py__getitem__s;+  ' ' *  $ $ADH  rctrr )rindexs rpy__simple_getitem__zValue.py__simple_getitem__s##rc|2ddlm}|j|jd|jd|zt gS)NrrXztype-error-not-iterablez&TypeError: '%s' object is not iterabler)rMrYrrrrm)rr>rYs rrozValue.py__iter__sE  * / LL#++)#((@4G  I Bxrc$|j|Sr)ro)rr>s r py__next__zValue.py__next__s233rcgSrrr-s rget_signatureszValue.get_signaturess rcyrrr-s ris_classzValue.is_classrcyrrr-s ris_class_mixinzValue.is_class_mixinrrcyrrr-s r is_instancezValue.is_instancerrcyrrr-s r is_functionzValue.is_functionrrcyrrr-s r is_modulezValue.is_modulerrcyrrr-s r is_namespacezValue.is_namespacerrcyrrr-s r is_compiledzValue.is_compiledrrcyrrr-s ris_bound_methodzValue.is_bound_methodrrcyrrr-s ris_builtins_modulezValue.is_builtins_modulerrcy)z Since Wrapper is a super class for classes, functions and modules, the return value will always be true. Trr-s r py__bool__zValue.py__bool__s rcx |jjt|jS#t$rYywxYw)N) tree_node get_doc_noderAttributeErrorr-s r py__doc__zValue.py__doc__s9 9 NN ' ')8 8  s - 99c2|turtd|z|S)Nz'There exists no safe value for value %s)sentinel ValueError)rdefaults rget_safe_valuezValue.get_safe_values h FMN Nrc>tjd|||tS)Nz!%s not possible between %s and %srrbr)rotheroperators rexecute_operationzValue.execute_operations 98T5Qrc:tjd|tS)Nzno execution possible %srr$s r py__call__zValue.py__call__s 0$7rc:tjd|tS)Nz0Not possible to return the stop iterations of %srr-s rrnz Value.py__stop_iteration_returnss H$OrctS)zH For now a way to add values in cases like __getattr__. )r)rrHs rrZz$Value.py__getattribute__alternativess rcFtjd|t|gS)NzNo __get__ defined on %s)rrbr()rinstancervs r py__get__zValue.py__get__s 0$7rctSr)NotImplemented)rcalling_instancerrvs rpy__get__on_classzValue.py__get__on_classsrcyrrr-s rget_qualified_nameszValue.get_qualified_namessrc6|jjSr)rrFr-s rrFz Value.is_stubs""**,,rctr)rr-s rr}zValue._as_context srctrNotImplementedErrorr-s rrWz Value.names!!rcyrr)radd_class_infos r get_type_hintzValue.get_type_hintsrciS)an When the current instance represents a type annotation, this method tries to find information about undefined type vars and returns a dict from type var name to value set. This is for example important to understand what `iter([1])` returns. According to typeshed, `iter` returns an `Iterator[_T]`: def iter(iterable: Iterable[_T]) -> Iterator[_T]: ... This functions would generate `int` for `_T` in this case, because it unpacks the `Iterable`. Parameters ---------- `self`: represents the annotation of the current parameter to infer the value for. In the above example, this would initially be the `Iterable[_T]` of the `iterable` parameter and then, when recursing, just the `_T` generic parameter. `value_set`: represents the actual argument passed to the parameter we're inferred for, or (for recursive calls) their types. In the above example this would first be the representation of the list `[1]` and then, when recursing, just of `1`. r)r value_sets rinfer_type_varszValue.infer_type_varss 6 rrT)'rrr__doc__r array_typeapi_typerrrrorrrrrrrrrrrrrrrrrrnrZrrrrFr}propertyrWrrrrrrrsIJ.H- $49&.   -""rrNc\tjd|j||DS)z Calls `iterate`, on all values but ignores the ordering and just returns all values that the iterate functions yield. c3<K|]}|jywrr4r6s rr9z!iterate_values..8s!  r:r?r;)r]r>r?s riterate_valuesr3s2    ..)s:EE*,$-$2rrc2eZdZeedZdZdZy)LazyValueWrappercxtjd5|jcdddS#1swYyxYw)NzResolve lazy value wrapper)rrs_get_wrapped_valuer-s rrzLazyValueWrapper._wrapped_valueTs4 % %&B C -**, - - -s09c4d|jjzS)Nz<%s>) __class__rr-s r__repr__zLazyValueWrapper.__repr__Zs0011rctrrr-s rrz#LazyValueWrapper._get_wrapped_value]s!!rN)rrrr r rrrrrrrrSs&--2"rrceZdZdZdZy) ValueWrapperc||_yr)r)r wrapped_values rrzValueWrapper.__init__bs +rcN|jjd|jdS)N())rrrr-s rrzValueWrapper.__repr__es>>22D4G4GHHrN)rrrrrrrrrras ,Irrc$eZdZfdZdZxZS) TreeValuec4t|||||_yr)superrr)rr"rrrs rrzTreeValue.__init__js .9"rcPd|jjd|jdS)N<: >)rrrr-s rrzTreeValue.__repr__ns!^^44dnnEEr)rrrrr __classcell__)rs@rrris#Frrc$eZdZdZdZdZdZy)ContextualizedNodec ||_||_yr)rr)rrrs rrzContextualizedNode.__init__ss  rc6|jjSr)rrr-s rrz#ContextualizedNode.get_root_contextws||,,..rcL|jj|jSr)r infer_noderr-s rr5zContextualizedNode.inferzs||&&tyy11rcjd|jjd|jd|jdS)Nrrz in r)rrrrr-s rrzContextualizedNode.__repr__}s!#'>>#:#:DIIt||TTrN)rrrrrr5rrrrrrrs/2Urrct}t}|D]a}|jd}t|tt t ttfvr ||j|z}Q|j|c|s|s||jt||z}tjd||S#t$rYXwxYw)N)rzpy__getitem__ result: %s)rsetrrzfloatintstrslicebytesrr rrr(rrO)r index_valuesr>result unused_values index_valuers r_getitemrs FEM# ' **4*8 ;5#sE59 9 %44U;; +& 'L%%% ] #    II(&1 M)  sB11 B=<B=ceZdZdZedZedZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZddZdZdZdZdZdZdZdZdZddZdZy)r(cVt||_|D]}t|tsJyr) frozenset_setrDr()riterablers rrzValueSet.__init__s-h'  3E!%2 22 3rc6|j|}||_|Sr)__new__r)rw frozenset_rs r_from_frozen_setzValueSet._from_frozen_sets{{3  rct}|D]0}t|tr||jz}#|t |z}2|j t |S)z7 Used to work with an iterable of set. )r rDr(rrr )rwsets aggregatedset_s rr<zValueSet.from_setssX U  .D$)dii' io-  . ##Ij$9::rcR|j|j|jzSrr rrrs r__or__zValueSet.__or__ $$TYY%;<.s#>qCF#>s)joinrr-s rrzValueSet.__repr__s $))#>DII#>>??rcL|jt||jSr)rfilterr)r filter_funcs rr;zValueSet.filters~~f[$))<==rcfd}|S)NcTjfdjDS)Nc3BK|]}t|iywr)r)r7rrrrWs rr9z7ValueSet.__getattr__..mapper..s,"%t$d5f5")r<r)rrrWrs``rmapperz$ValueSet.__getattr__..mappers%>>"!YY" rr)rrWrAs`` rrzValueSet.__getattr__s   rc4|j|jk(Sr)rr's r__eq__zValueSet.__eq__syyEJJ&&rc&|j| Sr)rCr's r__ne__zValueSet.__ne__s;;u%%%rc,t|jSr)hashrr-s r__hash__zValueSet.__hash__r.rc:td|jDS)Nc3<K|]}|jywr) py__class__)r7rIs rr9z'ValueSet.py__class__..s;A ;r:)r(rr-s rrKzValueSet.py__class__s;;;;rNc#Kddlm}|jDcgc]}|j||}}t |D]}||Dcgc]}|| c}ycc}wcc}ww)Nr)get_merged_lazy_valuer)rlrMrr=r)rr>r?rMrI type_iters lazy_valuesls rr=zValueSet.iteratesnCQUQZQZ[Aaii 3hiG[ [& 3 K''9q1=9  \:s!A&AA&A! A! A&cTtjfd|jDS)Nc3VK|] }|jj|"ywrr!)r7rIr s rr9z#ValueSet.execute..s$!]a!"3"3";";Ay"I!]s&)r(r<rr$s `rr#zValueSet.executes!!!!]SWS\S\!]]]rcXtjfd|jDS)Nc3BK|]}|jiywrr,r7rIrrs rr9z/ValueSet.execute_with_values..s$!\Q"7!"7"7"H"H!\r@rSr~s ``rr*zValueSet.execute_with_valuess!!!!\RVR[R[!\\\rc ~tt|jDcgc]}|j|i|c}gScc}wr)rrrrT)rrrrIs rrTz ValueSet.gotos3cTYYGFAFFD3F3GLLGs: cXtjfd|jDS)Nc3BK|]}|jiywr)r_rVs rr9z.ValueSet.py__getattribute__..s$![A"6!"6"6"G"G![r@rSr~s ``rr_zValueSet.py__getattribute__s!!!![QUQZQZ![[[rcXtjfd|jDS)Nc3<K|]}t|giywr)rrVs rr9z$ValueSet.get_item..s !R1(1">t">v">!RsrSr~s ``rget_itemzValueSet.get_items!!!R !RRRrc|jg}|jD]} t||}||z}|S#t$rY)wxYwr)rrrr)r function_namerrImethods r try_mergezValueSet.try_merges^NN2&  &A & M2VX%  & "  s < AActj|jDcgc]}|jc}Scc}wr)r(r<rr1)rrIs rr1z"ValueSet.gather_annotation_classess.!!$))"TQ1#>#>#@"TUU"Ts<cp|jDcgc]}|jD]}|c}}Scc}}wr)rr)rrIsigs rrzValueSet.get_signaturess/!YYE!2B2B2DE3EEEEs2c\|jDcgc]}|j|}}ttd|}t |dk(r|dSd|v}|r|j dt |dk(ryt |dk(r|d}nddj |z}|rd|z}|Scc}w)N)rrNonez Union[%s]r6z Optional[%s])rrsortedr;r3remover9)rrvt type_hintsoptionalr8s rrzValueSet.get_type_hintsEIYY OQ__N_ ; O OF4O, z?a a= Z'    f % z?a  _ !1 Adii 33A "A# PsB)chddlm}i}|jD]}|||j||S)Nr)merge_type_var_dicts)!jedi.inference.gradual.annotationrnrr)rrrn type_var_dictrs rrzValueSet.infer_type_varss>J YY E %%i0   rrr)rrrrrr r<r(r+r-r1r4rr;rrCrErHrKr=r#r*rTr_r\r`r1rrrrrrr(r(s3   ; ;==@>'&<^]M\S VF( rr(cfd}|S)Nc&t|i|Srr0)rrfuncs rwrapperz&iterator_to_value_set..wrapper+sd-f-..rr)rsrts` riterator_to_value_setru*s/ Nrr)%r functoolsrrr itertoolsrparso.python.treerjedirjedi.parser_utilsrjedi.inference.helpersr jedi.inference.utilsr jedi.inference.cacher jedi.cacher objectr Exceptionrrrrrrrrrrr(rrurrrrs!"38.F% 8 9 o1o1da aH2(2* "( "I$IFF U U6HHV RL r