ó
    Ð]jV?  ã                   ó^  • S r SSKrSSKJr  SSKJrJr  SSKJr  SSK	J
r
Jr  SSKJrJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  S rS$S jrS rS r\" 5       S%S j5       r S r!S r"S r#\" 5       S 5       r$S r%S r&S r'S r(S r)S r*S r+S r,S  r-S! r.S&S" jr/S# r0g)'a  
PEP 0484 ( https://www.python.org/dev/peps/pep-0484/ ) describes type hints
through function annotations. There is a strong suggestion in this document
that only the type of type hinting defined in PEP0484 should be allowed
as annotations in future python versions.
é    N)Ú	Parameter)ÚParserSyntaxErrorÚparse)Úinference_state_method_cache)ÚValueSetÚ	NO_VALUES)ÚDefineGenericBaseClassÚGenericClass)ÚTupleGenericManager)ÚTypeVar)Ú	is_string)Úbuiltin_from_name)Úget_executed_param_names)Údebug)Úparser_utilsc                 óD  • U R                  U5      n[        U5      S:X  a   [        R                  " SU< SU< 35        U$ [        nU HS  n[        U5      (       a1  [        XR                  5       5      nUb  X0R                  U5      -  nMD  U[        U/5      -  nMU     U$ )z�
Inferes an annotation node. This means that it inferes the part of
`int` here:

    foo: int = 3

Also checks for forward references (strings)
r   zInferred typing index z should lead to 1 object, not )	Ú
infer_nodeÚlenr   Úwarningr   r   Ú_get_forward_reference_nodeÚget_safe_valuer   )ÚcontextÚ
annotationÚ	value_setÚstrings_removedÚpartÚresults         Ú^/home/mande/repo/quber/.venv/lib/python3.13/site-packages/jedi/inference/gradual/annotation.pyÚinfer_annotationr      sœ   € ð ×"Ñ" :Ó.€IÜ
ˆ9ƒ~˜ÓÜ�‹ÛJTÒV_Ð`ô	bàÐä€OÛˆÜ�T�?‰?Ü0°×:MÑ:MÓ:OÓPˆFØÑ!Ø×#5Ñ#5°fÓ#=Ñ=�ÙØœ8 T FÓ+Ñ+Šñ ð Ðó    c                 ó    ^• [        X5      nUc  [        $ U R                  U5      nTb$  UR                  U4S j5      R	                  T5      nU$ )Nc                 óz   >• U R                   S:H  =(       a%    [        [        U R                  5       5      5      T:¬  $ )NÚtuple)Ú
array_typer   ÚlistÚ
py__iter__)ÚvalueÚindexs    €r   Ú<lambda>Ú*_infer_annotation_string.<locals>.<lambda>;   s6   ø€ Ø× Ñ  GÑ+÷ ;Üœ˜U×-Ñ-Ó/Ó0Ó1°UÑ:ð;r    )r   r   r   ÚfilterÚpy__simple_getitem__)r   Ústringr(   Únoder   s     `  r   Ú_infer_annotation_stringr/   3   s[   ø€ Ü& wÓ7€DØ�|ÜÐà×"Ñ" 4Ó(€IØÑØ×$Ñ$ôó
÷
 Ñ
˜uÓ
%ð 	ð Ðr    c                 ó@  •  U R                   R                  R                  USSS9nU R                  R	                  5       n[
        R                  " X#R                  S   5        U R                  Ul        U$ ! [         a    [        R                  " SU-  5         g f = f)NÚ
eval_inputF)Ústart_symbolÚerror_recoveryr   zAnnotation not parsed: %s)Úinference_stateÚgrammarr   Ú	tree_nodeÚget_root_noder   ÚmoveÚend_posÚparentr   r   r   )r   r-   Únew_nodeÚmodules       r   r   r   C   s–   € ðØ×*Ñ*×2Ñ2×8Ñ8ØØ%Ø ð 9ð 
ˆð ×"Ñ"×0Ñ0Ó2ˆÜ×Ò˜(§N¡N°1Ñ$5Ô6Ø!×+Ñ+ˆŒØˆøô ó Ü�ŠÐ1°FÑ:Ô;Ùðús   ‚%A7 Á7#BÂBc                 ó¼  •  [        U SS9R                  S   nUR
                  S;   a  UR                  5       R                  5       /$ / n UR                  nU HB  nUR
                  S;   d  M  UR                  UR                  5       R                  5       5        MD     U$ ! [         a    [        R                  " SU -  5        / s $ f = f! [         a    / s $ f = f)z’
Split decl_text on commas, but group generic expressions
together.

For example, given "foo, Bar[baz, biz]" we return
['foo', 'Bar[baz, biz]'].

F)r3   r   z*Comment annotation is not valid Python: %s)ÚnameÚ	atom_exprÚpower)
r   Úchildrenr   r   r   ÚtypeÚget_codeÚstripÚappendÚAttributeError)Ú	decl_textr.   ÚparamsrA   Úchilds        r   Ú _split_comment_param_declarationrJ   T   sÑ   € ðÜ�Y¨uÑ5×>Ñ>¸qÑAˆð
 ‡y�yÐ2Ó2Ø—‘“×%Ñ%Ó'Ð(Ð(à€Fð8Ø—=‘=ˆó ˆEØ�z‰zÐ;Õ;Ø—‘˜eŸn™nÓ.×4Ñ4Ó6Ö7ñ ð €Møô# ó Ü�ŠÐBÀYÑNÔOØŠ	ðûô ó ØŠ	ðús#   ‚B! ÁC Â!%C	ÃC	ÃCÃCc                 ór  • [        X5      nU(       d  U(       d  U$ U R                  nUR                  S:X  a,  [        US5      n[	        [        U[        U45      5      /5      $ UR                  S:X  aC  [        US5      n[	        [        US5      /5      U4n[	        [        U[        U5      5      /5      $ U$ )Né   r#   é   ÚdictÚstr)Ú_infer_paramr4   Ú
star_countr   r   r
   r   )Úfunction_valueÚparamÚignore_starsÚvaluesr4   Útuple_ÚdctÚgenericss           r   Úinfer_paramrY   s   sÇ   € ä˜.Ó0€FÞž6ØˆØ$×4Ñ4€OØ×Ñ˜1ÓÜ" ?°GÓ<ˆÜœØÜ  	Ó*ó
ð ó ð 	ð 
×	Ñ	˜QÓ	Ü °Ó8ˆäÔ'¨¸Ó?Ð@ÓAØð
ˆô œØÜ Ó)ó
ð ó ð 	ð €Mr    c                 óê  • UR                   nUGcD  UR                  R                   Vs/ s H  nUR                  S:X  d  M  UPM     nnUR                  R                  n[        R
                  " U5      nUc  [        $ [        R                  " SU5      nU(       d  [        $ [        UR                  S5      5      nUR                  U5      n	[        U5      [        U5      :w  a  [        R                  " SX„5        U R                  5       (       a  U	S:X  a  [        $ U	S-  n	U	[        U5      :¼  a  [        $ X‰   n
[!        U R#                  5       U
5      $ U R#                  5       n[%        X²5      $ s  snf )zB
Infers the type of a function parameter, using type annotations.
rS   z^#\s*type:\s*\(([^#]*)\)\s*->rL   z&Comments length != Params length %s %sr   )r   r:   rA   rB   r   Úget_following_comment_same_liner   ÚreÚmatchrJ   Úgroupr(   r   r   r   Úis_bound_methodr/   Úget_default_param_contextr   )rR   rS   r   rI   Ú
all_paramsr.   Úcommentr]   Úparams_commentsr(   Úparam_commentr   s               r   rP   rP   Œ   sX  € ð ×!Ñ!€JØÒð */¯©×)>Ò)>ó 0Ò)> ØŸ™ wÑ.÷ Ñ)>ˆ
ð 0ð �|‰|×"Ñ"ˆÜ×>Ò>¸tÓDˆØ‰?ÜÐä—’Ð9¸7ÓCˆÞÜÐÜ:¸5¿;¹;Àq»>ÓJˆð × Ñ  Ó'ˆô ˆÓ¤3 z£?Ó2Ü�MŠMØ8Øôð ×)Ñ)×+Ñ+Ø˜‹zä Ð Ø�Q‰JˆEØ”C˜Ó(Ó(ÜÐà'Ñ.ˆÜ'Ø×4Ñ4Ó6Øó
ð 	
ð
 ×6Ñ6Ó8€GÜ˜GÓ0Ð0ùòK0s   ©E0ÁE0c                 ó¸   • 0 nU R                  5        H,  nUR                  nUc  M  X1UR                  R                  '   M.     U R                  nU(       a  XAS'   U$ )NÚreturn)Ú
get_paramsr   r>   r'   )ÚfuncdefrW   Úfunction_paramÚparam_annotationÚreturn_annotations        r   Úpy__annotations__rl   ½   s]   € Ø
€CØ!×,Ñ,Ö.ˆØ)×4Ñ4ÐØÓ'Ø-=�×#Ñ#×)Ñ)Ó*ñ /ð
  ×*Ñ*ÐÞØ)ˆH‰Ø€Jr    c                 ór   ^ • U 4S jnUR                  5        VVs0 s H  u  p4X2" U5      _M     snn$ s  snnf )Nc                 óÊ   >• U b  U R                   S:w  a  U $ [        TTR                  R                  R	                  U R
                  5      5      n U c  g U R                  S   n U $ )Nr-   r   )rB   r   r4   Úcompiled_subprocessÚsafe_literal_evalr'   rA   )r.   r   s    €r   ÚresolveÚ+resolve_forward_references.<locals>.resolveË   se   ø€ Ø‰<˜4Ÿ9™9¨Ó0ØˆKä*ØØ×#Ñ#×7Ñ7×IÑIØ—
‘
óó
ˆð ‰<àð
 �}‰}˜QÑˆàˆr    )Úitems)r   Úall_annotationsrq   r>   r.   s   `    r   Úresolve_forward_referencesru   Ê   s9   ø€ õð, 3B×2GÑ2GÔ2IÔJÒ2I¡J DˆD�'˜$“-ÒÑ2IÒJÐJùÓJs   ›3c                 ól  ^
• U R                  5       n[        U[        U R                  5      5      nUR	                  SS5      nUc‡  U R                  n[
        R                  " U5      nUc  [        $ [        R                  " SU5      nU(       d  [        $ [        UUR                  S5      R                  5       5      R                  U5      $ [        X$5      n[        X$5      n	U(       d  U	R                  U5      $ [!        XU5      m
["        R$                  " U
4S jU	 5       5      R                  U5      $ )zN
Infers the type of a function's return value,
according to type annotations.
rf   Nz%^#\s*type:\s*\([^#]*\)\s*->\s*([^#]*)rL   c              3   ó”   >#   • U  H=  n[        U[        [        45      (       a  UR                  T5      O[	        U15      v •  M?     g 7f©N©Ú
isinstancer	   r   Údefine_genericsr   )Ú.0ÚannÚtype_var_dicts     €r   Ú	<genexpr>Ú%infer_return_types.<locals>.<genexpr>  sI   øé € ð ò %ˆCô �cÔ2´GÐ<×=Ñ=ð 	×Ñ˜MÔ*ÜCKÈSÈEÃ?ô	Sâ$ùó   ƒAA)r`   ru   rl   r6   Úgetr   r[   r   r\   r]   r/   r^   rD   Úexecute_annotationÚfind_unknown_type_varsr   Úinfer_type_vars_for_executionr   Ú	from_sets)ÚfunctionÚ	argumentsr   rt   r   r.   rb   r]   Úunknown_type_varsÚannotation_valuesr~   s             @r   Úinfer_return_typesr‹   ä   s"  ø€ ð ×0Ñ0Ó2€GÜ0ØÜ˜(×,Ñ,Ó-ó€Oð !×$Ñ$ X¨tÓ4€JØÑð ×!Ñ!ˆÜ×>Ò>¸tÓDˆØ‰?ÜÐä—’ÐAÀ7ÓKˆÞÜÐä'ØØ�K‰K˜‹N× Ñ Ó"ó
÷ Ñ
˜WÓ
%ð	&ô
 /¨wÓCÐÜ(¨Ó=ÐÞØ ×3Ñ3°GÓ<Ð<ä1°(ÀÓW€Mä×Òô ñ %óó ÷ Ñ˜Ó!ð	"r    c                 óâ  • U R                  5       n0 n[        X5      nU Hº  n X&R                     n[	        X75      nU(       d  M&  UR                  U5      n	UR                  5       n
UR                  5       nU
[        R                  L a  UR                  5       nO$U
[        R                  L a  UR                  S5      n[        UU	R                  U5      5        M¼     U$ ! [         a     MÍ  f = f)a1  
Some functions use type vars that are not defined by the class, but rather
only defined in the function. See for example `iter`. In those cases we
want to:

1. Search for undefined type vars.
2. Infer type vars with the execution state we have.
3. Return the union of all type vars that have been found.
Ú_dict_values)r`   r   Ústring_nameÚKeyErrorr„   r   Úget_kindÚinferr   ÚVAR_POSITIONALÚmerge_types_of_iterateÚVAR_KEYWORDÚ	try_mergeÚmerge_type_var_dictsÚinfer_type_vars)r‡   rˆ   Úannotation_dictr   Úannotation_variable_resultsÚexecuted_param_namesÚexecuted_param_nameÚannotation_nodeÚannotation_variablesÚannotation_value_setÚkindÚactual_value_sets               r   r…   r…     sô   € ð ×0Ñ0Ó2€Gà"$ÐÜ3°HÓHÐÛ3Ðð	Ø-×.MÑ.MÑNˆOô  6°gÓOÐßÐà#*×#5Ñ#5°oÓ#FÐ Ø&×/Ñ/Ó1ˆDØ2×8Ñ8Ó:ÐØ”y×/Ñ/Ò/Ø#3×#JÑ#JÓ#LÑ Øœ×.Ñ.Ò.à#3×#=Ñ#=¸nÓ#MÐ Ü Ø+Ø$×4Ñ4Ð5EÓFöñ#  4ð* 'Ð&øô% ó 	Úð	ús   ¤C Ã 
C.Ã-C.c                 ó  ^• 0 mU H?  nUR                   S:X  d  M  [        XR                  5       5      nTR                  U5        MA     [        R
                  " U4S jU 5       5      R                  U R                  5      $ )Nr%   c              3   ó”   >#   • U  H=  n[        U[        [        45      (       a  UR                  T5      O[	        U15      v •  M?     g 7frx   ry   )r|   ÚvÚall_type_varss     €r   r   Ú,infer_return_for_callable.<locals>.<genexpr><  sJ   øé € ð ò ˆAô �aÔ0´'Ð:×;Ñ;ð 	
×Ñ˜-Ô(ä�q�c‹]ô	ò ùr�   )r$   Ú_infer_type_vars_for_callabler&   Úupdater   r†   rƒ   r   )rˆ   Úparam_valuesÚresult_valuesÚpvr~   r¤   s        @r   Úinfer_return_for_callabler«   5  ss   ø€ Ø€MÛˆØ�=‰=˜FÕ"Ü9¸)Ç]Á]Ã_ÓUˆMØ× Ñ  Ö/ñ ô
 ×Òô ñ ó	ó ÷
 Ñ˜×*Ñ*Ó+ð,r    c                 óÌ   • 0 n[        U R                  5       U5       HC  u  u  p4nUR                  5       nUR                  5       n[        UUR	                  U5      5        ME     U$ )zb
Infers type vars for the Calllable class:

    def x() -> Callable[[Callable[..., _T]], _T]: ...
)ÚzipÚunpackr‘   r–   r—   )rˆ   Úlazy_paramsr™   Ú_Ú
lazy_valueÚlazy_callable_paramÚcallable_param_valuesr    s           r   r¦   r¦   D  sm   € ð #%ÐÜ03°I×4DÑ4DÓ4FÈÖ0TÑ,‰ˆÐ,Ø 3× 9Ñ 9Ó ;Ðà%×+Ñ+Ó-ÐÜØ'Ø!×1Ñ1Ð2BÓCö	
ñ	 1Uð 'Ð&r    c                 óŒ   • UR                  5        H  u  p#U(       d  M   X==   U-  ss'   M     g ! [         a    X0U'    M1  f = frx   )rs   r�   )Ú	base_dictÚnew_dictÚtype_var_namerU   s       r   r–   r–   V  sG   € Ø!)§¡Ö!1Ñˆßˆ6ð2ØÓ(¨FÑ2Õ(ò "2øô ó 2Ø+1˜-Ô(ð2ús    1±AÁAc           	      óô   • 0 n[        U[        5      (       d  U$ U R                  5       nUR                  5       n[        X45       H/  u  pV[	        UUR                  UR                  S5      5      5        M1     U$ )a  
Match up the generic parameters from the given argument class to the
target annotation.

This walks the generic parameters immediately within the annotation and
argument's type, in order to determine the concrete values of the
annotation's parameters for the current case.

For example, given the following code:

    def values(mapping: Mapping[K, V]) -> List[V]: ...

    for val in values({1: 'a'}):
        val

Then this function should be given representations of `Mapping[K, V]`
and `Mapping[int, str]`, so that it can determine that `K` is `int and
`V` is `str`.

Note that it is responsibility of the caller to traverse the MRO of the
argument type as needed in order to find the type matching the
annotation (in this case finding `Mapping[int, str]` as a parent of
`Dict[int, str]`).

Parameters
----------

`annotation_value`: represents the annotation to infer the concrete
    parameter types of.

`annotated_argument_class`: represents the annotated class of the
    argument being passed to the object annotated by `annotation_value`.
N)rz   r	   Úget_genericsr­   r–   r—   rƒ   )Úannotation_valueÚannotated_argument_classr~   Úannotation_genericsÚactual_genericsÚannotation_generics_setÚactual_generic_sets          r   Úmerge_pairwise_genericsrÀ   _  s   € ðF €MäÐ.Ô0F×GÑGØÐà*×7Ñ7Ó9ÐØ.×;Ñ;Ó=€Oä7:Ð;NÖ7`Ñ3ÐÜØØ#×3Ñ3Ð4F×4YÑ4YÐZ^Ó4_Ó`ö	
ñ 8að Ðr    c                 ó6   • [        XUR                  S   U5      $ )NrL   ©Ú_find_type_from_comment_hintrA   ©r   r.   r>   s      r   Úfind_type_from_comment_hint_forrÅ   “  ó   € Ü'¨°t·}±}ÀQÑ7GÈÓNÐNr    c                 óâ   • [        UR                  5      S:”  a  / $ [        UR                  S   R                  5      S:X  d   S5       eUR                  S   R                  S   n[        XX25      $ )Né   rL   é   z1Can only be here when children[1] is 'foo() as f'rM   )r   rA   rÃ   )r   r.   r>   Úvarlists       r   Ú find_type_from_comment_hint_withrË   —  sl   € Ü
ˆ4�=‰=Ó˜AÓð ˆ	Üˆt�}‰}˜QÑ×(Ñ(Ó)¨QÓ.ð <Ø;ó<Ð.à�m‰m˜AÑ×'Ñ'¨Ñ*€GÜ'¨°wÓEÐEr    c                 ó6   • [        XUR                  S   U5      $ )Nr   rÂ   rÄ   s      r   Ú"find_type_from_comment_hint_assignrÍ   ¢  rÆ   r    c                 ón  • S nUR                   S;   a5  SnUR                   H!  nXS:X  a    OUR                   S:X  a  M  US-  nM#     / $ [        R                  " U5      nUc  / $ [        R
                  " SU5      nUc  / $ [        XR                  S5      R                  5       U5      R                  U 5      $ )N)Útestlist_star_exprÚexprlistÚtestlistr   ÚoperatorrL   z^#\s*type:\s*([^#]*))
rB   rA   r   r[   r\   r]   r/   r^   rD   rƒ   )r   r.   rÊ   r>   r(   rI   rb   r]   s           r   rÃ   rÃ   ¦  s³   € Ø€EØ‡|�|ÐEÓEàˆØ×%Ô%ˆEØ‹}ÙØ�z‰z˜ZÓ'ÙØ�Q‰JŠEñ &ð ˆIä×:Ò:¸4Ó@€GØ�Øˆ	Ü�HŠHÐ,¨gÓ6€EØ�}Øˆ	Ü#Ø—‘˜Q“×%Ñ%Ó'¨óçÑ˜Ó!ð"r    c                 ó0   ^ ^^• UU U4S jm/ mT" U5        T$ )Nc                 ó  >• U R                   S;   a\  U R                  S   nUR                   S:X  a<  UR                  S   S:X  a(  [        UR                  S   5       H  nT" U5        M     g g g [        TR	                  U 5      T5      TS S & g )N)r?   r@   éÿÿÿÿÚtrailerr   Ú[rL   )rB   rA   Ú_unpack_subscriptlistÚ_filter_type_varsr   )r.   rÖ   Úsubscript_nodeÚ
check_noder   Úfounds      €€€r   rÛ   Ú*find_unknown_type_vars.<locals>.check_nodeÀ  s…   ø€ Ø�9‰9Ð.Ó.Ø—m‘m BÑ'ˆGØ�|‰|˜yÓ(¨W×-=Ñ-=¸aÑ-@ÀCÓ-GÜ&;¸G×<LÑ<LÈQÑ<OÖ&P�NÙ˜~Ö.ò 'Qð .HÐ(ô )¨×);Ñ);¸DÓ)AÀ5ÓIˆE‘!‰Hr    © )r   r.   rÛ   rÜ   s   ` @@r   r„   r„   ¿  s   ú€ ÷Jð €EÙˆtÔØ€Lr    c                 óŒ   • [        U5      nU  H2  n[        U[        5      (       d  M  X1;  d  M!  UR                  U5        M4     U$ rx   )r%   rz   r   rE   )r   rÜ   Ú	new_foundÚtype_vars       r   rÙ   rÙ   Î  s=   € Ü�U“€IÛˆÜ�h¤×(Ó(¨XÕ-BØ×Ñ˜XÖ&ñ ð Ðr    c              #   ó¶   #   • U R                   S:X  a0  U R                  S S S2    H  nUR                   S:w  d  M  Uv •  M     g U R                   S:w  a  U v •  g g 7f)NÚsubscriptlistrM   Ú	subscript)rB   rA   )rã   rä   s     r   rØ   rØ   Ö  sX   é € Ø×Ñ˜_Ó,Ø&×/Ñ/±°!°Ô4ˆIØ�~‰~ Õ,Ø”ò 5ð ×Ñ Ó,ØÓð -ùs
   ‚4AºArx   )F)rÞ   )1Ú__doc__r\   Úinspectr   Úparsor   r   Újedi.inference.cacher   Újedi.inference.base_valuer   r   Újedi.inference.gradual.baser	   r
   Újedi.inference.gradual.genericsr   Újedi.inference.gradual.type_varr   Újedi.inference.helpersr   Újedi.inference.compiledr   Újedi.inference.paramr   Újedir   r   r   r/   r   rJ   rY   rP   rl   ru   r‹   r…   r«   r¦   r–   rÀ   rÅ   rË   rÍ   rÃ   r„   rÙ   rØ   rÞ   r    r   Ú<module>rñ      sÈ   ðñó 
Ý ç *å =ß 9ß LÝ ?Ý 3Ý ,Ý 5Ý 9Ý Ý òô4ò ò"ñ> Óóó  ðò0.1òb
òKñ4 Óñ'"ó  ð'"òT#'òL,ò'ò$2ò1òhOòFòOò"ò2ôó r    