
    Mhߍ                     .   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZ ddlmZ ddlmZmZ ddlmZ ddlmZm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddddddd d!d"d#d$d%d&d'Z4d( e45                                D             Z6d) Z7d* Z8d+ Z9 e'e
,          d-             Z:ej;        e7d.                         Z<d/ Z=d0 Z>e7dCd1            Z?ej;        dCd2            Z@d3 ZAed4             ZBd5 ZCd6 ZDd7 ZEd8 ZFd9 ZGd: ZHd; ZId< ZJ e3jK                    d=             ZL e'            d>             ZMd? ZN G d@ dAe          ZOdB ZPdS )Dz&
Functions inferring the syntax tree.
    N)tree)debug)parser_utils)ValueSet	NO_VALUESContextualizedNodeiterator_to_value_setiterate_values)LazyTreeValue)compiled)	recursion)analysis)imports)	arguments)
ClassValueFunctionValue)iterable)ListModificationDictModification)TreeInstance)	is_string
is_literal	is_numberget_names_of_nodeis_big_annoying_library)COMPARISON_OPERATORS)inference_state_method_cache)VersionInfo)
annotation)TreeNameDefinition)CompForContext	Decoratee)plugin_manager__add____sub____mul__
__matmul____truediv____floordiv____mod____pow__
__lshift__
__rshift____and____or____xor__)+-*@/z//%**z<<z>>&|^c                 0    i | ]\  }}|d |dd         z   S )__r   N ).0kvs      Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/inference/syntax_tree.py
<dictcomp>rD   2   s7     $ $ $AAuqu}$ $ $    c                       fd}|S )a{  
    This is for now the way how we limit type inference going wild. There are
    other ways to ensure recursion limits as well. This is mostly necessary
    because of instance (self) access that can be quite tricky to limit.

    I'm still not sure this is the way to go, but it looks okay for now and we
    can still go anther way in the future. Tests are there. ~ dave
    c                 F   | j         }| j        }	 |j        |xx         dz  cc<   d}| j         |                                 |j        u r|dz  }|j        |         |k    rt          j        d|           t          S n# t          $ r d|j        |<   Y nw xY w | g|R i |S )N   i,  d   z+In value %s there were too many inferences.)
	tree_nodeinference_stateinferred_element_countsparent_context	get_valuebuiltins_moduler   warningr   KeyError)contextargskwargsnrK   maximumfuncs         rC   wrapperz$_limit_value_infers.<locals>.wrapper@   s    !1	;3A666!;666G%-))++/NNN
 36q9GCCKQOOO   D  	; 	; 	;9:O3A666	;tG-d---f---s   A*A= =BBr?   )rW   rX   s   ` rC   _limit_value_infersrY   7   s#    . . . . .* NrE   c                    t          | t                    rt          | |          S |}|*|j        }|j        dv rnt          j        |          rd }n|*| j                            |          }||r|j        dk    r| j	        j
        r|j        d         }i g}|j        |j        k    r9t          |          }t          |          }d |D             t          fd|D                       r|D ]}| j	                            | |          }	t#          |	          dk    rt#          |          t#          |	          z  dk    rt%          j        d|           i g} nt)          |          }
g }|	D ]`}t)          |
          }t+          |          D ]:\  }}|                                ||<   t/          |g          ||         |j        <   ;||z  }a|D ]}|	||j        <   t#          |          dk    rOt2          }|D ]C}|                     ||          5  |t          | |          z  }d d d            n# 1 swxY w Y   D|S t7          | |          S |rt          | |          S t7          | |          S )N)if_stmtfor_stmtr[   rH   c                     g | ]	}|j         
S r?   value)r@   es     rC   
<listcomp>zinfer_node.<locals>.<listcomp>u   s     @ @ @Q @ @ @rE   c              3   *   K   | ]}|j         v V  d S Nr^   )r@   istr_element_namess     rC   	<genexpr>zinfer_node.<locals>.<genexpr>v   s+      BBA17//BBBBBBrE      z,Too many options for if branch inference %s.)
isinstancer!   _infer_nodeparenttyper   is_scopepredefined_namesgetrK   is_analysischildren	start_posend_posr   anyinferlenr   dbglist	enumeratecopyr   r_   r   predefine_names_infer_node_if_inferred)rR   elementr[   predefined_if_name_dictif_stmt_test
name_dictsif_nameselement_namesif_namedefinitionsoriginal_name_dicts
definitionnew_name_dictsrd   	name_dictresultre   s                   @rC   
infer_noder   X   s>   '>** -7G,,,G

.<222 )) 	G 
 &6::7CC &7&	))g.E.Q)'*T

 |333 )66H-g66M @ @- @ @ @BBBBBBBBB C' C CG")"9"?"?"Q"QK ;''!++z??S-=-==BB!I&TV]^^^ +-J!E.2:.>.>+%'
*5 9 9J-12E-F-FN09.0I0I Z Z94=NN4D4Dq 1CKZLCYCYq 1'- @ @&.8JJ9 *4 C CI7BIgm44Cz??QF' < <	,,Wi@@ < <k'7;;;F< < < < < < < < < < < < < < <M*7G<<<" 	=w000*7G<<<s   H<<I 	I 	c                     |}|5|j         }| j                            |          }|t          | |          S |5t	          | |          S )zA
    TODO This function is temporary: Merge with infer_node.
    )rj   rm   rn   ri   _infer_node_cached)rR   r|   rj   r}   s       rC   r{   r{      s]     F

")":">">v"F"F".w000	 

 gw///rE   )defaultc                 "    t          | |          S rc   )ri   )rR   r|   s     rC   r   r      s    w(((rE   c                    t          j        d||j        |            | j        }|j        }|dv rt          | |          S |dk    r#t          t          j        | |          g          S |dk    rt          | |          S |dv r|j
        d         }|j
        dd          }d}|j        d	k    r"|j        d
k    rd}|                    d          }|                     |          }t          |          D ]N\  }}	|	dk    r2|                     ||dz                      }
t          | ||	|
          } nt!          | ||	          }O|r&|                                                                S |S |dv r$t          t'          j        || |          g          S |dv rD|                     |j
        d                   }|j
        d d         D ]}t+          ||          }|S |dk    rA|                     |j
        d                   |                     |j
        d                   z  S |dk    r]|j        dk    r/|j        }t/          dt1          |j                  d|d          t          t3          j        |d          g          S |dk    rGt          | |j
        d                   }|j
        dd d         D ]}|                    ||           }|S |dk    r |                     |j
        d                   S |dk    r2t9          j        | |j
        d                                                   S |dk    rt?          |j
                  r||j
        d         j        dk    rf|j
        d         j
        d         }|                     |                              d                                           }|                                S tB          S |dk    r |                     |j
        d                   S tE          | |          S ) Nzinfer_node %s@%s in %s)namenumberstringatomstringskeywordfstringlambdef	expr_stmt)power	atom_exprr   rH   Fr   awaitTr8   )testlist_star_exprtestlist)not_testfactortestoperatorz...zunhandled operator z in  Ellipsisdotted_namer>   )name_context
eval_input	annassign
yield_expr	yield_arg__iter__namedexpr_test)#r   rv   rq   rK   rk   
infer_atomr   r   from_contextinfer_expr_stmtrp   r_   popr   rx   _infer_comparisoninfer_trailerpy__await__py__stop_iteration_returnsr   SequenceLiteralValueinfer_factorrj   AssertionErrorreprr   builtin_from_namepy__getattribute__r   infer_annotationexecute_annotationru   execute_with_valuesr   infer_or_test)rR   r|   rK   typfirst_childrp   	had_await	value_setrd   trailerrightr   origin	next_name
generatorss                  rC   ri   ri      s[    
I&1BGLLL-O
,C
SSS'7+++				3GWEEFGGG			w000	&	&	&&q)#ABB'	y(([->'-I-II",,q//K&&{33	%h// 
	C 
	CLQ$**8AE?;;-	 	 %gy'BBII 	H((**EEGGG	3	3	36QXYYZ[[[	&	&	&&&w'7';<<	("- 	: 	:H$Y99II	""7#3A#677$$W%5b%9::; 	<	
		=E!!^F .4CVCVCVCVX^X^X^!_```3OZPPQRRR			w(8(;<<	 )!$Q$/ 	V 	VI!44YW4UUII			!!'"21"5666			*7G4DQ4GHH!!	"			w   	;W%5a%8%=%L%L&q)215G ++G44##J//0C0C0E0E 88::: 	 	 	 !!'"21"5666Wg...rE   c                    |j         d d         \  }}|dk    rd }|dk    r=|j         \  }}}|                    t          | |          t          | |                    S t	          j        d||           |dk    r|                    | |          S |dk    sJ d|z              t          j        | j	        | ||          }|
                    |          S )	Nr>   )[zinfer_trailer: %s in %s.)r   name_or_str(ztrailer_op is actually %s)rp   get_item_infer_subscript_listr   r   rv   r   r   TreeArgumentsrK   execute)rR   atom_valuesr   
trailer_opnode_rS   s          rC   r   r     s   '+Js{{S%.
D!##!'400w00
 
 	

 		+WkBBB11$  2   
 $$$&AJ&N$$$*7+BGTSZ[[D&&t,,,rE   c                    | j         }j        dk    rt          j        ddd          p}|j        dk    r0t	          fd|                                D                       s}n|j        dk    r}|j        }t                    rd}|                     |          S j        dk    rPj	        d	v r(t          t          j        |j	                  g          S j	        d
k    rt          S J dz              t          t          j                  rB|j                            j	                  }t          t          j        ||          g          S j        dk    rQt'          | j        d                   }j        dd         D ]$}t'          | |          }t+          | |d|          }%|S j        dk    rt          j        |          S j        }|d         dk    r]t/          |          dk    sJ|d         j        dk    rt/          |d         j                  dk    s|                     |d                   S 	 |d         j        d         }	|	dk    r%	 |d         j        d         }	n# t2          $ r Y nw xY w|	j        dv r$t          t5          j        ||           g          S n# t2          t8          f$ r Y nw xY w|d         }
	 |
j        }n# t8          $ r g }Y nw xY w|d         dk    r%|
dk    sd|v sd|v rt5          j        ||           }nt5          j        ||           }t          |g          S )z
    Basically to process ``atom`` nodes. The parser sometimes doesn't
    generate the node (because it has just one child). In that case an atom
    might be a name or a literal as well.
    r   r   r   r[   c              3   V   K   | ]#}|j         j         cxk    o
|j        k     nc V  $d S rc   )rq   rr   )r@   rU   r   s     rC   rf   zinfer_atom.<locals>.<genexpr>%  sE      ``Qq{dn@@@@qy@@@@``````rE   Npositionr   )FalseTrueNoneyieldFzCannot infer the keyword %sr   r   rH   r2   r   r   r>   testlist_comp:   )comp_forsync_comp_for{}r8   )rK   rk   r   search_ancestorrs   get_test_nodesrq   _is_annotation_namer   r_   r   r   r   r   rh   Literalcompiled_subprocesssafe_literal_evalcreate_simple_objectr   rp   r   get_string_value_setru   r   
IndexErrorr   comprehension_from_atomAttributeErrorDictLiteralValuer   )rR   r   statestmtr   r   r   r   cr   
array_nodearray_node_c	new_values    `           rC   r   r     s    #EyF#D+y)LLTPT9	!!````$J]J]J_J_````` Y)##D>t$$ 	 H))$)BBB	i		:222X7tzJJKLLLZ7"" :3d::::	D$,	'	' 0%*<<TZHH6ufEEFGGG	i		wa(899	mABB' 	J 	JFw//E)'9c5IIII	i		,U333MQ43;;s1vv{{1o55 1//!33%%ad+++	t}Q'H 3 t}Q/HH!   D } ===!A7D" " !    > N+ 	 	 	D	  qT
	%.LL 	 	 	LLL	Q43;;J#--1D1D#|33 1%$GGII 5eWdKKI$$$s6   J3 !I5 5
JJ3KKK K*)K*c                    t          j        | j        |          5 }|rE|&t          j        | ||          }|r|cd d d            S t          | ||          cd d d            S 	 d d d            n# 1 swxY w Y   t          S rc   )r   execution_allowedrK   r   "find_type_from_comment_hint_assign_infer_expr_stmtr   )rR   r   	seek_nameallowedpep0484_valuess        rC   r   r   o  s	   		$W%<d	C	C >w 	>$A'4QZ[[ ! *)> > > > > > > > $GT9==> > > > > > > >	>> > > > > > > > > > > > > > > s   A0A00A47A4c                     d }t          j        d||           |                                }                     |          |r t	           |          }t          |          t          |                                d          } ||          \  }|dvo
|j        dk    }|s|r|	                    d          d         j
        }	                     |	|j        	          }
|r$ fd
t          fd|
D                       nMt          j        |          }|j
        dd         |_
        t          j        |d          }||j        dk    rrt#          j        |          r|                                }t)           |          }t+          |                                                    |                    }|D ]}}|j        d         j
        |                                i}                     ||          5                       |          }t5           |
||          }
ddd           n# 1 swxY w Y   ~|
nt5           |
|          t          j        d           S )aD  
    The starting point of the completion. A statement always owns a call
    list, which are the calls, that a statement does. In case multiple
    names are defined in the statement, `seek_name` returns the result for
    this name.

    expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
                     ('=' (yield_expr|testlist_star_expr))*)
    annassign: ':' test ['=' test]
    augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
                '<<=' | '>>=' | '**=' | '//=')

    :param stmt: A `tree.ExprStmt`.
    c                     | j         d         }|j        dvrdS |j         d         }|j        dk    st          |j                   dk    rdS |j         d         }|j         d         dk    |j         d         fS )	Nr   )r   r   )FNr   r>   r   r   rH   )rp   rk   ru   )r   r   r   r   s       rC   check_setitemz'_infer_expr_stmt.<locals>.check_setitem  s    M!$	>!777;!!$9#i&8"9"9Q">">;$R("c)7+;A+>>>rE   zinfer_expr_stmt %s (%s)N)=Nr   T)include_setitemr   r   c                     t                    }| j        dk    rt          | |          S | j        dk    rt          | |          S | S )Ndictrw   )ContextualizedSubscriptListNode
array_typer   r   )rB   r   rR   subscriptlistr   s     rC   to_modz _infer_expr_stmt.<locals>.to_mod  sU    3G]KK<6))+Ay!<<<\V+++Ay!<<<rE   c              3   .   K   | ]} |          V  d S rc   r?   )r@   rB   r  s     rC   rf   z#_infer_expr_stmt.<locals>.<genexpr>  s+       @ @q @ @ @ @ @ @rE   r   r\   rH   zinfer_expr_stmt result %s)r   rv   get_rhsr   r    check_tuple_assignmentsnextyield_operatorsrk   get_defined_namesr_   r   rq   r   ry   r   r   r   for_stmt_defines_one_nameget_testlistr   rw   rt   iteraterp   rz   r   )rR   r   r   r   rhsrU   first_operator
is_setitemis_annassignr   left_valuesr   r\   r   cnordered
lazy_valuedcttr  r  r   s   `                  @@@rC   r   r   }  s    ? ? ? 
I'y999
,,..C""3''I :w	22+Ay99	$..00$77N -d 3 3J!4Z9LPZ9ZL #Yz #Y%%d%;;A>D000OO 	Y       ! @ @ @ @K @ @ @@@IIy00H%^CRC0HN+D*==H#(C(C	(C$>xHH )D
  ,,..'66rxxzz11"5566") [ [J#,Q/5z7G7G7I7IJC 003?? [ [#..s33&7hXY&Z&Z[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ (		-g{HiXX		I)9555s   (H<<I 	I 	c           	      2   t          |j                  }|                     t          |                    }|D ]}t          |          }|j        dk    r$d                    d |j        D                       }|dv r_t          d |D                       }|dhk    r|dk    r|                     |          }|dhk    r|dk    r|                     |          }t          | |||                     |                    }t          j	        d	|           |S )
Ncomp_opr   c              3   $   K   | ]}|j         V  d S rc   r^   )r@   r   s     rC   rf   z infer_or_test.<locals>.<genexpr>  s$      CCACCCCCCrE   )andorc              3   >   K   | ]}|                                 V  d S rc   )
py__bool__)r@   lefts     rC   rf   z infer_or_test.<locals>.<genexpr>  s,      AA4T__..AAAAAArE   Tr  Fzinfer_or_test types %s)
iterrp   r   r  rk   joinsetr   r   rv   )rR   or_testiteratortypesr   r   
left_boolss          rC   r   r     s<   G$%%HtH~~..E A AX=I%%xxCC1BCCCCCH }$$AA5AAAAAJdV##u$$#..u55Ew&&u$$#..u55E &guh&-&8&8&?&?A AEE	I&...LrE   c              #     K   | D ]}|dk    r&t          |          r|                                V  .|dk    r|                                }|St          |j        j                            d                                                                                    V  t          j
        |j        |           V  |V  dS )z6
    Calculates `+`, `-`, `~` and `not` prefixes.
    r3   notNbool)r   negater!  rw   rK   rO   r   r   r   r   r   )r   r   r_   bs       rC   r   r     s      
   s?? %llnn$$$  ""Ay50@SSTZ[[..002 225#%%8 8 8 8 3E4Iq5QQQQQQKKKK rE   c                     t           }|D ][}t          |          r7t          j        | |j        j                  }||                                z  }H|t          |g          z  }\|S rc   )r   r   r   r   r   string_namer   r   )rK   r   
new_resultr   clss        rC   _literals_to_typesr3    sq     J * *c?? 	* ,_ch>RSSC#11333JJ(C5//)JJrE   c                       j         t          t                    r}nt          j                  }|rs#|pt          pt          z  }t          |          S |dk    rBt          d t          j        |          D                       rt          j
        |f          S t          |          t                    z  dk    rt          |z            S t          j
         fd|D                       S )Nr:   c              3   f   K   | ],}|                                 p|                                V  -d S rc   )is_classis_compiled)r@   r_   s     rC   rf   z$_infer_comparison.<locals>.<genexpr>  sQ       % % 	/E--//% % % % % %rE      c           	   3   H   K   | ]}D ]}t          ||          V  d S rc   )_infer_comparison_part)r@   r"  r   rR   r   right_valuesr   s      rC   rf   z$_infer_comparison.<locals>.<genexpr>  s^       & &)& &  'ugtXuMM& & & & & & &rE   )rK   rh   strr_   r   r3  all	itertoolschainr   	from_setsru   )rR   r  r   r;  operator_strr   r   s   ` ``  @rC   r   r     sD   #E(C   +8>** l *|/HyI!%000			 % %_[,??% % % " "	
 !;"=>>>
 {c,///!33%e[<-GHHH% & & & & & & &'& & &   rE   c                 b   t          j        | ddd          }|dS |j        dv r)|j        }||j        | j        cxk    o
|j        k     nc S na|j        dk    rV|j        }t          |          dk    r<|d         j        dk    r+|d         j        | j        cxk    o|d         j        k     nc S dS )Nparamfuncdefr   F)rC  rD  rH   r   )r   r   rk   r   rq   rr   rp   ru   )r   ancestorannr   s       rC   r   r   %  s    #D'9kJJHu},,,!?=DN@@@@S[@@@@@ 	+	%	%q66A::!A$){22Q4>T^BBBBadlBBBBB5rE   c                     | j         dk    S )Nrw   r  r^   s    rC   _is_listrI  5  s    v%%rE   c                     | j         dk    S )NtuplerH  r^   s    rC   	_is_tuplerL  9  s    w&&rE   c                 F    t          j        | t          |                    S rc   )r   r   r<  )rK   bool_s     rC   _bool_to_valuerO  =  s    %os5zzBBBrE   c                 >   t          | t          j                  sd S g }|                                 D ]i}t          |t                    s d S |j        }|j        dk    r d S 	 |                    t          |j	                             X# t          $ r Y  d S w xY w|S )Nr   )rh   r   r   
py__iter__r   datark   appendintr_   
ValueError)r_   numbersr  r   s       rC   _get_tuple_intsrW  A  s    eX:;; tG&&(( 	 	
*m44 	449  44	NN3tz??++++ 	 	 	444	Ns   #'B
BBc                 2   t          |          }t          |          }t          |t                    r|}nt          |j                  }|dk    rtt          |t          j                  st          |          rt          |g          S t          |t          j                  st          |          rt          |g          S nA|dk    r|r|st          |          r%t          |          r|                    ||          S t          |          rt          |          st          |          r4t          |          r%t          t	          j        | ||f          g          S n|dk    r|r|r|                    ||          S n~|dk    rt          |g          S |t          v r.|                                r/|                                r|                    ||          }|r|S n|dv r?t          |         }	 |	||          }
|dv |
k    rt          t          | |
          g          S t          |t                    rft!          |          }|Ut#          j        j        |         | j        j        t+          |                    }t          t          | |          g          S t          t          | d          t          | d          g          S |d	v r,| j                            d
                                          S d }|dv r:||k    r4 ||          s) ||          sd}t3          j        |d||||fz             |                                s|                                rt8          S t:          |         }|                    |          }|r|                    |          }|r|S |s;t>          |         }|                    |          }|                    |          }|r|S t          ||g          }tA          j!        d||           |S )Nr4   r2   r3   r7   )isz!===zis not)rY  rZ  TF)inznot inr,  c                 H    t          | t                    o| j        j        dv S )z4Checks if a Jedi object is either a float or an int.)rT  float)rh   r   r   r0  )objs    rC   checkz%_infer_comparison_part.<locals>.check  s'    #|,, 5H $44	5rE   )r2   r3   z7TypeError: unsupported operand type(s) for +: %s and %sztype-error-operationz Used operator %s resulting in %s)"r   rh   r<  r_   r   Sequencer   r   execute_operationrI  rL  MergedArrayr   r7  rO  r   rW  r   accessenvironmentversion_inforK  rO   r   r   r   addr6  r   operator_to_magic_methodr    reverse_operator_to_magic_methodr   rv   )rK   rR   r"  r   r   l_is_numr_is_numstr_operatorr   	operationrN  re  bool_resultr_  messagemethod_namemagic_methodsreverse_method_names                     rC   r:  r:  R  s   HH(C   +8>**sdH-.. 	%)D// 	%TF###x011 	%Yu5E5E 	%UG$$$	%			 	T 	TIdOO 	T	%8H8H 	T))%>>>d^^ 	T 	T9T?? 	TyQVGWGW 	TX1/D%=QQRSSS			 	? 	?))%>>>			 	-	-	- 	T%"3"3"5"5 	T++E<@@F  ;;;0>	!	$.. !L0U::#^OU%K%K$LMMM$,, T.u55+"*/"Fx"P'3@l++# #K $^O[%Q%Q$RSSS?D11?E22
   	 
)	)	).AA&II\\^^^5 5 5 z!!h(&:&:U4[[ ';$)E%LL ';KW4he},	. 	. 	. }} %..** *<8K++K88M 22599 	M >|L001DEE22488 	MtUm$$F	I0(FCCCMrE   c                 $	   t           }|                                j        }||                                                    |j        g           }d}|D ]}|j        }|j        dk    r|j        d         j        dk    rt          j
        |          |j        k    }	|j        d         }
|	rd}|
j        d         j        dk    r)|
j        d         j        |j        k    r|j        r|j        }|t          j        ||j        d         j        d                                                   z  }|r|S g }|                    dd          }||j        }|j        dk    r|                    |          }|                                rt           S t%          |                                          }|                    |j                  }t)          j        d	 |D                       S |j        d
vr%|                    |          }t-          ||          S |j        }|dk    rt          j        |||          }|r|S |dk    rt          j        |||          }|r|S |dv r	 |j        |         |j                 }n# t4          $ rq t7          ||j        d                   }t9          |                                ||j        j        dk              }t=          ||          }t?          ||          }Y nw xY w|dk    rtA          |||          }n~|dk    r|!                    |"                    |                    }|j        j        dk    rO|#                    d          }|$                                }|%                                &                                S |#                    d          }|$                                S |d
v rtO          j(        ||          }n|dv rtS          ||          }n|dk    rN|!                    |*                                *                                          }|$                                }nE|dk    rt           }n7|dk    rt           }n)|dk    rtC          ||          }ntW          d|z            |S )NFr   rH   r   Tr   )import_name_alwaysr  global_stmtc              3   >   K   | ]}|                                 V  d S rc   )rt   )r@   r   s     rC   rf   z&tree_name_to_values.<locals>.<genexpr>  s*      %E%Etdjjll%E%E%E%E%E%ErE   )import_fromimport_namer\   	with_stmt)r\   r   r   r   
async_stmt)contextualized_nodeis_async
__aenter__	__enter__)rD  classdeftry_stmtrC  del_stmtr   zShould not happen. type: %s),r   get_root_contextrJ   get_used_namesrn   r_   rj   rk   rp   r   get_parent_scoperM   r   r   r   get_definitioncreate_context	is_moduler  get_filtersr   r@  r   find_type_from_comment_hint_for find_type_from_comment_hint_withrm   rQ   r   r
   rt   r    r
  r   r   get_test_node_from_namer   r   r   r   r   infer_import_apply_decoratorsget_previous_siblingrU  )rK   rR   	tree_namer   module_nodenamesfound_annotationr   r   correct_scope
ann_assignr(  r   r   filterr   r  	for_typesrU   value_managersenter_methodscoro
exceptionss                          rC   tree_name_to_valuesr    s   I**,,6K**,,00"EE  	+ 	+DI~,,1CA1F1K{1Z1Z , =d C CwGX X&/2
  
+'+$#,Q/4>>'039Y_LL#2 M #*"8!<!3A!6!?!B" "((**+I  	E##tT#RRD|9%%&&y11A{{}} ! !  !--//**FJJy//E%%E%Eu%E%E%EEEEY<<<&&y11Aa+++
)C
j:7D)TT 	L
k;GT9UU 	L
777
	:,T29?CEE 	: 	: 	:#GT]1-=>>B&

$&)\9  I
 #7I66A+Ay99EEE	: 
		y99			 ++D,H,H,S,STT;|++ +==lKKM 4466D##%%@@BBB&99+FF00222	.	.	.$Wi88	'	'	'!'400	
		 ''	(F(F(H(H(](](_(_``
..00		
			 	 	 7D))6<===Ls   !I; ;A7K65K6c                   	 |j         dk    rt          | j        | |          	nt          j        | |          	t          	g          x}}t          |           r|S t          |                                          D ]i}t          j
        d||d           t          j                    5  |                     |j        d                   }|j        dd         }|r-t          j        d	|          }||_        t#          | ||          }t%          |          sB|                    d
          }|dk    rt          j        d||           |cddd           c S |                    t-          j        |g                    }t%          |          s%t          j        d|           |cddd           c S 	 ddd           n# 1 swxY w Y   t          j
        d|d           k||k    rt          	fd|D                       S |S )z
    Returns the function, that should to be executed in the end.
    This is also the places where the decorators are processed.
    r~  )rM   rJ   zdecorator: %s %sMAGENTA)colorrH   r>   r   r   F)include_prefixz	@runtime
zdecorator not found: %s on %sNz)not possible to resolve wrappers found %szdecorator end %sc                 0    g | ]}t          |          S r?   r"   )r@   r   decoratee_values     rC   ra   z%_apply_decorators.<locals>.<listcomp>G  s#    GGG11o66GGGrE   )rk   r   rK   r   r   r   r   reversedget_decoratorsr   rv   increase_indent_cmr   rp   r   
PythonNoderj   r   ru   get_coderP   r   r   ValuesArguments)
rR   r   initialvaluesdec
dec_valuestrailer_nodesr   coder  s
            @rC   r  r    s    yJ$#"
 
 
 (4WdCC 1222Gfw'' ++--.. ? ?	$c6CCCC%'' 	 	 ++CLO<<JL2.M I/)]CC!$*7JHH
z?? ||5|99 <''M"A3MMM!	 	 	 	 	 	 	 	 	 	$  ''	(A6((K(KLLFv;; I4PPP+	 	 	 	 	 	 	 	 	 	&'	 	 	 	 	 	 	 	 	 	 	 	 	 	 	. 		$fI>>>>>GGGGGGGHHHMs   ,B!GAGG		G		c                 z   d}|                                  D ]\  }}t          | j        |          }|                    |          }t	          |t
                    r	t          c S d}||k    r:	 t          |          }||j        z  }n# t          $ r t          cY c S w xY w||k    :|
                                }|S )z(
    Checks if tuples are assigned.
    Nr   )assignment_indexesr   rM   r  rh   slicer   r  maxStopIterationrt   )r   r   r  indexr   r  iteratedrd   s           rC   r
  r
  K  s     J..00 ' 't 3T::$$R((eU## 	5jj	$!(^^
 Z^# ! ! ! !
 !     ! 5jj $$&&		s   -BBBc                       e Zd Zd ZdS )r  c                 6    t          | j        | j                  S rc   )r   rR   r   )selfs    rC   rt   z%ContextualizedSubscriptListNode.inferg  s    $T\49===rE   N)__name__
__module____qualname__rt   r?   rE   rC   r  r  f  s#        > > > > >rE   r  c                    |dk    r%t          t          j        | ddd          g          S |j        dk    r|j        d         dk    sg }|j        D ]y}|dk    r|s|                    d            |j        dk    r9t          |j                  dk    r |                    |j        d                    d|                    |           z|dgd	t          |          z
  z  z  }t          t          j        | g|R  g          S |j        d
k    r)t          t          j        | j        | |          g          S | 	                    |          S )z,
    Handles slices in subscript nodes.
    r   N	subscriptr   r   sliceopr>   rH   r   r  )
r   r   Slicerk   rp   rS  ru   r   rK   r   )rR   r  r   els       rC   r   r   k  s^    ||tTBBCDDD	{	"	"5>!+<+C+C . 	" 	"BSyy (MM$'''I%%r{##q((MM"+a.111b!!!!4&AFO,,9&999:;;;		&	&6w7NPWY^__`aaa e$$$rE   rc   )Q__doc__ry   r>  parso.pythonr   jedir   r   jedi.inference.base_valuer   r   r   r	   r
   jedi.inference.lazy_valuer   jedi.inferencer   r   r   r   r   jedi.inference.valuer   r   r   #jedi.inference.value.dynamic_arraysr   r   r   jedi.inference.helpersr   r   r   r   r   jedi.inference.compiled.accessr   jedi.inference.cacher   !jedi.inference.gradual.stub_valuer   jedi.inference.gradualr   jedi.inference.namesr    jedi.inference.contextr!   jedi.inference.value.decoratorr#   jedi.pluginsr$   rg  itemsrh  rY   r   r{   r   increase_indentri   r   r   r   r   r   r   r3  r   r   rI  rL  rO  rW  r:  decorater  r  r
  r  r   r?   rE   rC   <module>r     s                          * * * * * * * * * * * * * * 3 3 3 3 3 3 # # # # # # $ $ $ $ $ $ # # # # # # " " " " " " $ $ $ $ $ $ : : : : : : : : ) ) ) ) ) ) R R R R R R R R - - - - - -/ / / / / / / / / / / / / / ? ? ? ? ? ? = = = = = = 9 9 9 9 9 9 - - - - - - 3 3 3 3 3 3 1 1 1 1 1 1 4 4 4 4 4 4 ' ' ' ' ' ' 
				
	


			   $ $!9!?!?!A!A$ $ $  
  BE= E= E=P
0 
0 
0 i000) ) 10) K/ K/  K/\- - -0R% R% R%j 
 
 
 
 J J J JZ  2   &    <   & & &' ' 'C C C  "Z Z Zz d d dR . .  .b  6> > > > >&8 > > >
% % % % %rE   