TL igdZddlmZddlmZddlmZddlmZmZm Z m Z ddl m Z ddl mZddlmZeZd Zee ej(d Zd ZGd de ZGdde ZGddeZGddeZy)a A module to deal with stuff like `list.append` and `set.add`. Array modifications ******************* If the content of an array (``set``/``list``) is requested somewhere, the current module will be checked for appearances of ``arr.append``, ``arr.insert``, etc. If the ``arr`` name points to an actual array, the content will be added This can be really cpu intensive, as you can imagine. Because |jedi| has to follow **every** ``append`` and check whether it's the right array. However this works pretty good, because in *slow* cases, the recursion detector and other settings will stop this process. It is important to note that: 1. Array modifications work only in the current module. 2. Jedi only checks Array additions; ``list.pop``, etc are ignored. )debug)settings) recursion)ValueSet NO_VALUESHelperValueMixin ValueWrapper)LazyKnownValues)infer_call_of_leaf)inference_state_method_cachecB|jdvrtSt||S)zI Just a mapper function for the internal _internal_check_array_additions )listset) array_typer_internal_check_array_additions)contextsequences i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/value/dynamic_arrays.pycheck_array_additionsr"s#/1 *7H ==)defaultc ddlmtjd|zd|j }t j r|jrtjddtSfd}t jdc}t _ |jjd k(}|rgd nd d g}t}|D]D} |jj|} | D]} |j} | j| jcxkr| j ksn<| j"} | j"} | j$j'| } | j$|d z}|j(dk7s$|j$ddk7s|j$d dk(r|j-| }t/j0|j2| 5}|r,t5|| d}||vr||||j$d |z}ddd G|t _ tjd|d|S#t*$rYUwxYw#1swYcxYw#t6$rYwxYw)zr Checks if a `Array` has "add" (append, insert, extend) statements: >>> a = [""] >>> a.append(1) r argumentszDynamic array search for %sMAGENTA)colorzDynamic array search aborted.cHtj|j||j}t }|dvr|dd}|dvr|D]\}}|j ||S|dvr4|D]/\}}|t |j jz}1|S)N)insert)appendaddr)extendupdate)r TreeArgumentsinference_stateunpackrr!inferiterate)rarglistadd_nameparamsresultkey lazy_valuers rfind_additionsz7_internal_check_array_additions..find_additions<si--g.E.EwPWX__ab z !ABZF 2 2#) 'Z :& '  - -#) <Z#j..088:;; < rFr)r r"rr!r#rtrailer()T)cut_own_trailerNzDynamic array result %s)jedi.inferencerrdbgget_root_contextrdynamic_array_additions is_compiledr dynamic_params_for_other_modulesname string_namer tree_nodeget_used_names start_posend_posparentchildrenindextype IndexErrorcreate_contextrexecution_allowedr%r KeyError)rrmodule_contextr/temp_param_addis_list search_names added_typesr*possible_namesr: value_noder0power trailer_posexecution_trailerrandom_contextallowedfoundrs @rrr+sN) II+h6iH--/N  + +~/I/I/K 1C  115>NH=mm''61G6=2E8CTL%K &% +55DDFxPN' $.. ",,t~~R @R@RR++#nn227; !(-{Q(G%)--:099!<C099!<C !(!7!7!=001H1H%P T[ 2* ,0! $u,'> . 1 : :1 = (,K  '  &R1?H- II'IF 9"  -   s0I H, /H<, H98H9<I IIc^t||}ddlm}|jt |ggS)z$Used for set() and list() instances.rr)_DynamicArrayAdditionsr4rValuesArgumentsr)instancerais rget_dynamic_array_instancerZ~s+ ) 4B(  $ $htn%5 66rc,eZdZdZdZdZddZddZy) rVaj Used for the usage of set() and list(). This is definitely a hack, but a good one :-) It makes it possible to use set/list conversions. This is not a proper context, because it doesn't have to be. It's not used in the wild, it's just used within typeshed as an argument to `__init__` for set/list and never used in any other place. c ||_||_yN) _instance _arguments)selfrXrs r__init__z_DynamicArrayAdditions.__init__s!#rch|jjjjd\}|S)Ntuple)r^r%builtins_modulepy__getattribute__)r`tuple_s r py__class__z"_DynamicArrayAdditions.py__class__s*..00@@SST[\ rNc#JK|j} t|j\}}|jj Ed{ddlm}t||r+t|j|j}|Ed{yy7B#t $rYKwxYw7w)Nr)r$) r_nextr&r'r( StopIterationjedi.inference.argumentsr$ isinstancerrr^)r`contextualized_noder_r.r$ additionss r py__iter__z!_DynamicArrayAdditions.py__iter__sOO  4 !1!1!34MAz"'')113 3 3: i /7 8I8I4>>ZI  0 4    !s? B#B!B# B;B# B! B# BB#BB#c$|j|Sr])rp)r`rmis_asyncs rr(z_DynamicArrayAdditions.iterates233rr])NF)__name__ __module__ __qualname____doc__rargrpr(rrrVrVs$ !4rrVc*eZdZfdZdZdZxZS) _Modificationc@t||||_||_yr])superra_assigned_values_contextualized_key)r` wrapped_valueassigned_valuescontextualized_key __class__s rraz_Modification.__init__s  ' /#5 rcT|jj|i||jzSr])_wrapped_value py__getitem__r|)r`argskwargss rrz_Modification.py__getitem__s+0t""00$A&ADDYDYYYrc|jjDcgc]}|jt}}||vr |jS|j j |Scc}wr])r}r'get_safe_value _sentinelr|rpy__simple_getitem__)r`rBvactuals rrz"_Modification.py__simple_getitem__sl--335    Y '   F?(( (""77>>  sA&)rsrtrurarr __classcell__)rs@rryrys6 Z?rryceZdZddZdZy)DictModificationNc#rK|jj|Ed{|jy7wr])rrpr}r`rms rrpzDictModification.py__iter__s3&&112EFFF&&& Gs 757cl|jj|jjzSr])rget_key_valuesr}r')r`s rrzDictModification.get_key_valuess+""113d6N6N6T6T6VVVrr])rsrtrurprrwrrrrs 'WrrceZdZddZy)ListModificationNc#K|jj|Ed{t|jy7wr])rrpr r|rs rrpzListModification.py__iter__s8&&112EFFFd3344 GsA>Ar])rsrtrurprwrrrrs5rrN)rvjedirrr4rjedi.inference.base_valuerrrr jedi.inference.lazy_valuer jedi.inference.helpersr jedi.inference.cacher objectrrincrease_indentrrZrVryrrrwrrrs*$55= H >i0N1Nb7!4-!4H?L?&W}W5}5r