← Back
Editing: finder.cpython-311.pyc
� p�{c� � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z ddlmZ ddl mZ d � Zd � 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. � )�search_ancestor)�Name)�settings)� TreeArguments)�iterable)� NO_VALUES)�is_scopec � � t |t � � r|j n|}g }| D ]}|� |� � }|r 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 �7/usr/lib/python3/dist-packages/jedi/inference/finder.py�filter_namer sp � � (2�+�t�'D�'D�U�+�#�#�+�K��E�� � ��� � �;�'�'��� ��E� � � ��'�'�(�(�(� c # �x K � | D ]4}|j �'|j � � � }|�|j dk r�0|V � �5d S )N�del_stmt)� tree_name�get_definition�type)r �name� definitions r r r + sZ � � � �� � ���>�%���6�6�8�8�J��%�*�/�Z�*G�*G��� � � � �� r c �" ��� t j sdS d}t �� � r��� � � } |� � � |j }n# t $ r Y dS w xY wt ��fd�|D � � � � }|D ]0}t |d� � }|�t | |j |� � }|�|c S �1�j dv rOd� �j ddd� D � � } t | � � D ]%} |j | j k rt | | |� � c S �&|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. Nc �V �� g | ]%}�j |j cxk r �p�j k � n n|��&S � )� start_pos�end_pos)�.0�n�flow�poss ��r � <listcomp>z*check_flow_information.<locals>.<listcomp>I sP �� � � � ���~���D�D�D�D��0C�t�|�D�D�D�D�D� �D�D�Dr �assert_stmt)�if_stmt� while_stmtc � � g | ] }|d k �|��S )�:r! )r$ �cs r r( z*check_flow_information.<locals>.<listcomp>V s � �D�D�D�q�1��8�8��8�8�8r � � )r �dynamic_flow_informationr � get_root_node�get_used_namesr �KeyError�reversedr �_check_isinstance_type� assertionr �childrenr"