TL i*$ddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z hdZd Zdd Zd Zd Zd ZdZdZdZ d dZdZdZdZdZddZeeZdZdZdZ dZ!dZ"e"dZ#e"dZ$e"dZ%y)!N) literal_eval)cleandocWeakKeyDictionary)tree) parser_cache) split_lines>atomexprtermtestpowerfactorfuncdefor_testand_exprand_testclassdefnot_testxor_expr atom_expr arith_expr comparison shift_expr import_from import_name) tryexceptfinallyelseifelifwithforwhilecNg}|j}|dk(rE|j}|dur/|jjdk7r|dk7r|j||S|dk(r4|j||jD]}|t |dz }|S|dk(r6|jd d k(r"|jd }|d k7r|t |z }|S |j}|jt vr|s|j||D]}|t ||z }|S#t$rY|SwxYw) z For static analysis. nameFparam= expr_stmtT) last_added decorator)()type get_next_leafparentappendchildrenget_executable_nodes_EXECUTE_NODESAttributeError)noder+resulttyp next_leafchildr5s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/parser_utils.pyr6r6sXF ))C f}&&(  4;;#3#3w#>9PSCS MM$ 2 M1   d]] CE *5TB BF C( M%  ==  #==$Ds{.t44 M B}}HyyN*: d#! B.ujAA B M   M s D D$#D$c#K||jd} |jdk(r|jdn$|jdk(r|n|jdk(sy|jd}Uw)Ncomp_for sync_comp_forcomp_ifr5r1)rAlasts r>get_sync_comp_forsrG:sl N   R D  99 "--" " YY/ )Ji' }}R  sA*A,c:|jdjdk(S)z Returns True if only one name is returned: ``for x in y``. Returns False if the for loop is more complicated: ``for x, z in y``. :returns: bool rBr'rE)for_stmts r>for_stmt_defines_one_namerJGs    Q  $ $ ..c"|j}|j|cxkr|jkstdtdd}t|jD]3\}}||jkr|cS|j }|t vs2|}5y)Nz!The node is not part of the flow.) start_posend_pos ValueError enumerater5get_first_leaf_FLOW_KEYWORDS) flow_noder9rMkeywordir= first_leafs r>get_flow_branch_keywordrWQsI   ) @y/@/@ @<== A<==Gi001!5 u &N))+  ' G ! rKcd|j}|tt|jSy)z3 Returns a cleaned version of the docstring token. ) get_doc_nodersafe_literal_evalvalue) scope_noder9s r>clean_scope_docstringr^`s0  " " $D  )$**566 rKc|jdk(ri|j}|j}|K|jdk(r<|jd}|jdk(rt t |j Sy)Nr* simple_stmtrstringrY)r1r3get_next_siblingr5rr[r\) tree_node maybe_strings r>find_statement_documentationrelss~~$$$  113  #  M1+44Q7 $$0#$5l6H6H$IJJ rKcX|ddj}|ddk(s|dvryt|S)Nrf)frrfrY)lowerr)r\ first_twos r>r[r[xs7bq !I|si<7  rKc|(|jdk(rd}n|jj}|j}|r|dd}ddj d|Dj zdz}t jd d |}|jr |sd |jjz}nd}||z|z}d j tj||S) z Generate a string signature of a function. :param width: Fold lines if a line is longer than this value. :type width: int :arg func_name: Override function name when given. :type func_name: str :rtype: str NlambdefzrBr0rYc3<K|]}|jywN)get_code).0r(s r> z get_signature..s;5enn&;sr.z\s+ z -> ) r1r'r\ get_paramsjoinstripresub annotationrqtextwrapwrap) rwidth call_stringomit_first_paramomit_return_annotationparamsprtypecodes r> get_signaturers <<9 $$K!,,,,K    !F bgg;F;;AACCcIA vsAA"8**3355 ?U "D 99X]]4/ 00rKc |j}|D]}t||y#t$r|xj|z c_YywxYw)z$ Move the `Node` start_pos. N)r5mover8line)r9 line_offsetr5cs r>rrsJ!== !A K  ! ! [ !s "AAc |jdk(r(|jdjj}n|jdk(r(|jdjj}nm|jdk(r6|jdjj j}n(|j j j}d|vry||jdd}d |vr|d|jd }d |vr|d|jd }|S#t $rYyt$rYywxYw) zl returns (as string) any comment that appears on the same line, after the node, including the # rI with_stmtrN# ru) r1r5rQprefixr2 get_last_leafr8rOindex)r9 whitespacecomments r>get_following_comment_same_liners-  99 "q)88:AAJ YY+ %q)88:AAJ YY) #q)88:HHJQQJ++-;;=DDJ *))#./0G w.7==./ w.7==./ N  sCD(( D>3D>=D>cd|j}|dk(r|jdjdk7S|dvS)NrArBrC) file_inputrrrnrC)r1r5)r9ts r>is_scopers8 AJ}}Q$$77 Q QQrKc,tdfd }|S)Nc| ||S |} ||S#t$r ix}|<YwxYw#t$r||x}||<|cYSwxYwrp)KeyError)parso_cache_noder9 include_flows for_moduler:cachefuncs r>wrapperz(_get_parent_scope_cache..wrappers  #m, , 6/0J d# #  635 5J/0 6  (,T=(A AFZ%M s/,,A  A Fr)rrrs` @r>_get_parent_scope_cachers  E  NrKcj}|y t|r|jdvr|jj d}|j|j j k\rzjjdk(rjj k(r |Sjjdk(rjjdk(r |S|j}|S|rMt|tjr3|jdk(r"tfd|jDs|S|j}3) z' Returns the underlying scope. N)rrrn:r(tfpdefrif_stmtc3zK|]2}|jjcxkxr|jknc4ywrp)rMrN)rrnr9s r>rsz#get_parent_scope..s2= !KK4>>EAIIEE=s8;) r3rr1r5rrMr' isinstancerFlowanyget_test_nodes)r9rscopers` r>get_parent_scopers  KKE }  E?zz??,,S1>>%(22dnnD{{''72t{{7G7G47O L ))X5$++:N:Nq:QUY:YL!&  L z%;JJ)+=%*%9%9%;==  + rKc.t||jS)z Basically access the cached code lines in parso. This is not the nicest way to do this, but we avoid splitting all the lines again. )get_parso_cache_nodelinesgrammarpaths r>get_cached_code_linesrs  . 4 44rKc.t|j|S)z This is of course not public. But as long as I control parso, this shouldn't be a problem. ~ Dave The reason for this is mostly caching. This is obviously also a sign of a broken caching architecture. )r_hashedrs r>rrs  ( ..rKct|jdd|d|jz dz}|d}|j|dk(r||jz}|sy|dd||d<dj |S)z3 Cuts of the value of the leaf at position T)keependsNrrBrYr@)r r\rcolumnrw)leafpositionrrs r>cut_value_at_positionr"s}  T 23OHQK$))4Ka4O PE a[F yyHQK$++ b '6"E"I 775>rKcT|jdk(rCt|jdk(r*|jddk(rt|jdSy|jdk(r9|j}|ddk(ryt|dsyt d |dd DS|jd k(S) zP Checks if a path looks like `name` or `name.foo.bar` and not `name()`. r rrr0rBFrawaitc3@K|]}|jddk(yw)r.N)r5)rrrs r>rsz!expr_is_dotted..?s>A1::a=C'>sNr')r1lenr5expr_is_dottedall)r9r5s r>rr0s yyF t}}  "t}}Q'73'>!$--"23 3 yyK== A;' !hqk*>!">>> 99 rKcfd}|S)Nc~|jD])}|jd}|js)yy)z This is a heuristic. It will not hold ALL the times, but it will be correct pretty much for anyone that doesn't try to beat it. staticmethod/classmethod are builtins and unless overwritten, this will be correct. rBTF)get_decoratorsr5rq) function_noder, dotted_namedecorator_checkers r>rz&_function_is_x_method..wrapperDsF'557 I#,,Q/K !5!5!78 rK)rrs` r>_function_is_x_methodrCs  NrKc |dk(S)N staticmethodrms r>rSs 1;NrKc |dk(S)N classmethodrrs r>rrTs !}:LrKc@|dk(xs|dk(xs|jdS)Npropertycached_propertyz.setter)endswithrs r>rrVs,a:o  9rKr)HNFF)&ryr|astrinspectrweakrefr parso.pythonr parso.cacherparsor r7rRr6rGrJrWr^rer[rrrrrrget_cached_parent_scoperrrrrfunction_is_staticmethodfunction_is_classmethodfunction_is_propertyrrKr>rs %$B  "J !/   26AF1B !>R(@22BC5/ &  11NO/0LM,rK