ó
    Ð]jt&  ã                   óx  • S r SSKrSSKrSSKJrJr  SSKJr  SSKJ	r	  SSK
JrJrJr  SSKJr  / SQr\R"                  " S	\R$                  5      \R"                  " S
\R$                  5      /r\R"                  " S5      rSqS rS rS rS rS rS rS rS rS r\	" 5       S 5       r\	" 5       \S 5       5       r g)a©  
Docstrings are another source of information for functions and classes.
:mod:`jedi.inference.dynamic_params` tries to find all executions of functions,
while the docstring parsing is much easier. There are three different types of
docstrings that |jedi| understands:

- `Sphinx <http://sphinx-doc.org/markup/desc.html#info-field-lists>`_
- `Epydoc <http://epydoc.sourceforge.net/manual-fields.html>`_
- `Numpydoc <https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt>`_

For example, the sphinx annotation ``:type foo: str`` clearly states that the
type of ``foo`` is ``str``.

As an addition to parameter searching, this module also provides return
annotations.
é    N)ÚparseÚParserSyntaxError)Údebug)Úinference_state_method_cache)Úiterator_to_value_setÚValueSetÚ	NO_VALUES)ÚLazyKnownValues)z\s*:type\s+%s:\s*([^\n]+)z\s*:param\s+(\w+)\s+%s:[^\n]*z\s*@type\s+%s:\s*([^\n]+)z\s*:rtype:\s*([^\n]+)z\s*@rtype:\s*([^\n]+)z:[^`]+:`([^`]+)`c                  óh   • [        [        [        [        45      (       a  [        eSSKJn   U q[        $ )Nr   ©ÚNumpyDocString)Ú
isinstanceÚ_numpy_doc_string_cacheÚImportErrorÚSyntaxErrorÚnumpydoc.docscraper   r   s    ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/jedi/inference/docstrings.pyÚ_get_numpy_doc_string_clsr   /   s*   € äÔ)¬K¼Ð+E×FÑFÜ%Ð%Ý1Ø,ÐÜ"Ð"ó    c                 ó°  • [         R                  " 5          [         R                  " S5         [        5       " U 5      R                  S   n SSS5        W HP  u  p4nX1:X  d  M  [        R                  " SU5      nU(       a  UR                  S5      n[        [        U5      5      s  $    / $ ! [
         a    / s sSSS5        $ f = f! , (       d  f       N�= f)zASearch `docstr` (in numpydoc format) for type(-s) of `param_str`.ÚignoreÚ
ParametersNz"([^,]+(,[^,]+)*?)(,[ ]*optional)?$é   )ÚwarningsÚcatch_warningsÚsimplefilterr   Ú_parsed_dataÚ	ExceptionÚreÚmatchÚgroupÚlistÚ_expand_typestr)ÚdocstrÚ	param_strÚparamsÚp_nameÚp_typeÚp_descrÚms          r   Ú_search_param_in_numpydocstrr+   8   s¶   € ä	×	 Ò	 Õ	"Ü×Ò˜hÔ'ð	ô /Ô0°Ó8×EÑEÀlÑS‰F÷ 
#ó $*Ñˆ˜ØÕÜ—’Ð>ÀÓGˆAÞØŸ™ ›�Üœ¨Ó/Ó0Ò0ñ $*ð €Iøô ó 	Ø‰I÷ 
#Ñ	"ð	ú÷ 
#Õ	"ús(   –C®B,Â,CÂ8CÃCÃCÃ
Cc              #   ó   #   • [         R                  " 5          [         R                  " S5         [        5       " U 5      n SSS5         WR
                  S   nX!R
                  S   -  nU H"  u  p4nU(       d  Un[        U5       Sh  v•N   M$     g! [         a     SSS5        gf = f! , (       d  f       Np= f! [         a     gf = f NB7f)zH
Search `docstr` (in numpydoc format) for type(-s) of function returns.
r   NÚReturnsÚYields)r   r   r   r   r   r   r#   )r$   ÚdocÚreturnsÚr_nameÚr_typeÚr_descrs         r   Ú_search_return_in_numpydocstrr4   K   sÆ   é € ô 
×	 Ò	 Õ	"Ü×Ò˜hÔ'ð	Ü+Ô-¨fÓ5‰C÷ 
#ðð ×"Ñ" 9Ñ-ˆØ×#Ñ# HÑ-Ñ-ˆó $+Ñˆ˜æØˆFÜ" 6Ó*×*Ò*ò	 $+øô ó 	Ø÷ 
#Ð	"ð	ú÷	 
#Õ	"ûô ó Ùðúñ 	+ùso   ‚C˜B+°BÁCÁ
 B< Á*CÂ	CÂ
	CÂ
B(ÂB+Â	CÂ'B(Â(B+Â+
B9Â5CÂ<
C	ÃCÃC	Ã	Cc              #   ó¸  #   • [         R                  " SU 5      (       a=  U R                  S5       H'  nUR                  S5      S   R                  5       v •  M)     g[         R                  " SU 5      (       a  U R                  S5      S   v •  gU R	                  S5      (       a°  [        U SS9R                  S   nUR                  S	:X  aˆ  [        UR                  S
   S/ 5       Hi  nUR                  S:X  a  SUR                  ;   a  Sv •  M)  Sv •  M/  UR                  S:X  d  MA  SUR                  R                  5       ;   a  Sv •  Me  Sv •  Mk     ggU v •  g7f)z8
Attempts to interpret the possible types in `type_str`
z\bor\bÚorÚofr   z\bof\bÚ{z3.13)ÚversionÚatomr   ÚchildrenÚnumberÚ.ÚfloatÚintÚstringÚbÚbytesÚstrN)r   ÚsearchÚsplitÚstripÚ
startswithr   r;   ÚtypeÚgetattrÚvalueÚstring_prefixÚlower)Útype_strÚtÚnodeÚleafs       r   r#   r#   c   s  é € ô
 
‡y‚y�˜H×%Ñ%Ø—‘ Ö%ˆAØ—'‘'˜$“- Ñ"×(Ñ(Ó*Ô*ò &ô 
�Š�9˜h×	'Ñ	'Ø�n‰n˜TÓ" 1Ñ%Ó%à	×	Ñ	˜S×	!Ñ	!Ü�X vÑ.×7Ñ7¸Ñ:ˆØ�9‰9˜ÓÜ §¡¨aÑ 0°*¸bÖA�Ø—9‘9 Ó(Ø˜dŸj™jÓ(Ø%œà#œØ—Y‘Y (Õ*Ø˜d×0Ñ0×6Ñ6Ó8Ó8Ø%œà#œò Bð ð  ‹ùs   ‚D!EÄ'3Ec           	      ó   • [          Vs/ s H0  n[        R                  " U[        R                  " U5      -  5      PM2     nnU H8  nUR	                  U 5      nU(       d  M  [        UR                  S5      5      /s  $    [        X5      $ s  snf )a°  
Search `docstr` for type(-s) of `param_str`.

>>> _search_param_in_docstr(':type param: int', 'param')
['int']
>>> _search_param_in_docstr('@type param: int', 'param')
['int']
>>> _search_param_in_docstr(
...   ':type param: :class:`threading.Thread`', 'param')
['threading.Thread']
>>> bool(_search_param_in_docstr('no document', 'param'))
False
>>> _search_param_in_docstr(':param int param: some description', 'param')
['int']

r   )ÚDOCSTRING_PARAM_PATTERNSr   ÚcompileÚescaperD   Ú_strip_rst_roler!   r+   )r$   r%   ÚpÚpatternsÚpatternr    s         r   Ú_search_param_in_docstrrY   „   s€   € õ& 2ó3Ú1�Aô —
’
˜1œrŸyšy¨Ó3Ñ3Ö4Ù1ð ð 3ãˆØ—‘˜vÓ&ˆßˆ5Ü# E§K¡K°£NÓ3Ð4Ò4ñ ô
 (¨Ó:Ð:ùò3s   ‰7Bc                 ó`   • [         R                  U 5      nU(       a  UR                  S5      $ U $ )ax  
Strip off the part looks like a ReST role in `type_str`.

>>> _strip_rst_role(':class:`ClassName`')  # strip off :class:
'ClassName'
>>> _strip_rst_role(':py:obj:`module.Object`')  # works with domain
'module.Object'
>>> _strip_rst_role('ClassName')  # do nothing when not ReST role
'ClassName'

See also:
http://sphinx-doc.org/domains.html#cross-referencing-python-objects

r   )ÚREST_ROLE_PATTERNr    r!   )rM   r    s     r   rU   rU       s*   € ô ×#Ñ# HÓ-€EÞØ�{‰{˜1‹~Ðàˆr   c                 ó  • Uc  / $ [         R                  " SU5      nSR                  S U 5       5      nU SU 3n[        R                  " SUSS9  U R
                  R                  n UR                  USS9n UR                  S	   nUR                  S
;  a  / $ SSKJn  U" U U R
                  U/ S9n[        [!        UR#                  5       U5      5      $ ! [         a    / s $ f = f! [        [        4 a    / s $ f = f)Nz((?:\w+\.)*\w+)\.Ú
c              3   ó,   #   • U  H
  nS U 3v •  M     g7f)zimport N© )Ú.0rV   s     r   Ú	<genexpr>Ú._infer_for_statement_string.<locals>.<genexpr>½   s   é € ÐAÒ/@¨!˜' ! �Ò/@ùs   ‚zParse docstring code %sÚBLUE©ÚcolorF)Úerror_recoveryéþÿÿÿ)Únamer:   Ú	atom_exprr   )ÚDocstringModule)Úin_module_contextÚinference_stateÚmodule_nodeÚ
code_lines)r   ÚfindallÚjoinr   Údbgrl   Úgrammarr   r   r;   ÚAttributeErrorÚ
IndexErrorrH   Újedi.inference.docstring_utilsrj   r"   Ú_execute_types_in_stmtÚ
as_context)	Úmodule_contextr@   Úpotential_importsÚimportsrr   ÚmoduleÚstmtrj   r*   s	            r   Ú_infer_for_statement_stringr}   ¶   s  € Ø�~Øˆ	äŸ
š
Ð#7¸Ó@Ðð �i‰iÑAÑ/@ÓAÓA€GØˆy˜˜6˜(Ð#€Fä	‡I‚IÐ'¨°vÒ>Ø×,Ñ,×4Ñ4€GðØ—‘˜v°e�Ð<ˆðà�‰˜rÑ"ˆð ‡y�yÐ5Ó5Øˆ	õ ?ÙØ(Ø&×6Ñ6ØØñ		€Aô Ô& q§|¡|£~°tÓ<Ó=Ð=øô) ó ØŠ	ðûô
 œJÐ'ó ØŠ	ðús$   Á)C Á:C) ÃC&Ã%C&Ã)C>Ã=C>c                 óf   ^ • T R                  U5      n[        R                  " U 4S jU 5       5      $ )zÂ
Executing all types or general elements that we find in a statement. This
doesn't include tuple, list and dict literals, because the stuff they
contain is executed. (Used as type information).
c              3   óP   >#   • U  H  n[        TR                  U5      v •  M     g 7f©N)Ú_execute_array_valuesrl   )r`   Údrx   s     €r   ra   Ú)_execute_types_in_stmt.<locals>.<genexpr>â   s(   øé € ð âˆAô 	˜n×<Ñ<¸a×@Ð@Úùó   ƒ#&)Ú
infer_noder   Ú	from_sets)rx   r|   Údefinitionss   `  r   rv   rv   Û   s5   ø€ ð !×+Ñ+¨DÓ1€KÜ×Òô áóó ð r   c                 óx  ^ • SSK JnJnJn  [	        X5      (       a�  UR
                  S;   a  / nUR                  5        HK  n[        R                  " U 4S jUR                  5        5       5      nUR                  [        U5      5        MM     UR
                  S:X  a  UOUnU" T U5      1$ UR                  S5      $ )z‹
Tuples indicate that there's not just one return value, but the listed
ones.  `(str, int)` means that it returns a tuple with both types.
r   )ÚSequenceLiteralValueÚ	FakeTupleÚFakeList)Útupler"   c              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7fr€   )r�   )r`   Útyprl   s     €r   ra   Ú(_execute_array_values.<locals>.<genexpr>ñ   s"   øé € ð )â-�Cô & o°s×;Ð;Ú-ùs   ƒrŒ   N)Újedi.inference.value.iterabler‰   rŠ   r‹   r   Ú
array_typeÚ
py__iter__r   r†   ÚinferÚappendr
   Úexecute_annotation)	rl   Úarrayr‰   rŠ   r‹   ÚvaluesÚ
lazy_valueÚobjectsÚclss	   `        r   r�   r�   è   s­   ø€ ÷
 XÑWÜ�%×.Ñ.°5×3CÑ3CÐGXÓ3XØˆØ×*Ñ*Ö,ˆJÜ×(Ò(ô )à%×+Ñ+Ô-ó)ó ˆGð �M‰Mœ/¨'Ó2Ö3ñ -ð !×+Ñ+¨wÓ6‰i¸HˆÙ�O VÓ,Ð-Ð-à×'Ñ'¨Ó-Ð-r   c                 ór  ^^• UU4S jnU R                  5       mTR                  5       nUR                  S:X  a  [        $ U" U R	                  5       5      nU R                  5       (       a6  U R                  5       S:X  a"  XB" U R                  R	                  5       5      -  n[        R                  " SUSS9  U$ )Nc                 ój   >• [        U4S j[        U TR                  R                  5       5       5      $ )Nc              3   óP   >#   • U  H  n[        TU5        H  nUv •  M	     M     g 7fr€   )r}   )r`   r%   rV   rx   s      €r   ra   Ú7infer_param.<locals>.infer_docstring.<locals>.<genexpr>ÿ   s,   øé € ð 
âQ�	Ü0°À×K�õ áKñ ÚQùr„   )r   rY   rh   rJ   )Ú	docstringrx   Úparams    €€r   Úinfer_docstringÚ$infer_param.<locals>.infer_docstringþ   s.   ø€ Üô 
ä4°YÀÇ
Á
×@PÑ@PÔQó
ó 
ð 	
r   ÚlambdefÚ__init__z#Found param types for docstring: %src   rd   )
Úget_root_contextÚget_parent_functionrH   r	   Ú	py__doc__Úis_bound_methodÚ
py__name__Úclass_contextr   rq   )Úfunction_valuer    r¡   ÚfuncÚtypesrx   s    `   @r   Úinfer_paramr®   ü   sŸ   ù€ ö
ð $×4Ñ4Ó6€NØ×$Ñ$Ó&€DØ‡y�y�IÓÜÐá˜N×4Ñ4Ó6Ó7€EØ×%Ñ%×'Ñ'Ø×)Ñ)Ó+¨zÓ9Ø� ×!=Ñ!=×!GÑ!GÓ!IÓJÑJˆä	‡I‚IÐ3°UÀ&ÒIØ€Lr   c              #   ó”   #   • S nU" U R                  5       5       H%  n[        U R                  5       U5       S h  v•N   M'     g  N	7f)Nc              3   ó¼   #   • [          H9  nUR                  U 5      nU(       d  M  [        UR                  S5      5      v •  M;     [	        U 5       S h  v•N   g  N7f)Nr   )ÚDOCSTRING_RETURN_PATTERNSrD   rU   r!   r4   )ÚcoderV   r    s      r   Úsearch_return_in_docstrÚ3infer_return_types.<locals>.search_return_in_docstr  sD   é € ß*ˆAØ—H‘H˜T“NˆEßˆuÜ% e§k¡k°!£nÓ5Ô5ñ +ô
 1°Ó6×6Ó6ùs   ‚ A¦.AÁAÁA)r§   r}   r¥   )r«   r³   rM   s      r   Úinfer_return_typesrµ     sB   é € ò7ñ ,¨N×,DÑ,DÓ,FÖGˆÜ.¨~×/NÑ/NÓ/PÐRZÓ[×[Ò[ò HÙ[ùs   ‚:A¼A½
A)!Ú__doc__r   r   Úparsor   r   Újedir   Újedi.inference.cacher   Újedi.inference.base_valuer   r   r	   Újedi.inference.lazy_valuer
   rR   rS   ÚMr±   r[   r   r   r+   r4   r#   rY   rU   r}   rv   r�   r®   rµ   r_   r   r   Ú<module>r½      sá   ðñó" 
Û ç *å Ý =÷ñ å 5òÐ ð ‡J‚JÐ'¨¯©Ó.Ø‡J‚JÐ'¨¯©Ó.ðÐ ð
 —J’JÐ2Ó3Ð ð Ð ò#òò&+ò0òB;ò8ò,">òJ
ò.ñ( Óñó  ðñ* ÓØñ
\ó ó  ñ
\r   