o
    ˷e                     @   s   d dl mZ d dl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d	Zd
d ZedddZdd ZedddZdddZdddZdd ZdS )    )debug)ValueSet	NO_VALUES)to_list)StubModuleValue)try_to_load_stub_cached	DecorateeFc                    s   |   }| st| gS d t| tr| j|  }|r't| dd  |  } | 	 }|d u r1t
S |  }|rE|d }|d d }d}d  t|||}|rYt fdd|D }|r`||}d urotfdd|D }|S )N
_argumentsTc                 3   s2    | ]}|  r d u r| n| V  qd S N)is_classexecute_with_valuesexecute.0c)	arguments X/var/www/ideatree/venv/lib/python3.10/site-packages/jedi/inference/gradual/conversion.py	<genexpr>&   s    
z,_stub_to_python_value_set.<locals>.<genexpr>c                 3   s    | ]}t | V  qd S r   r   )r   v)	decoratesr   r   r   0   s    )get_root_contextis_stubr   
isinstancer	   _original_valueis_instancegetattrpy__class__get_qualified_namesr   is_bound_method_infer_from_stub	from_setspy__getattribute__)
stub_valueignore_compiledstub_module_contextwas_instancequalified_nameswas_bound_methodmethod_namevaluesr   )r   r   r   _stub_to_python_value_set
   s:   


r-   c                 C   sZ   ddl m} |  }t|t|fsJ | |j}|r!|dd }|D ]}||}q#|S )Nr   )MixedObjectc                 S   s
   |    S r   )is_compiled)r   r   r   r   <lambda>:   s   
 z"_infer_from_stub.<locals>.<lambda>)jedi.inference.compiled.mixedr.   	get_valuer   r   non_stub_value_setfilterr$   )r'   r)   r&   r.   stub_module	non_stubsnamer   r   r   r"   4   s   r"   c           	      c   s    | D ]W}|  }| s|V  q|jdkr+t| |d}|r*|D ]}|jV  q"qn,| }|d urWt||d}|rW||	 }|rW|D ]}|   rR|V  qF|V  qFq|V  qd S )Nmoduler&   )
r   r   api_typeconvert_valuesinferr7   get_defining_qualified_valuer-   gotoget_public_name)	namesprefer_stub_to_compiledr7   module_contextr,   r   	convertedconverted_namesnr   r   r   _try_stub_to_python_names@   s4   

rF   c                 C   s.   |   r| S t| j| jt| gd | j dS )N)import_namespython_value_setparent_module_valuesys_path)r   r   inference_statestring_namesr   get_sys_path)r8   r   r   r   _load_stub_modulea   s   rN   c                 c   s    | D ]j}|  }| r|V  q|jdkrKd}| D ]*}|jdkr7t| dd}|D ]}|jV  d}q-qt|g|dD ]}|V  d}q>q|rJqn| }|d urht	|}	|	rh|	|
 }
|
rh|
E d H  q|rm|V  qd S )Nr8   FT)
only_stubsfallback_to_python)r   r   r:   r>   r;   r<   r7   _python_to_stub_namesr=   to_stubr?   )r@   rQ   r7   rB   
found_namerE   r,   r   xrC   rD   r   r   r   rR   m   sD   


rR   Tc                 C   sl   |r|rt dtd |s|rt| |dW  d    S t| |dW  d    S 1 s/w   Y  d S )Nz3You cannot use both of only_stubs and prefer_stubs.zconvert namesrP   )rA   )
ValueErrorr   increase_indent_cmrR   rF   )r@   rO   prefer_stubsrA   r   r   r   convert_names   s   
$rY   c                    s   |rrJ t d+ |sr#tfdd| D W  d    S t fdd| D W  d    S 1 s9w   Y  d S )Nzconvert valuesc                 3   s*    | ]}t |p rt|hntV  qd S r   )rS   r   r   )r   value)rX   r   r   r      s    
z!convert_values.<locals>.<genexpr>c                 3   s&    | ]}t | d pt|hV  qdS )r9   N)r-   r   )r   r%   r9   r   r   r      s    
)r   rW   r   r#   )r,   rO   rX   r&   r   )r&   rX   r   r;      s   $r;   c                 C   s   |   r	t| gS |  }|r|  } |  }t|   }|d u s'|d u r)tS | 	 }|r;|d }|d d }d}t|g}|D ]}|
|}qB|rVtdd |D }|r]|
|}|S )Nr   Tc                 s   s     | ]}|  r| V  qd S r   )r   r   r   r   r   r   r      s    
zto_stub.<locals>.<genexpr>)r   r   r   r   r    rN   r   r2   r   r!   r$   r#   )rZ   r(   r)   r5   r*   r+   stub_valuesr7   r   r   r   rS      s0   



rS   N)F)FFT)jedir   jedi.inference.base_valuer   r   jedi.inference.utilsr   !jedi.inference.gradual.stub_valuer   jedi.inference.gradual.typeshedr   jedi.inference.value.decoratorr	   r-   r"   rF   rN   rR   rY   r;   rS   r   r   r   r   <module>   s     
* 
$
