
    fgC              	          d Z ddlZddlmZ ddlmZmZ ddlmZm	Z	m
Z
mZmZ ddlmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZmZmZ ddlmZ ddlmZm Z  djC                         Z"dddddddddZ#djC                         Z$ G d de      Z% G d de      Z& G d de      Z' G d d e      Z( G d! d"e      Z) G d# d$e'e)      Z* G d% d&e(e)      Z+ G d' d(e      Z, G d) d*e      Z- G d+ d,e      Z. G d- d.e      Z/ G d/ d0e      Z0 G d1 d2e      Z1 G d3 d4e      Z2 G d5 d6e      Z3 G d7 d8e
      Z4 G d9 d:e      Z5 G d; d<e      Z6 G d= d>e      Z7y)?z
We need to somehow work with the typing objects. Since the typing objects are
pretty bare we need to add all the Jedi customizations to make them work as
values.

This file deals with all the typing.py cases.
    N)debug)builtin_from_namecreate_simple_object)ValueSet	NO_VALUESValueLazyValueWrapperValueWrapper)LazyKnownValues)repack_with_argument_clinic)FilterWrapper)NameWrapper	ValueName)
ClassMixin)BaseTypingValueBaseTypingClassWithGenericsBaseTypingInstance)TypeVarClass)LazyGenericManagerTupleGenericManagerz$Tuple Generic Protocol Callable Typezbuiltins.listzbuiltins.dictzbuiltins.setzbuiltins.frozensetzcollections.ChainMapzcollections.Counterzcollections.defaultdictzcollections.deque)ListDictSet	FrozenSetChainMapCounterDefaultDictDequez!Optional Union ClassVar Annotatedc                       e Zd Zd Zd Zy)TypingModuleNamec                 4    t        | j                               S N)r   _remapselfs    X/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/inference/gradual/typing.pyinferzTypingModuleName.infer'   s    &&    c              #     K   | j                   }| j                  j                  }	 t        |   }t        j                  || j                  | j                  |       y # t        $ r Y nw xY w|t        v r.t        j                  || j                  | j                         y |t        v r.t        j                  || j                  | j                         y |dk(  ry |dk(  r5| j                  j                         \  }t        j
                  ||       y |dk(  r.t        j                  || j                  | j                         y |dk(  rt!        |d       y |dk(  r.t"        j                  || j                  | j                         y |dk(  r5| j                  j                         \  }t$        j                  ||       y |dk(  r5| j                  j                         \  }t&        j                  ||       y |d	k(  r.t(        j                  || j                  | j                         y | j                  j                         E d {  7   y w)
NruntimeTypeVarAnyTYPE_CHECKINGTrueoverloadNewTypecast	TypedDict)string_nameparent_contextinference_state_TYPE_ALIAS_TYPES	TypeAliascreate_cached	tree_nameKeyError_PROXY_CLASS_TYPESProxyTypingClassValue_PROXY_TYPESProxyTypingValue_wrapped_namer'   r   AnyClassr   OverloadFunctionNewTypeFunctionCastFunctionTypedDictClass)r%   namer5   actualclsvcast_fns          r&   r#   zTypingModuleName._remap*   s,    --==	&t,F ))!4!4dnnfN N  		 %%'55!4!4dnnF F\!"00!4!4dnnF FY Y%%++-DC,,_cBBU]((!4!4dnnF F_$ $OV<<Z"00!4!4dnnF FY##))+BA!//CCV^))//1HG,,_gFF[  !..!4!4dnnF F ))//111s4   #I	A /I	A*'I)A**G-IIIN)__name__
__module____qualname__r'   r#    r(   r&   r    r    &   s    '32r(   r    c                       e Zd ZeZy)TypingModuleFilterWrapperN)rJ   rK   rL   r    name_wrapper_classrM   r(   r&   rO   rO   `   s    )r(   rO   c                   $    e Zd Zd Zd Zd Zd Zy)ProxyWithGenericsc                    | j                   j                  }|dk(  r| j                         j                         S |dk(  r?| j                         j                         t	        t        | j                  d      g      z  S |dk(  r| j                  d   S |dv r| j                  d   j                         S t        t        t        t        d}||   }t	         || j                  | | j                   | j                        g      S )	NUnionOptionalNoneTyper   )ClassVar	Annotated)TupleGenericProtocolCallablegenerics_manager)
_tree_namevaluegather_annotation_classesexecute_annotationr   r   r5   _generics_managerrZ   r[   r\   r]   r4   )r%   r3   mappedrG   s       r&   rc   z$ProxyWithGenerics.execute_annotatione   s	   oo++'! 113FFHHJ& 113FFH-d.B.BFKLMN NF"))!,,55))!,??AA   	
 [!OO!33	
   	r(   c                 \    t        j                  | j                  j                               S r"   )r   	from_setsrd   to_tupler$   s    r&   rb   z+ProxyWithGenerics.gather_annotation_classes   s"    !!$"8"8"A"A"CDDr(   c                 D    t        | j                  | j                  |      S r"   )rR   r4   r`   r%   r_   s     r&   _create_instance_with_genericsz0ProxyWithGenerics._create_instance_with_generics   s"     OO
 	
r(   c                     | j                         }|si S | j                         }|dk(  r<t        | j                  d      |d   j	                  |j                  fd            S i S )NrU   rV   r   c                     | k7  S r"   rM   )xnones    r&   <lambda>z3ProxyWithGenerics.infer_type_vars.<locals>.<lambda>   s    19 r(   )get_generics
py__name__r   r5   infer_type_varsfilter)r%   	value_setannotation_genericsannotation_namero   s       @r&   rs   z!ProxyWithGenerics.infer_type_vars   sp    "//1"I//+j( %T%9%96BD&q)99  !45  	r(   N)rJ   rK   rL   rc   rb   rk   rs   rM   r(   r&   rR   rR   d   s    BE
r(   rR   c                       e Zd ZeZd Zd Zy)r>   c                     | j                   j                  | j                  | j                  | j                  t        |            S )Nr^   )index_classr8   r5   r4   r`   r   )r%   generics_tuples     r&   with_genericszProxyTypingValue.with_generics   sA    --  OO0@	 . 
 	
r(   c                 0     t         fd|D              S )Nc           
   3      K   | ]V  }j                   j                  j                  j                  j                  t        j                  |              X yw))context_of_indexindex_valuer^   N)rz   r8   r5   r4   r`   r   context).0r   contextualized_noder%   s     r&   	<genexpr>z1ProxyTypingValue.py__getitem__.<locals>.<genexpr>   s^      

  **$$##!3%8%@%@ +"	 + 

s   AAr   r%   index_value_setr   s   ` `r&   py__getitem__zProxyTypingValue.py__getitem__   s     

 "1

 

 
	
r(   N)rJ   rK   rL   rR   rz   r|   r   rM   r(   r&   r>   r>      s    #K

r(   r>   c                   (    e Zd Zd Zd Zed        Zy)_TypingClassMixinc                 `    t        | j                  j                  j                  d            gS )Nobject)r   r5   builtins_modulepy__getattribute__r$   s    r&   py__bases__z_TypingClassMixin.py__bases__   s.      00CCHM
  	r(   c                     g S r"   rM   r$   s    r&   get_metaclassesz!_TypingClassMixin.get_metaclasses       	r(   c                 .    t        | | j                        S r"   )r   r`   r$   s    r&   rE   z_TypingClassMixin.name   s    t//r(   N)rJ   rK   rL   r   r   propertyrE   rM   r(   r&   r   r      s     
 0 0r(   r   c                       e Zd Zd Zd Zy)TypingClassWithGenericsc                 ^   i }| j                         }|s|S | j                         }|dk(  r"|d   j                  |j                               S |dk(  r2t	        |      dk(  r"|d   j                  |j                               S |S |dk(  r#| j                         \  }|j                  |      S |S )NrW   r   r]         rZ   )rq   rr   rs   rc   len)r%   ru   type_var_dictrv   rw   tuple_annotations         r&   rs   z'TypingClassWithGenerics.infer_type_vars   s    "//1"  //+f$&q)99 ,,.	  
*&'1,*1-==002  	 ' $ 7 7 9#33I>>r(   c                 D    t        | j                  | j                  |      S r"   )r   r4   r`   rj   s     r&   rk   z6TypingClassWithGenerics._create_instance_with_generics   s"    &OO
 	
r(   N)rJ   rK   rL   rs   rk   rM   r(   r&   r   r      s    8
r(   r   c                       e Zd ZeZy)r<   N)rJ   rK   rL   r   rz   rM   r(   r&   r<   r<      s    )Kr(   r<   c                   @    e Zd Zd Zed        Zd Zd Zd Zd Z	d Z
y)	r7   c                 P    |j                   | _         || _        || _        || _        y r"   )r5   r4   _origin_tree_name_actual)r%   r4   origin_tree_namerF   s       r&   __init__zTypeAlias.__init__   s'    -==,!1r(   c                 .    t        | | j                        S r"   )r   r   r$   s    r&   rE   zTypeAlias.name   s    t5566r(   c                 .    | j                   j                  S r"   )rE   r3   r$   s    r&   rr   zTypeAlias.py__name__   s    yy$$$r(   c                 P    d| j                   j                  d| j                  dS )N<z: >)	__class__rJ   r   r$   s    r&   __repr__zTypeAlias.__repr__  s    !^^44dllCCr(   c                 4   | j                   j                  d      \  }}ddlm}  || j                  |g| j                  j
                        j                         \  }|j                  |      }t        |      dk(  sJ |       t        t        |            }|S )N.r   )Importerr   )r   splitjedi.inference.importsr   r5   r   followr   r   nextiter)r%   module_name
class_namer   moduleclassesrG   s          r&   _get_wrapped_valuezTypeAlias._get_wrapped_value  s    "&,,"4"4S"9Z 	4  ;-1E1E1U1U

&( 	 ++J77|q )') 4=!
r(   c                 6    t        | j                         g      S r"   )r   r   r$   s    r&   rb   z#TypeAlias.gather_annotation_classes  s    002344r(   c                     g S r"   rM   r$   s    r&   get_signatureszTypeAlias.get_signatures  r   r(   N)rJ   rK   rL   r   r   rE   rr   r   r   rb   r   rM   r(   r&   r7   r7      s5     7 7%D5r(   r7   c                       e Zd Zd Zd Zy)r]   c                     	 | j                   d   }| j                   d   }ddlm}  ||||      S # t        $ r t	        j
                  d       t        cY S w xY w)zG
            def x() -> Callable[[Callable[..., _T]], _T]: ...
        r   r   )infer_return_for_callablez+Callable[...] defined without two arguments)rd   !jedi.inference.gradual.annotationr   
IndexErrorr   warningr   )r%   	argumentsparam_valuesresult_valuesr   s        r&   
py__call__zCallable.py__call__  sa    
	U11!4L 2215M
 T,YmTT  	MMGH	s   0 $AAc                     t        | g      S r"   r   )r%   instanceclass_values      r&   	py__get__zCallable.py__get__)  s    r(   N)rJ   rK   rL   r   r   rM   r(   r&   r]   r]     s    U r(   r]   c                   B    e Zd Zd Zd Zd	dZd Zd Zed        Z	d Z
y)
rZ   c                 6    | j                   j                         S r"   )rd   is_homogenous_tupler$   s    r&   _is_homogenouszTuple._is_homogenous.  s     %%99;;r(   c                     | j                         r| j                  j                  d      S t        |t              r| j                  j                  |      S t        j                  d|z         t        S )Nr   z The getitem type on Tuple was %s)r   rd   get_index_and_execute
isinstanceintr   dbgr   r%   indexs     r&   py__simple_getitem__zTuple.py__simple_getitem__3  s^     ))??BB%%--CCEJJII85@Ar(   Nc              #      K   | j                         r't        | j                  j                  d             y | j                  j	                         D ]  }t        |j                                 y wNr   )r   r   rd   r   rh   rc   )r%   r   rH   s      r&   
py__iter__zTuple.py__iter__=  s`      !$"8"8"N"Nq"QRR++446 >%a&:&:&<==>s   A3A5c                     | j                         r| j                  j                  d      S t        j                  | j                  j                               j                         S r   )r   rd   r   r   rg   rh   rc   r   s      r&   r   zTuple.py__getitem__D  sS     ))??BB!!""++-



	r(   c                 p    | j                   j                  j                  d      j                         \  }|S Ntuple)r5   r   r   rc   )r%   tuple_s     r&   r   zTuple._get_wrapped_valueL  s1    &&66(););)= 	r(   c                 .    | j                   j                  S r"   )_wrapped_valuerE   r$   s    r&   rE   z
Tuple.nameQ  s    ""'''r(   c                 Z   ddl m}m} |j                  d       }| j	                         r:| j
                  j                         d   j                  |j                               S i }|D ]0  }	 |j                  } |       } || || j
                  |             2 |S # t        $ r Y @w xY w)Nr   )merge_pairwise_genericsmerge_type_var_dictsc                 D    | j                         j                         dk(  S r   )rr   lower)rn   s    r&   rp   z'Tuple.infer_type_vars.<locals>.<lambda>Z  s    alln**,7 r(   )r   r   r   rt   r   _class_valuerq   rs   merge_types_of_iterateget_annotated_class_objectAttributeError)r%   ru   r   r   r   elementmethodpy_classs           r&   rs   zTuple.infer_type_varsU  s    c$$7
	   $$113A6FF002  M$ $??F "8$!+D,=,=xH !  &  	s   -B	B*)B*r"   )rJ   rK   rL   r   r   r   r   r   r   rE   rs   rM   r(   r&   rZ   rZ   -  s4    <
>
 ( (&!r(   rZ   c                       e Zd Zy)r[   NrJ   rK   rL   rM   r(   r&   r[   r[   ~      r(   r[   c                       e Zd Zy)r\   Nr   rM   r(   r&   r\   r\     r   r(   r\   c                       e Zd Zd Zy)r@   c                 8    t        j                  d       t        S )NzUsed Any - returned no results)r   r   r   r$   s    r&   rc   zAnyClass.execute_annotation  s    67r(   N)rJ   rK   rL   rc   rM   r(   r&   r@   r@     s    r(   r@   c                   (    e Zd Z ed      d        Zy)rA   zfunc, /c                     |S r"   rM   )r%   func_value_sets     r&   r   zOverloadFunction.py__call__  s
     r(   NrJ   rK   rL   r   r   rM   r(   r&   rA   rA     s     + ,r(   rA   c                       e Zd Zd Zy)rB   c                      |j                         }t        |d       t        |d      \  }t        S t         fd|j	                         D              S )N)NNc              3      K   | ]>  }t        j                  |j                  |j                  j	                                @ y wr"   )r0   r5   r   noder'   )r   r   
second_argr%   s     r&   r   z-NewTypeFunction.py__call__.<locals>.<genexpr>  sI      H & $$#++#((  "	Hs   AA)unpackr   r   r   get_calling_nodes)r%   r   ordered_args_r   s   `   @r&   r   zNewTypeFunction.py__call__  s`     '')\<(\<8: H *3)D)D)FH H 	Hr(   N)rJ   rK   rL   r   rM   r(   r&   rB   rB     s    Hr(   rB   c                   F     e Zd Z fdZd Zd Zed        ZdefdZ	 xZ
S )r0   c                 B    t         |   ||       || _        || _        y r"   )superr   _type_value_set	tree_node)r%   r5   r4   r  type_value_setr   s        r&   r   zNewType.__init__  s!    .9-"r(   c                 >    | j                   j                         \  }|S r"   )r  py__class__)r%   cs     r&   r  zNewType.py__class__  s    !!--/r(   c                 6    | j                   j                         S r"   )r  rc   )r%   r   s     r&   r   zNewType.py__call__  s    ##6688r(   c                      ddl m}  || d      S )Nr   )CompiledValueNamer0   )jedi.inference.compiled.valuer
  )r%   r
  s     r&   rE   zNewType.name  s    C y11r(   returnc                 :    d| j                   d| j                  S )Nz
<NewType: r   )r  r  r$   s    r&   r   zNewType.__repr__  s    $(NND4H4HIIr(   )rJ   rK   rL   r   r  r   r   rE   strr   __classcell__)r   s   @r&   r0   r0     s4    #
9 2 2J# Jr(   r0   c                   (    e Zd Z ed      d        Zy)rC   ztype, object, /c                 "    |j                         S r"   )rc   )r%   r  object_value_sets      r&   r   zCastFunction.py__call__  s    0022r(   Nr   rM   r(   r&   rC   rC     s     !233 43r(   rC   c                       e Zd ZdZy)rD   zr
    This class has no responsibilities and is just here to make sure that typed
    dicts can be identified.
    N)rJ   rK   rL   __doc__rM   r(   r&   rD   rD     s    r(   rD   c                   8    e Zd ZdZd Zed        Zd Zd Zd Z	y)r2   z6Represents the instance version of ``TypedDictClass``.c                 x    |j                   | _         |j                  | _        |j                  | _        || _        y r"   )r5   r4   r  _definition_class)r%   definition_classs     r&   r   zTypedDict.__init__  s3    /??.==)33!1r(   c                 B    t        | | j                  j                        S r"   )r   r  rE   r$   s    r&   rE   zTypedDict.name  s    t~~2233r(   c                     t        t              r8t        j                  fd| j                  j                  d      D              S t        S )Nc              3   j   K   | ]*  }|j                        D ]  }|j                           , y wr"   )getr'   )r   rt   rE   r   s      r&   r   z1TypedDict.py__simple_getitem__.<locals>.<genexpr>  s=      &"JJu-&  

&&s   03Tis_instance)r   r  r   rg   r  get_filtersr   r   s    `r&   r   zTypedDict.py__simple_getitem__  sI    eS!%% &"44@@T@R&  
 r(   c           	          t         j                  j                  d | j                  j	                  d      D              }t        |D ch c]"  }t        | j                  |j                        $ c}      S c c}w )Nc              3   <   K   | ]  }|j                           y wr"   )values)r   fs     r&   r   z+TypedDict.get_key_values.<locals>.<genexpr>  s      9
 HHJ9
s   Tr  )		itertoolschainfrom_iterabler  r  r   r   r5   r3   )r%   filtered_valuesrH   s      r&   get_key_valueszTypedDict.get_key_values  sr    #//77 9
++77D7I9
  $
 !!5!5q}}E
  	 
s   
'A8c                 x    | j                   j                  j                  d      \  }|j                         \  }|S )Ndict)r5   r   r   execute_with_values)r%   dresults      r&   r   zTypedDict._get_wrapped_value  s5    !!11DDVL'')r(   N)
rJ   rK   rL   r  r   r   rE   r   r(  r   rM   r(   r&   r2   r2     s-    @2 4 4r(   r2   )8r  r$  jedir   jedi.inference.compiledr   r   jedi.inference.base_valuer   r   r   r	   r
   jedi.inference.lazy_valuer   jedi.inference.argumentsr   jedi.inference.filtersr   jedi.inference.namesr   r   jedi.inference.value.klassr   jedi.inference.gradual.baser   r   r   jedi.inference.gradual.type_varr   jedi.inference.gradual.genericsr   r   r   r;   r6   r=   r    rO   rR   r>   r   r   r<   r7   r]   rZ   r[   r\   r@   rA   rB   r0   rC   rD   r2   rM   r(   r&   <module>r9     s{     K# # 5 @ 0 7 14 4 8 S;AAC %&$, 	  388:72{ 72t* *<3 <~
 
20
 0"
/1B "
J*,.? *#  #L !  (N! N!b	  		! 	  Hl H Je J,3< 3_ "  "r(   