
    -h*                     *   S SK r S SKrS SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  1 SkrS	rSS
 jrS rS rS rS rS rS r  S S jrS rS rS rS rSS jr\" \5      rS rS rS r S r!S r"\"" S 5      r#\"" S 5      r$\"" S 5      r%g)!    N)literal_eval)cleandocWeakKeyDictionary)tree)parser_cache)split_lines>   atomexprtermtestpowerfactorfuncdefor_testand_exprand_testclassdefnot_testxor_expr	atom_expr
arith_expr
comparison
shift_exprimport_fromimport_name)	tryexceptfinallyelseifelifwithforwhilec                 n   / nU R                   nUS:X  aH  U R                  5       nUSL a1  U R                  R                   S:w  a  US:w  a  UR                  U 5        U$ US:X  a3  UR                  U 5        U R                   H  nU[        USS9-  nM     U$ US:X  a8  U R                  S	   S
:X  a#  U R                  S   n U S:w  a  U[        U 5      -  nU$  U R                  nU R                   [        ;   a  U(       d  UR                  U 5        U H  nU[        XQ5      -  nM     U$ ! [         a     U$ f = f)z
For static analysis.
nameFparam=	expr_stmtT)
last_added	decorator)()typeget_next_leafparentappendchildrenget_executable_nodes_EXECUTE_NODESAttributeError)noder+   resulttyp	next_leafchildr5   s          dC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\jedi/parser_utils.pyr6   r6      sH    F
))C
f}&&(	4;;#3#3w#>9PSCSMM$2 M1 
	 	d]]E*5TBBF #( M% 
	==#==$Ds{.t44 M		B}}H yyN*:d#!.uAA " M  	 M	s   D& &
D43D4c              #      #    U v   U R                   S   n UR                  S:X  a  UR                   S   v   O&UR                  S:X  a  Uv   OUR                  S:X  d  g UR                   S   nMY  7f)Ncomp_for   sync_comp_forcomp_ifr5   r1   )rA   lasts     r>   get_sync_comp_forsrG   :   sk     
NR D
99
"--""YY/)Ji'}}R  s   A.A0c                 :    U R                   S   R                  S:H  $ )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
rB   r'   rE   )for_stmts    r>   for_stmt_defines_one_namerJ   G   s      Q$$..    c                    UR                   nU R                   Us=:  a  U R                  ::  d  O  [        S5      eS n[        U R                  5       H6  u  pEX%R                   :  a  Us  $ UR                  5       nU[        ;   d  M4  UnM8     g )Nz!The node is not part of the flow.)	start_posend_pos
ValueError	enumerater5   get_first_leaf_FLOW_KEYWORDS)	flow_noder9   rM   keywordir=   
first_leafs          r>   get_flow_branch_keywordrW   Q   s{    I)@y/@/@@<==Gi001&N))+
' G 2 rK   c                 f    U R                  5       nUb  [        [        UR                  5      5      $ g)z2Returns a cleaned version of the docstring token.  )get_doc_noder   safe_literal_evalvalue)
scope_noder9   s     r>   clean_scope_docstringr^   `   s0    ""$D
 )$**566rK   c                     U R                   S:X  al  U R                  n U R                  5       nUbM  UR                   S:X  a=  UR                  S   nUR                   S:X  a  [	        [        UR                  5      5      $ g)Nr*   simple_stmtr   stringrY   )r1   r3   get_next_siblingr5   r   r[   r\   )	tree_nodemaybe_strings     r>   find_statement_documentationre   l   ss    ~~$$$	 113#  M1+44Q7$$0#$5l6H6H$IJJrK   c                 ^    U S S R                  5       nUS   S:X  d  US;   a  g[        U 5      $ )N   r   f)frrfrY   )lowerr   )r\   	first_twos     r>   r[   r[   x   s7    bq	!I|si<7 rK   c                    Uc)  U R                   S:X  a  SnOU R                  R                  nU R                  5       nU(       a  USS nSSR	                  S U 5       5      R                  5       -   S-   n[        R                  " S	S
U5      nU R                  (       a%  U(       d  SU R                  R                  5       -   nOSnX&-   U-   nSR	                  [        R                  " X5      5      $ )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
Nlambdefz<lambda>rB   r0   rY   c              3   @   #    U  H  oR                  5       v   M     g 7fN)get_code).0r(   s     r>   	<genexpr> get_signature.<locals>.<genexpr>   s     ;F5nn&&Fs   r.   z\s+ z ->
)r1   r'   r\   
get_paramsjoinstripresub
annotationrq   textwrapwrap)	r   widthcall_stringomit_first_paramomit_return_annotationparamsprtypecodes	            r>   get_signaturer      s     <<9$$K!,,,,K!Fbgg;F;;AACCcIA
vsAA"8**3355?U"D99X]]4/00rK   c                      U R                   nU H  n[        X15        M     g! [         a    U =R                  U-  sl         gf = f)z
Move the `Node` start_pos.
N)r5   mover8   line)r9   line_offsetr5   cs       r>   r   r      sC    !== A    !		[ 	!s   # AAc                     U R                   S:X  a(  U R                  S   R                  5       R                  nOU R                   S:X  a(  U R                  S   R                  5       R                  nOoU R                   S:X  a6  U R                  S   R                  5       R	                  5       R                  nO)U R                  5       R	                  5       R                  n SU;  a  gXR                  S5      S nS	U;   a  USUR                  S	5       nS
U;   a  USUR                  S
5       nU$ ! [         a     g[         a     gf = f)z`
returns (as string) any comment that appears on the same line,
after the node, including the #
rI      	with_stmt   r      N#rv   )	r1   r5   rQ   prefixr2   get_last_leafr8   rO   index)r9   
whitespacecomments      r>   get_following_comment_same_liner      s+   
99
"q)88:AAJYY+%q)88:AAJYY)#q)88:HHJQQJ++-;;=DDJ *))#./0Gw.7==./w.7==./N    s)   7D1 7D1 2AD1 8(D1 1
E	=	E	E	c                 h    U R                   nUS:X  a  U R                  S   R                   S:g  $ US;   $ )NrA   rB   rC   )
file_inputr   r   rn   rC   )r1   r5   )r9   ts     r>   is_scoper      s8    		AJ}}Q$$77QQQrK   c                 0   ^ ^ [        5       mSUU 4S jjnU$ )Nc                    > U c  T" X5      $  TU    n X1   $ ! [          a
    0 =nTU '    Nf = f! [          a    T" X5      =oCU'   Us $ f = frp   )KeyError)parso_cache_noder9   include_flows
for_moduler:   cachefuncs        r>   wrapper(_get_parent_scope_cache.<locals>.wrapper   sz    #,,	6/0J	##	  	6355J/0	6
  	(,T(AAF%M	s    / ,,A
	A
Fr   )r   r   r   s   ` @r>   _get_parent_scope_cacher      s    E  NrK   c                   ^  T R                   nUc  g [        U5      (       a  UR                  S;   a  UR                  R	                  S5      nUR                  U   R
                  T R
                  :  a  T R                   R                  S:X  a  T R                   R                  T :X  a   U$ T R                   R                  S:X  a   T R                   R                  S   T :X  a   U$ UR                   nM  U$ U(       aY  [        U[        R                  5      (       a:  UR                  S:X  a(  [        U 4S jUR                  5        5       5      (       d  U$ UR                   nGMR  )	z
Returns the underlying scope.
N)r   r   rn   :r(   tfpdefr   if_stmtc              3      >#    U  H8  nUR                   TR                   s=:*  =(       a    UR                  :  Os  v   M:     g 7frp   )rM   rN   )rr   nr9   s     r>   rs   #get_parent_scope.<locals>.<genexpr>  s4      =%; KK4>>EEAIIEE%;s   A A)r3   r   r1   r5   r   rM   r'   
isinstancer   Flowanyget_test_nodes)r9   r   scoper   s   `   r>   get_parent_scoper      s*    KKE}
E??zz??,,S1>>%(22dnnD{{''72t{{7G7G47O L ))X5$++:N:Nq:QUY:Y L !& Lz%;; JJ)+ =%*%9%9%;= = =+ rK   c                 ,    [        X5      R                  $ )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_nodelinesgrammarpaths     r>   get_cached_code_linesr     s    
  .444rK   c                 .    [         U R                     U   $ )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   _hashedr   s     r>   r   r     s     (..rK   c                     [        U R                  SS9SUS   U R                  -
  S-    nUS   nU R                  US   :X  a  X0R                  -  nU(       d  gUS   SU US'   SR	                  U5      $ )z+
Cuts of the value of the leaf at position
T)keependsNr   rB   rY   r@   )r	   r\   r   columnrx   )leafpositionr   r   s       r>   cut_value_at_positionr   "  s{     

T23OHQK$))4Ka4OPEa[FyyHQK++b	'6"E"I775>rK   c                 h   U R                   S:X  aE  [        U R                  5      S:X  a+  U R                  S   S:X  a  [        U R                  S   5      $ gU R                   S:X  a?  U R                  nUS   S:X  a  g[        US   5      (       d  g[	        S	 USS
  5       5      $ U R                   S:H  $ )zH
Checks if a path looks like `name` or `name.foo.bar` and not `name()`.
r
   r   r   r0   rB   Fr   awaitc              3   D   #    U  H  oR                   S    S:H  v   M     g7f)r   .N)r5   )rr   r   s     r>   rs   !expr_is_dotted.<locals>.<genexpr>?  s     >A::a=C's    Nr'   )r1   lenr5   expr_is_dottedall)r9   r5   s     r>   r   r   0  s     yyFt}}"t}}Q'73'>!$--"233yyK==A;'!hqk**>!">>>99rK   c                    ^  U 4S jnU$ )Nc                    > U R                  5        H/  nUR                  S   nT" UR                  5       5      (       d  M/    g   g)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.
rB   TF)get_decoratorsr5   rq   )function_noder,   dotted_namedecorator_checkers      r>   r   &_function_is_x_method.<locals>.wrapperD  sD     '557I#,,Q/K !5!5!788 8 rK    )r   r   s   ` r>   _function_is_x_methodr   C  s     NrK   c                     U S:H  $ )Nstaticmethodr   ms    r>   <lambda>r   S  s	    1;NrK   c                     U S:H  $ )Nclassmethodr   r   s    r>   r   r   T  s	    !}:LrK   c                 T    U S:H  =(       d    U S:H  =(       d    U R                  S5      $ )Npropertycached_propertyz.setter)endswithr   s    r>   r   r   V  s,    a:o 	

9rK   r   )H   NFF)&rz   r}   astr   inspectr   weakrefr   parso.pythonr   parso.cacher   parsor	   r7   rR   r6   rG   rJ   rW   r^   re   r[   r   r   r   r   r   r   get_cached_parent_scoper   r   r   r   r   function_is_staticmethodfunction_is_classmethodfunction_is_propertyr   rK   r>   <module>r      s    	    %  $ B

"J
!/		 26AF1B
!>R(@ 22BC 5/&  11NO /0LM , rK   