Ë
    ½lÔhÎ  ã                   ó€   — d 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 d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zy)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_scopec                 ó¢   — t        |t        «      r|j                  n|}g }| D ]  }|j                  |«      }|sŒ n t	        t        |«      «      S )zh
    Searches names that are defined in a scope (the different
    ``filters``), until a name fits.
    )Ú
isinstancer   ÚvalueÚgetÚlistÚ_remove_del_stmt)ÚfiltersÚname_or_strÚstring_nameÚnamesÚfilters        új/home/josh/.local/share/pipx/venvs/python-lsp-server/lib/python3.12/site-packages/jedi/inference/finder.pyÚfilter_namer      sU   € ô
 (2°+¼tÔ'D�+×#Ò#È+€KØ€EØò ˆØ—
‘
˜;Ó'ˆÚÙðô
 Ô  Ó'Ó(Ð(ó    c              #   ó’   K  — | D ]>  }|j                   �,|j                   j                  «       }|�|j                  dk(  rŒ;|–— Œ@ y ­w)NÚdel_stmt)Ú	tree_nameÚget_definitionÚtype)r   ÚnameÚ
definitions      r   r   r   +   sJ   è ø€ àò ˆØ�>‰>Ð%ØŸ™×6Ñ6Ó8ˆJØÐ%¨*¯/©/¸ZÒ*GØØ‹
ñùs   ‚AAc                 óž  — t         j                  syd}t        |«      rª|j                  «       }	 |j	                  «       |j
                     }t        |D �cg c]4  }|j                  |j                  cxk  r|xs |j                  k  rn n|‘Œ6 c}«      }|D ].  }t        |d«      }	|	€Œt        | |	j                  |«      }|€Œ,|c S  |j                  dv r]|j                  ddd…   D �
cg c]
  }
|
dk7  sŒ	|
‘Œ }}
t        |«      D ]*  }|j                  |j                  kD  sŒt        | ||«      c S  |S # t        $ r Y yw xY wc c}w c c}
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é   é   ú:)r   Údynamic_flow_informationr	   Úget_root_nodeÚget_used_namesr   ÚKeyErrorÚreversedÚ	start_posÚend_posr   Ú_check_isinstance_typeÚ	assertionr   Úchildren)r   ÚflowÚsearch_nameÚposÚresultÚmodule_noder   Únr   ÚassÚcÚpotential_ifsÚif_tests                r   Úcheck_flow_informationr:   5   sZ  € ô ×,Ò,Øà€FÜ�„~à×(Ñ(Ó*ˆð	Ø×.Ñ.Ó0°×1BÑ1BÑCˆEô Øö
ØØ�~‰~ §¡ÔD°Ò0C°t·|±|ÕDò ò
ó ˆð
 ò 	"ˆDÜ! $¨Ó6ˆCØ‰Ü/°°s·}±}ÀkÓR�ØÑ%Ø!’Mð	"ð ‡y�yÐ-Ñ-Ø$(§M¡M°!°$°Q°$Ñ$7ÖD˜q¸1À»8šÐDˆÐDÜ Ó.ò 	KˆGØ×$Ñ$ w§¡Ó6Ü-¨e°W¸kÓJÒJð	Kð €Møô' ò 	Ùð	üò
ùò Es#   °D6 Á9EÃ+
E
Ã6E
Ä6	EÅEc                 óð   — | j                   dv rht        | j                  «      dk(  rP| j                  \  }}|j                   dk(  r2|j                  dk(  r#|j                   dk(  r|j                  d   dk(  r|S y )N)ÚpowerÚ	atom_expré   r   r   Útrailerr   ú()r   Úlenr/   r   )ÚnodeÚfirstr?   s      r   Ú_get_isinstance_trailer_arglistrD   ]   si   € Ø‡y�yÐ*Ñ*¬s°4·=±=Ó/AÀQÒ/FàŸ™‰ˆˆwØ�:‰:˜Ò E§K¡K°<Ò$?Ø—L‘L IÒ-°'×2BÑ2BÀ1Ñ2EÈÒ2LØˆNØr   c                 ó´  — d }t        |«      }|�·t        |j                  «      dk(  rŸ|j                  d   }t        | j                  | ||«      }t        |j                  «       «      }t        |«      dk(  rQt        |j                  «      dk(  r9|\  \  }}	\  }
}|€,|
€*t        |«      }t        |j                  d   «      }||k(  r|}|€y t        }|j                  «       D ]u  }t        |t        j                  «      rF|j                  dk(  r7|j                  «       D ]#  }||j                  «       j                  «       z  }Œ% Œc||j                  «       z  }Œw |S )Né   r#   r>   r   Útuple)rD   rA   r/   r   Úinference_stater   ÚunpackÚ_get_call_stringr   Úinferr   r   ÚSequenceÚ
array_typeÚ
py__iter__Úexecute_with_values)r   rB   r1   Úlazy_clsr?   ÚarglistÚargsÚ
param_listÚkey1Ú_Úkey2Úlazy_value_clsÚcallÚis_instance_callÚ	value_setÚ
cls_or_tupÚ
lazy_values                    r   r-   r-   g   s^  € Ø€HÜ-¨dÓ3€GØÐœs 7×#3Ñ#3Ó4¸Ò9Ø×"Ñ" 1Ñ%ˆÜ˜U×2Ñ2°E¸7ÀGÓLˆÜ˜$Ÿ+™+›-Ó(ˆ
äˆz‹?˜aÒ¤C¨×(8Ñ(8Ó$9¸QÒ$>Ø0:Ñ-‰IˆT�1Ñ-˜˜nØˆ|  Ü'¨Ó4�Ü#3°G×4DÑ4DÀQÑ4GÓ#HÐ ð Ð+Ò+Ø-�HØÐØä€IØ—n‘nÓ&ò :ˆ
Ü�j¤(×"3Ñ"3Ô4¸×9NÑ9NÐRYÒ9YØ(×3Ñ3Ó5ò F�
Ø˜Z×-Ñ-Ó/×CÑCÓEÑE‘	ñFð ˜×7Ñ7Ó9Ñ9‰Ið:ð Ðr   c                 ó6  — | j                   j                  dk(  rt        | j                   «      S d}| j                  «       }| j	                  «       j
                  }|j                  |k  r/||j                  z  }|j                  «       }|j                  |k  rŒ/|S )Nr=   Ú )	Úparentr   rJ   Úget_first_leafÚget_last_leafr,   r+   r   Úget_next_leaf)rB   ÚcodeÚleafÚends       r   rJ   rJ   ˆ   s‡   € Ø‡{�{×Ñ˜;Ò&Ü §¡Ó,Ð,à€DØ×ÑÓ €DØ
×
Ñ
Ó
×
&Ñ
&€CØ
�.‰.˜3Ò
Ø�—
‘
ÑˆØ×!Ñ!Ó#ˆð �.‰.˜3Ó
ð €Kr   N)Ú__doc__Ú
parso.treer   Úparso.python.treer   Újedir   Újedi.inference.argumentsr   Újedi.inference.valuer   Újedi.inference.base_valuer   Újedi.parser_utilsr	   r   r   r:   rD   r-   rJ   © r   r   ú<module>ro      sA   ðñõ" 'Ý "å Ý 2Ý )Ý /Ý &ò)òò%òPòóB
r   