o
    Zh                     @   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 )NZ
_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/html/lang_env/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	   Z_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   )Zis_compiled)r   r   r   r   <lambda>:   s   
 z"_infer_from_stub.<locals>.<lambda>)Zjedi.inference.compiled.mixedr,   	get_valuer   r   Znon_stub_value_setfilterr"   )r%   r'   r$   r,   stub_moduleZ	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inferr1   get_defining_qualified_valuer+   gotoget_public_name)	namesprefer_stub_to_compiledr1   module_contextr*   r   	convertedconverted_namesnr   r   r   _try_stub_to_python_names@   s4   

r@   c                 C   s.   |   r| S t| j| jt| gd | j dS )N)Zimport_namesZpython_value_setZparent_module_valuesys_path)r   r   Zinference_stateZstring_namesr   Zget_sys_path)r2   r   r   r   _load_stub_modulea   s   rB   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 )Nr2   FT)
only_stubsfallback_to_python)r   r   r4   r8   r5   r6   r1   _python_to_stub_namesr7   to_stubr9   )r:   rE   r1   r<   
found_namer?   r*   r   xr=   r>   r   r   r   rF   m   sD   


rF   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 namesrD   )r;   )
ValueErrorr   increase_indent_cmrF   r@   )r:   rC   prefer_stubsr;   r   r   r   convert_names   s   
$rM   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   )rG   r   r   )r   value)rL   r   r   r      s    
z!convert_values.<locals>.<genexpr>c                 3   s&    | ]}t | d pt|hV  qdS )r3   N)r+   r   )r   r#   r3   r   r   r      s    
)r   rK   r   r!   )r*   rC   rL   r$   r   )r$   rL   r   r5      s   $r5   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   rB   r   r.   r   r   r"   r!   )rN   r&   r'   r0   r(   r)   Zstub_valuesr1   r   r   r   rG      s0   



rG   N)F)FFT)Zjedir   Zjedi.inference.base_valuer   r   Zjedi.inference.utilsr   Z!jedi.inference.gradual.stub_valuer   Zjedi.inference.gradual.typeshedr   Zjedi.inference.value.decoratorr	   r+   r    r@   rB   rF   rM   r5   rG   r   r   r   r   <module>   s     
* 
$
