TL idZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZd Zd Zd Zd Zd ZdZy)a Searching for names with given scope and name. This is very central in Jedi and Python. The name resolution is quite complicated with descripter, ``__getattribute__``, ``__getattr__``, ``global``, etc. If you want to understand name resolution, please read the first few chapters in http://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/. Flow checks +++++++++++ Flow checks are not really mature. There's only a check for ``isinstance``. It would check whether a flow has the form of ``if isinstance(a, type_or_tuple)``. Unfortunately every other thing is being ignored (e.g. a == '' would be easy to check for -> a is a string). There's big potential in these checks. )search_ancestor)Name)settings) TreeArguments)iterable) NO_VALUES)is_scopect|tr |jn|}g}|D]}|j|}|snt t |S)zh Searches names that are defined in a scope (the different ``filters``), until a name fits. ) isinstancervaluegetlist_remove_del_stmt)filters name_or_str string_namenamesfilters [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/finder.py filter_namersU (2+t'D+##+K E ;'    ' ((c#K|D]>}|j,|jj}||jdk(r;|@yw)Ndel_stmt) tree_nameget_definitiontype)rname definitions rrr+sJ >> %668J%*//Z*G sAActjsyd}t|r|j} |j |j }t|Dcgc]4}|j|jcxkr|xs |jkrnn|6c}}|D].}t|d} | t|| j|}|,|cS|jdvr]|jdddD cgc] } | dk7s |  } } t| D]*} |j| jkDst|| |cS|S#t $rYywxYwcc}wcc} w)z Try to find out the type of a variable just with the information that is given by the flows: e.g. It is also responsible for assert checks.:: if isinstance(k, str): k. # <- completion here ensures that `k` is a string. N assert_stmt)if_stmt while_stmt:)rdynamic_flow_informationr get_root_nodeget_used_namesr KeyErrorreversed start_posend_posr_check_isinstance_type assertionrchildren) r flow search_nameposresult module_nodernrassc potential_ifsif_tests rcheck_flow_informationr:5sZ  , , F~((*  ..01B1BCE ~~D0Ct||D     "D!$ 6C/s}}kR%!M  " yy--$(MM!$Q$$7Dq18D D . KG$$w6-eWkJJ K M'   Es#D69E+ E 6E 6 EEc|jdvrht|jdk(rP|j\}}|jdk(r2|jdk(r#|jdk(r|jddk(r|Sy)N)power atom_exprrr trailerr()rlenr/r )nodefirstr?s r_get_isinstance_trailer_arglistrD]si yy**s4==/AQ/Fw :: EKK<$?LLI-'2B2B12E2LN rcd}t|}|t|jdk(r|jd}t|j|||}t |j }t|dk(rQt|jdk(r9|\\}} \} } |,| *t|} t|jd} | | k(r| }|yt}|jD]u}t|tjrF|jdk(r7|jD]#}||jjz}%c||jz}w|S)Nr#r>rtuple)rDrAr/rinference_staterunpack_get_call_stringrinferr rSequence array_type py__iter__execute_with_values)r rBr1lazy_clsr?arglistargs param_listkey1_key2lazy_value_clscallis_instance_call value_set cls_or_tup lazy_values rr-r-gs^H-d3Gs7#3#349""1%U22E7GL$++-( z?a C(8(8$9Q$>0: -IT1-n| ' 4#3G4D4DQ4G#H ++-HInn&: j("3"3 49N9NRY9Y(335 F Z--/CCEE  F 779 9I : rc6|jjdk(rt|jSd}|j}|j j }|j |kr/||jz }|j}|j |kr/|S)Nr=) parentrrJget_first_leaf get_last_leafr,r+r get_next_leaf)rBcodeleafends rrJrJs {{;& ,, D    D     & &C ..3   !!# ..3  KrN)__doc__ parso.treerparso.python.treerjedirjedi.inference.argumentsrjedi.inference.valuerjedi.inference.base_valuerjedi.parser_utilsr rrr:rDr-rJrrrosA"'"2)/& )%PB r