uBFjvdZddlmZddlmZddlmZddlmZddl m Z ddl m Z dZ d Zd Zd Zd Zd ZdS)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. )Name)settings) TreeArguments)iterable) NO_VALUES)is_scopect|tr|jn|}g}|D]}||}|rnt 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 CC:\PYTHON\_runtimes\venv\Lib\site-packages\jedi/inference/finder.py filter_namersp (2+t'D'DU+##+K E ;''   E   '' ( ((c#xK|D]4}|j'|j}| |jdkr0|V5dS)Ndel_stmt) tree_nameget_definitiontype)rname definitions rrr*sZ > %6688J%*/Z*G*G rc,tjsdSd}tr} ||j}n#t $rYdSwxYwtfd|D}|D]5}|d}|t||j |}||cS6j dvrOdj dddD} t| D]%} |j | jkrt|| |cS&|S)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. NcVg|]%}j|jcxkr pjk nn|&S) start_posend_pos).0nflowposs r z*check_flow_information..HsP   ~DDDD0Ct|DDDDD DDDr assert_stmt)if_stmt while_stmtcg|] }|dk| S):r )r#cs rr'z*check_flow_information..UsDDDq188888r)rdynamic_flow_informationr get_root_nodeget_used_namesr KeyErrorreversedsearch_ancestor_check_isinstance_type assertionrchildrenr!r") r r% search_namer&result module_noderrass potential_ifsif_tests ` ` rcheck_flow_informationr?4s{  ,t F~~"((**  ..001BCEE   44             " "D&&}55C/s}kRR%!MMM y---DDDM!$Q$$7DDD  .. K KG$w66-eWkJJJJJ7 MsA A%$A%c|jdvrVt|jdkr>|j\}}|jdkr)|jdkr|jdkr|jddkr|SdS)N)power atom_exprrr trailerr()rlenr8r )nodefirstrDs r_get_isinstance_trailer_arglistrI\sq y***s4=/A/AQ/F/Fw :  EK<$?$?LI--'2B12E2L2LN 4rcd}t|}|t|jdkr|jd}t|j|||}t |}t|dkrXt|jdkr@|\\}} \} } |3| 1t|} t|jd} | | kr| }|dSt}| D]}t|tj rL|j dkrA|D]+}|| z},h||z}|S)Nr.rCrtuple)rIrFr8rinference_stater unpack_get_call_stringrinferr rSequence array_type py__iter__execute_with_values)r rGr9lazy_clsrDarglistargs param_listkey1_key2lazy_value_clscallis_instance_call value_set cls_or_tup lazy_values rr6r6fsH-d33Gs7#34499"1%U2E7GLL$++--(( z??a  C(8$9$9Q$>$>0: -IT1-n| ' 44#3G4DQ4G#H#H +++-HtInn&&:: j("3 4 4 :9NRY9Y9Y(3355 F F Z--//CCEEE  F 7799 9II rc|jjdkrt|jSd}|}|j}|j|kr)||jz }|}|j|k)|S)NrB) parentrrOget_first_leaf get_last_leafr"r!r get_next_leaf)rGcodeleafends rrOrOs {;&& ,,, D    D      &C .3    !!## .3   KrN)__doc__parso.python.treerjedirjedi.inference.argumentsrjedi.inference.valuerjedi.inference.base_valuerjedi.parser_utilsrrrr?rIr6rOr rrrrs"#"""""222222))))))//////&&&&&& ) ) )%%%PB     r