o
    ï›h+G  ã                   @   s2  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d	lmZ dd
lmZ ddlmZ eƒ ZG dd„ deƒZG dd„ dƒZG dd„ deƒZd&dd„ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dƒZ d d!„ Z!G d"d#„ d#ƒZ"e"g ƒZ#d$d%„ Z$dS )'a4  
Values are the "values" that Python would return. However Values are at the
same time also the "values" that a user is currently sitting in.

A ValueSet is typically used to specify the return of a function or any other
static analysis operation. In jedi there are always multiple returns and not
just one.
é    )Úreduce)Úadd)Úzip_longest)ÚName)Údebug)Úclean_scope_docstring©ÚSimpleGetItemNotFound)Úsafe_property)Ú%inference_state_as_method_param_cache)Úmemoize_methodc                   @   s   e Zd ZdS )ÚHasNoContextN)Ú__name__Ú
__module__Ú__qualname__© r   r   úOc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/base_value.pyr      s    r   c                   @   s”   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zd"dd„Zdd„ Z	d#dd„Z
		d$dd„Zdd„ Zdd„ Zd"dd„Zdd„ Zdd„ Zed d!„ ƒZdS )%ÚHelperValueMixinc                 C   s.   | }|j d u r| ¡ S 	 |j d u r|S |j }q©N)Úparent_contextÚ
as_context)ÚselfÚvaluer   r   r   Úget_root_context   s   

ýz!HelperValueMixin.get_root_contextc                 C   s   | j j| |d�S )N©Ú	arguments©Úinference_stateÚexecute©r   r   r   r   r   r   (   ó   zHelperValueMixin.executec                 G   s,   ddl m} |dd„ |D ƒƒ}| j | |¡S )Nr   )ÚValuesArgumentsc                 S   s   g | ]}t |gƒ‘qS r   ©ÚValueSet©Ú.0r   r   r   r   Ú
<listcomp>-   s    z8HelperValueMixin.execute_with_values.<locals>.<listcomp>)Zjedi.inference.argumentsr!   r   r   )r   Z
value_listr!   r   r   r   r   Úexecute_with_values+   s   z$HelperValueMixin.execute_with_valuesc                 C   s   |   ¡ S r   ©r'   ©r   r   r   r   Úexecute_annotation0   ó   z#HelperValueMixin.execute_annotationc                 C   s
   t | gƒS r   r"   r)   r   r   r   Úgather_annotation_classes3   ó   
z*HelperValueMixin.gather_annotation_classesNFc                 C   s   t  dd„ |  ||¡D ƒ¡S )Nc                 s   ó   � | ]}|  ¡ V  qd S r   ©Úinfer©r%   Z
lazy_valuer   r   r   Ú	<genexpr>7   ó
   € ÿ
ÿz:HelperValueMixin.merge_types_of_iterate.<locals>.<genexpr>©r#   Ú	from_setsÚiterate)r   Úcontextualized_nodeÚis_asyncr   r   r   Úmerge_types_of_iterate6   s   

þz'HelperValueMixin.merge_types_of_iteratec                 c   sd   � t |tƒr|nd }| j|d�E d H  |  ¡ r.ddlm} |t| hƒƒD ]}| ¡ E d H  q$d S d S )N)Úorigin_scoper   )Úconvert_values)Ú
isinstancer   Zget_filtersÚis_stubZ!jedi.inference.gradual.conversionr;   r#   )r   Úname_or_strr:   r;   Úcr   r   r   Ú_get_value_filters<   s   €ýz#HelperValueMixin._get_value_filtersTc                 C   s6   ddl m} |  |¡}| ||¡}t d|| |¡ |S )Nr   )Úfinderzcontext.goto %s in (%s): %s)Újedi.inferencerA   r@   Zfilter_namer   Údbg)r   r>   Úname_contextÚanalysis_errorsrA   ÚfiltersÚnamesr   r   r   ÚgotoE   s
   
zHelperValueMixin.gotoc           	      C   s’   |du r| }|   |||¡}t dd„ |D ƒ¡}|s(t|tƒr!|jn|}|  |¡}|s@|s@|r@t|tƒr@ddlm} | 	|| |¡ t
 d||¡ |S )zZ
        :param position: Position of the last statement -> tuple of line, column
        Nc                 s   r.   r   r/   )r%   Únamer   r   r   r2   T   ó   € z6HelperValueMixin.py__getattribute__.<locals>.<genexpr>r   ©Úanalysisz context.names_to_types: %s -> %s)rH   r#   r5   r<   r   r   Úpy__getattribute__alternativesrB   rL   Zadd_attribute_errorr   rC   )	r   r>   rD   ÚpositionrE   rG   ÚvaluesÚnrL   r   r   r   Úpy__getattribute__L   s   

ÿz#HelperValueMixin.py__getattribute__c                 C   s"   |   d¡}|st d| ¡ | ¡ S )NÚ	__await__z"Tried to run __await__ on value %s)rQ   r   Úwarningr'   )r   Zawait_value_setr   r   r   Úpy__await__a   s   
zHelperValueMixin.py__await__c                 C   s   | j jS r   )rI   Ústring_namer)   r   r   r   Ú
py__name__g   r+   zHelperValueMixin.py__name__c                 C   sV   t  d| ¡ |r&ddlm} t||  d¡ ¡  d¡ ¡  d¡ ¡  ¡ ƒgƒS |  |¡S )Nz
iterate %sr   )ÚLazyKnownValuesÚ	__aiter__Ú	__anext__rR   )	r   rC   Újedi.inference.lazy_valuerW   ÚiterrQ   r'   Úpy__stop_iteration_returnsÚ
py__iter__)r   r7   r8   rW   r   r   r   r6   j   s   

üÿ
zHelperValueMixin.iteratec                 C   s„   t jd| |f dd��- |  ¡ D ]}| |¡r't jddd�  W d   ƒ dS qt jddd� 	 W d   ƒ dS 1 s;w   Y  d S )Nzsubclass matching of %s <=> %sZBLUE)Úcolorzmatched subclass TrueTzmatched subclass FalseF)r   Úincrease_indent_cmZ	py__mro__Úis_same_classrC   )r   Úclass_valueÚclsr   r   r   Úis_sub_class_ofz   s   ÿ
û$ùz HelperValueMixin.is_sub_class_ofc                 C   s"   t |ƒjtjkr| | ¡S | |kS r   )Útyper`   r   )r   Zclass2r   r   r   r`   „   s   
zHelperValueMixin.is_same_classc                 O   s   | j |i |¤ŽS r   )Ú_as_context©r   ÚargsÚkwargsr   r   r   r   Š   s   zHelperValueMixin.as_context©NF)NT)NNT)r   r   r   r   r   r'   r*   r,   r9   r@   rH   rQ   rT   rV   r6   rc   r`   r   r   r   r   r   r   r      s&    


	
ÿ

r   c                   @   s  e Zd ZdZdZdZdZdAdd„Zdd„ Zdd	„ Z	dAd
d„Z
dAdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zefd&d'„Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Z d6d7„ Z!d8d9„ Z"e#d:d;„ ƒZ$dBd=d>„Z%d?d@„ Z&dS )CÚValuez*
    To be implemented by subclasses.
    NZnot_defined_please_report_bugc                 C   ó   || _ || _d S r   )r   r   )r   r   r   r   r   r   Ú__init__™   ó   
zValue.__init__c                 C   s*   ddl m} |j|jd|jd|  d� tS )Nr   rK   ztype-error-not-subscriptablez+TypeError: '%s' object is not subscriptable©Úmessage)rB   rL   r   ÚcontextÚnodeÚ	NO_VALUES)r   Zindex_value_setr7   rL   r   r   r   Úpy__getitem__�   s   üzValue.py__getitem__c                 C   ó   t ‚r   r   )r   Úindexr   r   r   Úpy__simple_getitem__¨   ó   zValue.py__simple_getitem__c                 C   s6   |d urddl m} |j|jd|jd|  d� tg ƒS )Nr   rK   ztype-error-not-iterablez&TypeError: '%s' object is not iterablern   )rB   rL   r   rp   rq   r[   )r   r7   rL   r   r   r   r]   «   s   üzValue.py__iter__c                 C   s
   |   |¡S r   )r]   )r   r7   r   r   r   Ú
py__next__µ   r-   zValue.py__next__c                 C   s   g S r   r   r)   r   r   r   Úget_signatures¸   rw   zValue.get_signaturesc                 C   ó   dS ri   r   r)   r   r   r   Úis_class»   rw   zValue.is_classc                 C   rz   ri   r   r)   r   r   r   Úis_class_mixin¾   rw   zValue.is_class_mixinc                 C   rz   ri   r   r)   r   r   r   Úis_instanceÁ   rw   zValue.is_instancec                 C   rz   ri   r   r)   r   r   r   Úis_functionÄ   rw   zValue.is_functionc                 C   rz   ri   r   r)   r   r   r   Ú	is_moduleÇ   rw   zValue.is_modulec                 C   rz   ri   r   r)   r   r   r   Úis_namespaceÊ   rw   zValue.is_namespacec                 C   rz   ri   r   r)   r   r   r   Úis_compiledÍ   rw   zValue.is_compiledc                 C   rz   ri   r   r)   r   r   r   Úis_bound_methodÐ   rw   zValue.is_bound_methodc                 C   rz   ri   r   r)   r   r   r   Úis_builtins_moduleÓ   rw   zValue.is_builtins_modulec                 C   rz   )z‚
        Since Wrapper is a super class for classes, functions and modules,
        the return value will always be true.
        Tr   r)   r   r   r   Ú
py__bool__Ö   s   zValue.py__bool__c                 C   s,   z| j j W n
 ty   Y dS w t| j ƒS )NÚ )Ú	tree_nodeZget_doc_nodeÚAttributeErrorr   r)   r   r   r   Ú	py__doc__Ý   s   ÿ
zValue.py__doc__c                 C   s   |t u r
td|  ƒ‚|S )Nz'There exists no safe value for value %s)ÚsentinelÚ
ValueError)r   Údefaultr   r   r   Úget_safe_valueå   s   zValue.get_safe_valuec                 C   s   t  d|| |¡ tS )Nz!%s not possible between %s and %s©r   rS   rr   )r   ÚotherÚoperatorr   r   r   Úexecute_operationê   s   zValue.execute_operationc                 C   ó   t  d| ¡ tS )Nzno execution possible %sr�   r   r   r   r   Ú
py__call__î   ó   zValue.py__call__c                 C   r‘   )Nz0Not possible to return the stop iterations of %sr�   r)   r   r   r   r\   ò   r“   z Value.py__stop_iteration_returnsc                 C   ó   t S )zH
        For now a way to add values in cases like __getattr__.
        )rr   )r   r>   r   r   r   rM   ö   s   z$Value.py__getattribute__alternativesc                 C   s   t  d| ¡ t| gƒS )NzNo __get__ defined on %s)r   rS   r#   )r   Úinstancera   r   r   r   Ú	py__get__ü   s   
zValue.py__get__c                 C   r”   r   )ÚNotImplemented)r   Zcalling_instancer•   ra   r   r   r   Úpy__get__on_class   rw   zValue.py__get__on_classc                 C   ó   d S r   r   r)   r   r   r   Úget_qualified_names  ó   zValue.get_qualified_namesc                 C   ó
   | j  ¡ S r   )r   r=   r)   r   r   r   r=     s   
zValue.is_stubc                 C   rt   r   )r   r)   r   r   r   re     rw   zValue._as_contextc                 C   rt   r   ©ÚNotImplementedErrorr)   r   r   r   rI     r›   z
Value.nameTc                 C   r™   r   r   )r   Úadd_class_infor   r   r   Úget_type_hint  rw   zValue.get_type_hintc                 C   s   i S )an  
        When the current instance represents a type annotation, this method
        tries to find information about undefined type vars and returns a dict
        from type var name to value set.

        This is for example important to understand what `iter([1])` returns.
        According to typeshed, `iter` returns an `Iterator[_T]`:

            def iter(iterable: Iterable[_T]) -> Iterator[_T]: ...

        This functions would generate `int` for `_T` in this case, because it
        unpacks the `Iterable`.

        Parameters
        ----------

        `self`: represents the annotation of the current parameter to infer the
            value for. In the above example, this would initially be the
            `Iterable[_T]` of the `iterable` parameter and then, when recursing,
            just the `_T` generic parameter.

        `value_set`: represents the actual argument passed to the parameter
            we're inferred for, or (for recursive calls) their types. In the
            above example this would first be the representation of the list
            `[1]` and then, when recursing, just of `1`.
        r   )r   Ú	value_setr   r   r   Úinfer_type_vars  s   zValue.infer_type_varsr   ©T)'r   r   r   Ú__doc__r†   Z
array_typeZapi_typerl   rs   rv   r]   rx   ry   r{   r|   r}   r~   r   r€   r�   r‚   rƒ   r„   rˆ   r‰   rŒ   r�   r’   r\   rM   r–   r˜   rš   r=   re   ÚpropertyrI   r    r¢   r   r   r   r   rj   �   sH    





rj   NFc                 C   s   t  dd„ | j||d�D ƒ¡S )zƒ
    Calls `iterate`, on all values but ignores the ordering and just returns
    all values that the iterate functions yield.
    c                 s   r.   r   r/   r1   r   r   r   r2   8  r3   z!iterate_values.<locals>.<genexpr>©r8   r4   )rO   r7   r8   r   r   r   Úiterate_values3  s   
þr§   c                   @   s2   e Zd Zedd„ ƒZeeƒ dd„ ƒƒZdd„ ZdS )Ú_ValueWrapperBasec                 C   sB   ddl m} | jj}|jd ur|| |jƒS ddlm} || |jƒS )Nr   )Ú	ValueName)ÚCompiledValueName)Zjedi.inference.namesr©   Ú_wrapped_valuerI   Z	tree_nameZjedi.inference.compiledrª   rU   )r   r©   Zwrapped_namerª   r   r   r   rI   ?  s   
z_ValueWrapperBase.namec                 O   s   | |i |¤ŽS r   r   )rb   r   rg   rh   r   r   r   Úcreate_cachedI  s   z_ValueWrapperBase.create_cachedc                 C   s   |dksJ dƒ‚t | j|ƒS )Nr«   zProblem with _get_wrapped_value)Úgetattrr«   )r   rI   r   r   r   Ú__getattr__N  s   z_ValueWrapperBase.__getattr__N)	r   r   r   r
   rI   Úclassmethodr   r¬   r®   r   r   r   r   r¨   >  s    
	r¨   c                   @   s,   e Zd Zeedd„ ƒƒZdd„ Zdd„ ZdS )ÚLazyValueWrapperc                 C   s6   t  d¡� |  ¡ W  d   ƒ S 1 sw   Y  d S )NzResolve lazy value wrapper)r   r_   Ú_get_wrapped_valuer)   r   r   r   r«   T  s   $ÿzLazyValueWrapper._wrapped_valuec                 C   s   d| j j S )Nz<%s>)Ú	__class__r   r)   r   r   r   Ú__repr__Z  ó   zLazyValueWrapper.__repr__c                 C   rt   r   r�   r)   r   r   r   r±   ]  rw   z#LazyValueWrapper._get_wrapped_valueN)r   r   r   r
   r   r«   r³   r±   r   r   r   r   r°   S  s    r°   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚValueWrapperc                 C   s
   || _ d S r   )r«   )r   Zwrapped_valuer   r   r   rl   b  r-   zValueWrapper.__init__c                 C   ó   d| j j| jf S )Nz%s(%s))r²   r   r«   r)   r   r   r   r³   e  ó   zValueWrapper.__repr__N)r   r   r   rl   r³   r   r   r   r   rµ   a  s    rµ   c                       s$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )Ú	TreeValuec                    s   t ƒ  ||¡ || _d S r   )Úsuperrl   r†   )r   r   r   r†   ©r²   r   r   rl   j  s   
zTreeValue.__init__c                 C   r¶   )Nz<%s: %s>)r²   r   r†   r)   r   r   r   r³   n  r·   zTreeValue.__repr__)r   r   r   rl   r³   Ú__classcell__r   r   rº   r   r¸   i  s    r¸   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚContextualizedNodec                 C   rk   r   )rp   rq   )r   rp   rq   r   r   r   rl   s  rm   zContextualizedNode.__init__c                 C   rœ   r   )rp   r   r)   r   r   r   r   w  r-   z#ContextualizedNode.get_root_contextc                 C   s   | j  | j¡S r   )rp   Z
infer_noderq   r)   r   r   r   r0   z  s   zContextualizedNode.inferc                 C   s   d| j j| j| jf S )Nz<%s: %s in %s>)r²   r   rq   rp   r)   r   r   r   r³   }  ó   zContextualizedNode.__repr__N)r   r   r   rl   r   r0   r³   r   r   r   r   r¼   r  s
    r¼   c              	   C   s’   t }tƒ }|D ]+}|jd d�}t|ƒtttttfv r-z	||  	|¡O }W q t
y,   Y nw | |¡ q|s7|sA||  t|ƒ|¡O }t d|¡ |S )N)r‹   zpy__getitem__ result: %s)rr   ÚsetrŒ   rd   ÚfloatÚintÚstrÚsliceÚbytesrv   r	   r   rs   r#   r   rC   )r   Zindex_valuesr7   ÚresultZunused_valuesZindex_valueru   r   r   r   Ú_getitem�  s&   ÿþrÅ   c                   @   sè   e Zd Zdd„ Zedd„ ƒZedd„ ƒZdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd8d!d"„Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd9d4d5„Zd6d7„ ZdS ):r#   c                 C   s&   t |ƒ| _|D ]	}t|tƒrJ ‚qd S r   )Ú	frozensetÚ_setr<   r#   )r   Úiterabler   r   r   r   rl   �  s   
ÿzValueSet.__init__c                 C   s   |   | ¡}||_|S r   )Ú__new__rÇ   )rb   Z
frozenset_r   r   r   r   Ú_from_frozen_set¢  s   
zValueSet._from_frozen_setc                 C   s@   t ƒ }|D ]}t|tƒr||jO }q|t|ƒO }q|  t|ƒ¡S )z7
        Used to work with an iterable of set.
        )r¾   r<   r#   rÇ   rÆ   rÊ   )rb   ZsetsZ
aggregatedÚset_r   r   r   r5   ¨  s   
zValueSet.from_setsc                 C   s   |   | j|jB ¡S r   ©rÊ   rÇ   ©r   rŽ   r   r   r   Ú__or__µ  r·   zValueSet.__or__c                 C   s   |   | j|j@ ¡S r   rÌ   rÍ   r   r   r   Ú__and__¸  r·   zValueSet.__and__c                 C   ó
   t | jƒS r   )r[   rÇ   r)   r   r   r   Ú__iter__»  r-   zValueSet.__iter__c                 C   rÐ   r   )ÚboolrÇ   r)   r   r   r   Ú__bool__¾  r-   zValueSet.__bool__c                 C   rÐ   r   )ÚlenrÇ   r)   r   r   r   Ú__len__Á  r-   zValueSet.__len__c                 C   s   dd  dd„ | jD ƒ¡ S )NzS{%s}ú, c                 s   s   � | ]}t |ƒV  qd S r   )rÁ   )r%   Úsr   r   r   r2   Å  rJ   z$ValueSet.__repr__.<locals>.<genexpr>)ÚjoinrÇ   r)   r   r   r   r³   Ä  ó   zValueSet.__repr__c                 C   s   |   t|| jƒ¡S r   )r²   ÚfilterrÇ   )r   Zfilter_funcr   r   r   rÚ   Ç  r·   zValueSet.filterc                    s   ‡ ‡fdd„}|S )Nc                     s   ˆ  ‡ ‡‡fdd„ˆjD ƒ¡S )Nc                 3   s$   � | ]}t |ˆƒˆ i ˆ¤ŽV  qd S r   )r­   r$   )rg   rh   rI   r   r   r2   Ì  s
   € ÿ
ÿz7ValueSet.__getattr__.<locals>.mapper.<locals>.<genexpr>)r5   rÇ   ©rg   rh   ©rI   r   rÛ   r   ÚmapperË  s   þz$ValueSet.__getattr__.<locals>.mapperr   )r   rI   rÝ   r   rÜ   r   r®   Ê  s   zValueSet.__getattr__c                 C   s   | j |j kS r   ©rÇ   rÍ   r   r   r   Ú__eq__Ò  r´   zValueSet.__eq__c                 C   s   |   |¡ S r   )rß   rÍ   r   r   r   Ú__ne__Õ  r´   zValueSet.__ne__c                 C   rÐ   r   )ÚhashrÇ   r)   r   r   r   Ú__hash__Ø  r-   zValueSet.__hash__c                 C   s   t dd„ | jD ƒƒS )Nc                 s   r.   r   )Úpy__class__©r%   r?   r   r   r   r2   Ü  rJ   z'ValueSet.py__class__.<locals>.<genexpr>)r#   rÇ   r)   r   r   r   rã   Û  s   zValueSet.py__class__NFc                 #   sJ   � ddl m} ‡ ‡fdd„| jD ƒ}t|Ž D ]}|dd„ |D ƒƒV  qd S )Nr   )Úget_merged_lazy_valuec                    s   g | ]	}|j ˆ ˆd �‘qS )r¦   )r6   rä   ©r7   r8   r   r   r&   à  s    z$ValueSet.iterate.<locals>.<listcomp>c                 S   s   g | ]}|d ur|‘qS r   r   )r%   Úlr   r   r   r&   ã  ó    )rZ   rå   rÇ   r   )r   r7   r8   rå   Z
type_itersZlazy_valuesr   ræ   r   r6   Þ  s   €ÿÿzValueSet.iteratec                    s   t  ‡ fdd„| jD ƒ¡S )Nc                 3   s   � | ]
}|j  |ˆ ¡V  qd S r   r   rä   r   r   r   r2   ç  s   € z#ValueSet.execute.<locals>.<genexpr>©r#   r5   rÇ   r   r   r   r   r   æ  rÙ   zValueSet.executec                    ó   t  ‡ ‡fdd„| jD ƒ¡S )Nc                 3   ó    � | ]}|j ˆ i ˆ¤ŽV  qd S r   r(   rä   rÛ   r   r   r2   ê  ó   € z/ValueSet.execute_with_values.<locals>.<genexpr>ré   rf   r   rÛ   r   r'   é  ó   zValueSet.execute_with_valuesc                    s   t t‡ ‡fdd„| jD ƒg ƒS )Nc                    s   g | ]
}|j ˆ i ˆ¤Ž‘qS r   )rH   rä   rÛ   r   r   r&   í  s    z!ValueSet.goto.<locals>.<listcomp>)r   r   rÇ   rf   r   rÛ   r   rH   ì  s   zValueSet.gotoc                    rê   )Nc                 3   rë   r   )rQ   rä   rÛ   r   r   r2   ð  rì   z.ValueSet.py__getattribute__.<locals>.<genexpr>ré   rf   r   rÛ   r   rQ   ï  rí   zValueSet.py__getattribute__c                    rê   )Nc                 3   s&   � | ]}t |gˆ ¢R i ˆ¤ŽV  qd S r   )rÅ   rä   rÛ   r   r   r2   ó  s   €$ z$ValueSet.get_item.<locals>.<genexpr>ré   rf   r   rÛ   r   Úget_itemò  rí   zValueSet.get_itemc              	   C   sF   |   g ¡}| jD ]}zt||ƒ}W n	 ty   Y qw ||ƒ O }q|S r   )r²   rÇ   r­   r‡   )r   Zfunction_namer¡   r?   Úmethodr   r   r   Ú	try_mergeõ  s   

ÿzValueSet.try_mergec                 C   s   t  dd„ | jD ƒ¡S )Nc                 S   s   g | ]}|  ¡ ‘qS r   )r,   rä   r   r   r   r&     s    z6ValueSet.gather_annotation_classes.<locals>.<listcomp>ré   r)   r   r   r   r,      r½   z"ValueSet.gather_annotation_classesc                 C   s   dd„ | j D ƒS )Nc                 S   s   g | ]}|  ¡ D ]}|‘qqS r   )ry   )r%   r?   Úsigr   r   r   r&     s    z+ValueSet.get_signatures.<locals>.<listcomp>rÞ   r)   r   r   r   ry     r    zValueSet.get_signaturesTc                    s�   ‡ fdd„| j D ƒ}ttd |ƒƒ}t|ƒdkr|d S d|v }|r&| d¡ t|ƒdkr.d S t|ƒdkr9|d }ndd |¡ }|rFd| }|S )	Nc                    s   g | ]}|j ˆ d �‘qS )©rŸ   )r    )r%   Úvrò   r   r   r&     rè   z*ValueSet.get_type_hint.<locals>.<listcomp>é   r   ÚNonez	Union[%s]rÖ   zOptional[%s])rÇ   ÚsortedrÚ   rÔ   ÚremoverØ   )r   rŸ   ÚtZ
type_hintsÚoptionalr×   r   rò   r   r      s   

zValueSet.get_type_hintc                 C   s0   ddl m} i }| jD ]
}||| |¡ƒ q|S )Nr   )Úmerge_type_var_dicts)Z!jedi.inference.gradual.annotationrú   rÇ   r¢   )r   r¡   rú   Ztype_var_dictr   r   r   r   r¢     s   
þzValueSet.infer_type_varsri   r£   )r   r   r   rl   r¯   rÊ   r5   rÎ   rÏ   rÑ   rÓ   rÕ   r³   rÚ   r®   rß   rà   râ   rã   r6   r   r'   rH   rQ   rî   rð   r,   ry   r    r¢   r   r   r   r   r#   œ  s:    



r#   c                    s   ‡ fdd„}|S )Nc                     s   t ˆ | i |¤ŽƒS r   r"   rÛ   ©Úfuncr   r   Úwrapper+  r·   z&iterator_to_value_set.<locals>.wrapperr   )rü   rý   r   rû   r   Úiterator_to_value_set*  s   rþ   ri   )%r¤   Ú	functoolsr   r�   r   Ú	itertoolsr   Zparso.python.treer   Zjedir   Zjedi.parser_utilsr   Zjedi.inference.helpersr	   Zjedi.inference.utilsr
   Zjedi.inference.cacher   Z
jedi.cacher   Úobjectr‰   Ú	Exceptionr   r   rj   r§   r¨   r°   rµ   r¸   r¼   rÅ   r#   rr   rþ   r   r   r   r   Ú<module>   s6    r 
%	 