+
    e`&                     z   R t ^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHt . ROt]P"                  ! R]P$                  4      ]P"                  ! R]P$                  4      .t]P"                  ! R	4      tRsR
 tR tR tR tR tR tR tR tR t]	! 4       R 4       t]	! 4       ]R 4       4       t R# )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)LazyKnownValuesz\s*:rtype:\s*([^\n]+)z\s*@rtype:\s*([^\n]+)z:[^`]+:`([^`]+)`c                  j    \        \        \        \        34      '       d   \        h^ RIHp  V s\        # )    NumpyDocString)
isinstance_numpy_doc_string_cacheImportErrorSyntaxErrornumpydoc.docscraper   r   s    ;/usr/lib/python3/dist-packages/jedi/inference/docstrings.py_get_numpy_doc_string_clsr   /   s*    )K+EFF%%1,""    c                   \         P                  ! 4       ;_uu_ 4        \         P                  ! R4        \        4       ! V 4      P                  R,          p RRR4       X FR  w  r4pY18X  g   K  \        P                  ! RT4      pT'       d   TP                  ^4      p\        \        T4      4      u # 	  . #   \
         d    . u uuRRR4       # i ; i  + '       g   i     L; i)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ElSF 
# $*>GA/00 $* I  	I 
#	"	 
#	"s(   C!B::CCCCC'	c              #    "   \         P                  ! 4       ;_uu_ 4        \         P                  ! R4        \        4       ! V 4      p RRR4        XP
                  R,          pY!P
                  R,          ,          pT F#  w  r4pT'       g   Tp\        T4       Rj  xL
  K%  	  R#   \         d     RRR4       R# i ; i  + '       g   i     L; i  \         d     R# i ; i LI5i)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_numpydocstrr3   K   s      
	 	 	"	"h'	+-f5C 
# ""9-##H-- $+F"6***	 $+  	 
#	"		 
#	"   	+so   C*CB)	C*,C > C*C(
C*)C 4C5
C*?C  CC	C*C%!C*$C%%C*c              #    "   \         P                  ! RV 4      '       dC   V P                  R4       F+  pVP                  R4      ^ ,          P                  4       x  K-  	  R# \         P                  ! RV 4      '       d   V P                  R4      ^ ,          x  R# V P	                  R4      '       d   \        V RR7      P                  ^ ,          pVP                  R8X  d   \        VP                  ^,          R	. 4       Fm  pVP                  R
8X  d   RVP                  9   d   Rx  K+  Rx  K1  VP                  R8X  g   KD  RVP                  P                  4       9   d   Rx  Ki  Rx  Ko  	  R# R# V x  R# 5i)z8
Attempts to interpret the possible types in `type_str`
z\bor\borofz\bof\b{z3.7)versionatom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    
 
yyH%%%A''$-"((** & 
9h	'	'nnT"1%%			S	!	!Xu-66q999a 0*bA99(djj(%#YY(*d006688%# B   s   A<E:?2E:2BE:7E:c           	     (   \          Uu. uF4  p\        P                  ! V\        P                  ! V4      ,          4      NK6  	  ppV F9  pVP	                  V 4      pV'       g   K  \        VP                  ^4      4      .u # 	  \        W4      # u upi )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']

)DOCSTRING_PARAM_PATTERNSr   compileescaperC   _strip_rst_roler    r*   )r#   r$   ppatternspatternr   s   &&    r   _search_param_in_docstrrX      s    & 231A 

1ryy3341  3v&5#EKKN344 
 (::3s   :Bc                b    \         P                  V 4      pV'       d   VP                  ^4      # V # )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

)REST_ROLE_PATTERNr   r    )rL   r   s   & r   rT   rT      s*     ##H-E{{1~r   c                 $   Vf   . # \         P                  ! RV4      pRP                  R V 4       4      pV RV 2p\        P                  ! RVRR7       V P
                  P                  p VP                  VRR7      p TP                  R,          pTP                  R9  d   . # ^ R	IHp T! T T P
                  T. R
7      p\        \!        TP#                  4       T4      4      #   \         d    . u # i ; i  \        \        3 d    . u # i ; i)Nz((?:\w+\.)*\w+)\.
c              3   ,   "   T F
  pR V 2x  K  	  R# 5i)zimport N ).0rU   s   & r   	<genexpr>._infer_for_statement_string.<locals>.<genexpr>   s     A/@!'!/@s   zParse docstring code %sBLUEcolorF)error_recovery)DocstringModule)in_module_contextinference_statemodule_node
code_lines)namer9   	atom_expr)r   findalljoinr   dbgrh   grammarr   r   r:   AttributeError
IndexErrorrG   jedi.inference.docstring_utilsrf   r!   _execute_types_in_stmt
as_context)	module_contextr?   potential_importsimportsrq   modulestmtrf   r)   s	   &&       r   _infer_for_statement_stringr|      s   ~	

#7@ iiA/@AAGy6(#F	II'v>,,44Gve<r" yy55	 ?(&66		A &q||~t<==)  	
 J' 	s$   -C& C9 &C65C69DDc                f   a  S P                  V4      p\        P                  ! V 3R lV 4       4      # )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   <"   T F  p\        SP                  V4      x  K  	  R # 5iN)_execute_array_valuesrh   )r_   drw   s   & r   r`   )_execute_types_in_stmt.<locals>.<genexpr>   s(      A 	n<<a@@s   #&)
infer_noder   	from_sets)rw   r{   definitionss   f& r   ru   ru      s5     !++D1K   r   c                |  a  ^ RI HpHpHp \	        W4      '       d   VP
                  R9   d   . pVP                  4        FK  p\        P                  ! V 3R lVP                  4        4       4      pVP                  \        V4      4       KM  	  VP
                  R8X  d   TMTpV! S V4      0# VP                  4       # )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.
)SequenceLiteralValue	FakeTupleFakeListtuplec              3   <   <"   T F  p\        SV4      x  K  	  R # 5ir   )r   )r_   typrh   s   & r   r`   (_execute_array_values.<locals>.<genexpr>   s"      )-C &os;;-s   )r   r!   )jedi.inference.value.iterabler   r   r   r   
array_type
py__iter__r   r   inferappendr	   execute_annotation)	rh   arrayr   r   r   values
lazy_valueobjectsclss	   f&       r   r   r      s    
 XW%..53C3CGX3X**,J(( )%++-) G MM/'23 - !++w6iHOV,--''))r   c                   aa VV3R  lpV P                  4       oSP                  4       pVP                  R8X  d   \        # V! V P	                  4       4      pV P                  4       '       d<   V P                  4       R8X  d'   WB! V P                  P	                  4       4      ,          p\        P                  ! RVRR7       V# )c                 j   < \        V3R  l\        V SP                  P                  4       4       4      # )c              3   N   <"   T F  p\        SV4       F  pVx  K	  	  K  	  R # 5ir   )r|   )r_   r$   rU   rw   s   &  r   r`   7infer_param.<locals>.infer_docstring.<locals>.<genexpr>   s,      
Q	0K K Qs   "%)r   rX   rl   rI   )	docstringrw   params   &r   infer_docstring$infer_param.<locals>.infer_docstring   s.     
4Y

@P@PQ
 
 	
r   lambdef__init__z#Found param types for docstring: %srb   rc   )
get_root_contextget_parent_functionrG   r   	py__doc__is_bound_method
py__name__class_contextr   rp   )function_valuer   r   functypesrw   s   &f   @r   infer_paramr      s    
 $446N$$&DyyIN4467E%%''))+z9!=!=!G!G!IJJ	II3U&ILr   c              #      "   R  pV! V P                  4       4       F%  p\        V P                  4       V4       Rj  xL
  K'  	  R#  L
5i)c              3      "   \          F:  pVP                  V 4      pV'       g   K  \        VP                  ^4      4      x  K<  	  \	        V 4       Rj  xL
  R#  L5i)   N)DOCSTRING_RETURN_PATTERNSrC   rT   r    r3   )coderU   r   s   &  r   search_return_in_docstr3infer_return_types.<locals>.search_return_in_docstr  sD     *AHHTNEu%ekk!n55 +
 1666s    A.AAAN)r   r|   r   )r   r   rL   s   &  r   infer_return_typesr     sB     7 ,N,D,D,FG.~/N/N/PRZ[[[ H[s   :A	AA	)z\s*:type\s+%s:\s*([^\n]+)z\s*:param\s+(\w+)\s+%s:[^\n]*z\s*@type\s+%s:\s*([^\n]+))!__doc__r   r   parsor   r   jedir   jedi.inference.cacher   jedi.inference.base_valuer   r   r   jedi.inference.lazy_valuer	   rQ   rR   Mr   rZ   r   r   r*   r3   r"   rX   rT   r|   ru   r   r   r   r^   r   r   <module>r      s   " 
  *  =  5  JJ'.JJ'. 
 JJ23   #&+0B;8,">J
*(   * 
\   
\r   