
    e9t                    R   d Z ddlmZ ddlZddlZddlmZ ddlZddlmZ ddl	m
Z
 ddlm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+dZ G d d      Z G d de      Z G d de      Z G d de      Z G d de      ZeeeeedZy),z'Utility methods for docstring checking.    )annotationsN)Iterable)nodes)UninferableBase)utilsc                N    t        |       t        | j                  d            z
  S )zThe number of leading spaces in a string.

    :param str s: input string

    :rtype: int
    :return: number of leading spaces
     )lenlstrip)ss    E/usr/lib/python3/dist-packages/pylint/extensions/_check_docs_utils.pyspace_indentationr      s      q6C&&&    c                (   | j                   r| j                   j                  ng }|D ]i  }t        |t        j                        s|j                  dk(  s.t        |j
                  t        j                        sS|j
                  j                  c S  y)a  Get the name of the property that the given node is a setter for.

    :param node: The node to get the property name for.
    :type node: str

    :rtype: str or None
    :returns: The name of the property that the node is a setter for,
        or None if one could not be found.
    setterN)
decoratorsr   
isinstance	AttributeattrnameexprNamename)noder   	decorators      r   get_setters_property_namer      sm     +///&&rJ '	y%//2""h.9>>5::6>>&&&' r   c                    d}t        |       }t        j                  |       }|r>|r<|j                  | j                        }|D ]  }t        j
                  |      s|} |S  |S )a'  Get the property node for the given setter node.

    :param node: The node to get the property for.
    :type node: nodes.FunctionDef

    :rtype: nodes.FunctionDef or None
    :returns: The node relating to the property of the given setter node,
        or None if one could not be found.
    N)r   r   node_frame_classgetattrr   decorated_with_property)r   	property_property_name
class_nodeclass_attrsattrs         r   get_setters_propertyr%   4   so     I-d3M''-J/9/A/A$))/L 	D,,T2 		
 r   c                v    | j                   }|yt        |t        j                        xr |j                   du  S )a  Check if a return node returns a value other than None.

    :param return_node: The return node to check.
    :type return_node: astroid.Return

    :rtype: bool
    :return: True if the return node returns a value other than None,
        False otherwise.
    NF)valuer   r   Const)return_nodereturnss     r   returns_somethingr+   L   s9     G7EKK0JW]]d5JKKr   c                    t        | j                  t        j                        rU| j                  j                  }t        |t        j
                  t        j                  f      rt        j                  |      S y N)	r   excr   Callfuncr   r   r   
safe_infer)r   r0   s     r   _get_raise_targetr2   ^   sL    $((EJJ'xx}}dUZZ9:##D))r   c                2    d}t        j                  ||       S )Nz(\s*,(?:\s*or\s)?\s*|\s+or\s+))resplit)target
delimiterss     r   _split_multiple_exc_typesr8   f   s    2J88J''r   c                B   g }t        | j                  t        j                        r't	        j
                  | j                        }|r|g}n| j                  | j                  }|rCt        |t        j                        s)|j                  }|rt        |t        j                        s)|r|j                  rt	 t        j                  |j                        D ]$  }t        |t              r|j                  |       & n+t        |       }t        |t        j                        r|g}nt        |t        j                         r|j#                  t        j$                        D ]  }|j&                  |j)                         |k7  r$t	        j
                  |j&                        }|sFt	        j*                  |      s\t        |t        j                        r|j                  |       t        |t        j,                        s|j                  |j/                  d      d           	 |D ch c]$  }t	        j0                  | |j2                        s|& c}S # t        j                  $ r Y Fw xY wc c}w # t        j                  $ r t5               cY S w xY w)a  Gets all the possible raised exception types for the given raise node.

    .. note::

        Caught exception types are ignored.

    :param node: The raise node to find exception types for.

    :returns: A list of exception types possibly raised by :param:`node`.
    	__class__r   )r   r.   r   r   r   r1   parentExceptHandlertypeastroidunpack_inferr   appendInferenceErrorr2   ClassDefFunctionDefnodes_of_classReturnr'   frameinherit_from_std_exInstancer   node_ignores_exceptionr   set)	r   
exceptionsinferredhandler	exceptionr6   retvalr.   s	            r   possible_exc_typesrQ   k   s    J$((EJJ'##DHH-"J		++j%2E2EFnnG j%2E2EF w||!(!5!5gll!C 5I%iA")))45 #4(fenn- J 1 12,,U\\: G99$99;&(&&syy1544S9!#u~~6"))#.#C)9)9:"))#++k*B1*EFG "
//chh? 
 	
- )) ,

 !! us<   <2I  /I  0I> 4)I9I>  I65I69I> >JJc                `    t        | t        j                        xr | j                  t        k(  S r-   )r   r   r(   r'   Ellipsis)r   s    r   _is_ellipsisrT      s!    dEKK(CTZZ8-CCr   c              #     K   t        j                  | |      D ]-  \  }}|rt        |      s| |rt        |      s| *d  / y wr-   )	itertoolszip_longestrT   )r   comment_annotationsanncomment_anns       r   _merge_annotationsr[      sN      &11+?RS [|C(Ik!:Js   AA
c           	         | j                   xs d}| j                  j                  xs d}| j                  }|| j                  xs g z  }|| j                  z  }t        t        |t        ||                  S )a  Get a merged list of annotations.

    The annotations can come from:

    * Real type annotations.
    * A type comment on the function.
    * A type common on the individual argument.

    :param args_node: The node to get the annotations for.
    :returns: The annotations.
     )r   r;   type_comment_argstype_comment_posonlyargstype_comment_kwonlyargslistr[   )	args_nodeplain_annotationsfunc_comment_annotationsrX   s       r   _annotations_listre      s     "--3(//AAGR#<<966<"<9<<<79LM	
 r   c                   t               }t        |       }d}| j                  r| j                  }t	        | j                        s"t        | j                        }||||z    }||z  }t        | j                  |      D ]#  \  }}|s	|j                  |j                         % | j                  r\t        | j                        }t        | j                  ||||z          D ]#  \  }}|s	|j                  |j                         % ||z  }| j                  r[| j                  r|j                  | j                         n3t        |      |kD  r%||   r |j                  | j                         |dz  }| j                  r| j                  }t	        | j                        s"t        | j                        }||||z    }||z  }t        | j                  |      D ]#  \  }}|s	|j                  |j                         % | j                  r\| j                  r|j                  | j                         |S t        |      |kD  r%||   r |j                  | j                         |dz  }|S Nr      )rJ   re   posonlyargsposonlyargs_annotationsanyr
   zipaddr   argsvarargvarargannotation
kwonlyargskwonlyargs_annotationskwargkwargannotation)	rb   resultr   annotation_offsetrj   num_argsarg
annotationrr   s	            r   args_with_annotationrz      sN   UF#I.K"+"C"C94459001H&1!$5$@'# )"9#8#8:QR 	%OC

388$	% ~~y~~&"NN),=,HI 
 	%OC 

388$	% 	X%%%JJy''( 11kBS6TJJy''("!*!A!A93349//0H%0!$5$@&" )"9#7#79OP 	%OC

388$	% $$JJy'
 M	  11kBS6TJJy'"Mr   	Docstringc                    dt        j                  |t              |       f}t        t        t
        t        fD ]'  } ||       }|j                         }||d   kD  s$||f}) |d   S rg   )DOCSTRING_TYPESgetr{   SphinxDocstringEpytextDocstringGoogleDocstringNumpyDocstringmatching_sections)	docstringdefault_type
best_matchdocstring_typeinstancer   s         r   docstringifyr     sz     _((yA)LMJ	 	7 "),$668z!},+X6J	7 a=r   c                      e Zd ZU  ej                  dej
                  ej                  z        ZdZde	d<   	 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y)r{   z=
        For\s+the\s+(other)?\s*parameters\s*,\s+see
        Fboolsupports_yieldsc                N    |r|j                   nd}|j                         | _        y )N )r'   
expandtabsdoc)selfr   r   s      r   __init__zDocstring.__init__)  s    &)r	'')r   c                P    d| j                   j                   d| j                   dS )N<z:'''z'''>)r:   __name__r   r   s    r   __repr__zDocstring.__repr__-  s&    4>>**+4z>>r   c                     y)2Returns the number of matching docstring sections.r   r]   r   s    r   r   zDocstring.matching_sections0  s    r   c                    t               S r-   rJ   r   s    r   rK   zDocstring.exceptions4  s	    ur   c                     yNFr]   r   s    r   
has_paramszDocstring.has_params7      r   c                     yr   r]   r   s    r   has_returnszDocstring.has_returns:  r   r   c                     yr   r]   r   s    r   	has_rtypezDocstring.has_rtype=  r   r   c                     yr   r]   r   s    r   has_property_returnszDocstring.has_property_returns@  r   r   c                     yr   r]   r   s    r   has_property_typezDocstring.has_property_typeC  r   r   c                     yr   r]   r   s    r   
has_yieldszDocstring.has_yieldsF  r   r   c                     yr   r]   r   s    r   has_yields_typezDocstring.has_yields_typeI  r   r   c                *    t               t               fS r-   r   r   s    r   match_param_docszDocstring.match_param_docsL  s    uce|r   c                P    | j                   j                  | j                        d uS r-   )re_for_parameters_seesearchr   r   s    r   params_documented_elsewherez%Docstring.params_documented_elsewhereO  s"    ))00:$FFr   N)r   nodes.Const | NonereturnNoner   strr   intr   set[str]r   r   r   ztuple[set[str], set[str]])r   
__module____qualname__r4   compileXSr   r   __annotations__r   r   r   rK   r   r   r   r   r   r   r   r   r   r]   r   r   r{   r{     s|    &BJJ	 	rtt	 "OT!*?Gr   c            	      X   e Zd ZdZde dZde de de de d	Zde d	Zd
e de dZ ej                  eej                  ej                  z        Zde dZ ej                  eej                  ej                  z        Zde dZ ej                  eej                  ej                  z        Zde dZ ej                  eej                  ej                  z        Z ej                  d      Z ej                  d      Z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y)"r   zt
        [~!.]?               # Optional link style prefix
        \w(?:\w|\.[^\.])*    # Valid python name
        z	
        zw                     # a container type
        [\(\[] [^\n\s]+ [\)\]]        # with the contents of the container
    
        (?:|4)
        (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+)(?:))*
    z?
        (?::\w+:)?                    # optional tag
        `z0`                   # what to reference
        a#  
        :                       # initial colon
        (?:                     # Sphinx keywords
        param|parameter|
        arg|argument|
        key|keyword
        )
        \s+                     # whitespace

        (?:                     # optional type declaration
        (z)
        \s+
        )?

        ((\\\*{0,2}\w+)|(\w+))  # Parameter name with potential asterisks
        \s*                       # whitespace
        :                         # final colon
        zx
        :type                           # Sphinx keyword
        \s+                             # whitespace
        (z)     # Parameter name
        \s*                             # whitespace
        :                               # final colon
        zo
        :type:                      # Sphinx keyword
        \s+                         # whitespace
        z   # type declaration
        z
        :                               # initial colon
        (?:                             # Sphinx keyword
        raises?|
        except|exception
        )
        \s+                             # whitespace
        (z)     # exception type
        \s*                             # whitespace
        :                               # final colon
        z:rtype:z
:returns?:Fc           
        t        d | j                  j                  | j                        | j                  j                  | j                        | j
                  j                  | j                        | j                  j                  | j                        | j                  j                  | j                        fD              S )r   c              3  2   K   | ]  }t        |        y wr-   r   .0is     r   	<genexpr>z4SphinxDocstring.matching_sections.<locals>.<genexpr>        	
 G	
   )sumre_param_in_docstringr   r   re_raise_in_docstringre_rtype_in_docstringre_returns_in_docstringre_property_type_in_docstringr   s    r   r   z!SphinxDocstring.matching_sections  s     	
 **11$((;**11$((;**11$((;,,33DHH=2299$((C	
 	
 		
r   c                    t               }t        j                  | j                  | j                        D ]-  }|j                  d      }|j                  t        |             / |S Nrh   )rJ   r4   finditerr   r   groupupdater8   )r   typesmatch
raise_types       r   rK   zSphinxDocstring.exceptions  sU    %[[!;!;TXXF 	@EQJLL2:>?	@ r   c                j    | j                   sy| j                  j                  | j                         d uS r   )r   r   r   r   s    r   r   zSphinxDocstring.has_params  s,    xx))00:$FFr   c                x    | j                   syt        | j                  j                  | j                               S r   )r   r   r   r   r   s    r   r   zSphinxDocstring.has_returns  s,    xxD0077ABBr   c                x    | j                   syt        | j                  j                  | j                               S r   )r   r   r   r   r   s    r   r   zSphinxDocstring.has_rtype  s,    xxD..55dhh?@@r   c                p    | j                   sy| j                   j                         j                  d       S )NF:)r   r   
startswithr   s    r   r   z$SphinxDocstring.has_property_returns  s-    xx 88??$//444r   c                x    | j                   syt        | j                  j                  | j                               S r   )r   r   r   r   r   s    r   r   z!SphinxDocstring.has_property_type  s,    xxD66==dhhGHHr   c                   t               }t               }t        j                  | j                  | j                        D ][  }|j                  d      }|j                  dd      }|j                  |       |j                  d      }|K|j                  |       ] |j                  t        j                  | j                  | j                               ||fS )N   \r   rh   )rJ   r4   r   r   r   r   replacerm   r   findallre_type_in_docstring)r   params_with_docparams_with_typer   r   
param_types         r   r   z SphinxDocstring.match_param_docs  s    %5[[!;!;TXXF 	+E;;q>D<<b)D%QJ% $$T*	+ 	

4+D+Ddhh OP 000r   Nr   r   r   r   )r   r   r   re_typere_simple_container_typere_multiple_simple_typere_xrefre_param_rawr4   r   r   r   r   re_type_rawr   re_property_type_rawr   re_raise_rawr   r   r   r   r   rK   r   r   r   r   r   r   r]   r   r   r   r   S  s   G
%			  
$$%Qwi 033K2LAgY W


 	G


 !,- .	L$ 'BJJ|RTTBDD[A
 "	" #	K &2::k244"$$;?!	 
!! "	
 %/BJJ/CRTTBDD[$Q!
 "	" #	
L 'BJJ|RTTBDD[A&BJJz2(bjj7O
GCA5I1r   r   c                     e Zd ZdZ ej
                  ej                  j                  ddd      ej                  ej                  z        Z ej
                  ej                  j                  ddd      ej                  ej                  z        Z ej
                  ej                  j                  ddd      ej                  ej                  z        Z ej
                  ej                   j                  ddd      ej                  ej                  z        Z ej
                  dej                  ej                  z        Z ej
                  d      Zd	dZy)
r   a  Epytext is similar to Sphinx.

    See the docs:
        http://epydoc.sourceforge.net/epytext.html
        http://epydoc.sourceforge.net/fields.html#fields

    It's used in PyCharm:
        https://www.jetbrains.com/help/pycharm/2016.1/creating-documentation-comments.html#d848203e314
        https://www.jetbrains.com/help/pycharm/2016.1/using-docstrings-to-specify-types.html
    r   @rh   z
        @                       # initial "at" symbol
        (?:                     # Epytext keyword
        rtype|returntype
        )
        :                       # final colon
        z
@returns?:c                    | j                   sy| j                         r*| j                   j                         j                  d       S y)NFr   )r   r   r   r   r   s    r   r   z%EpytextDocstring.has_property_returns  s>    xx !!# xx(33C888r   Nr   )r   r   r   __doc__r4   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r]   r   r   r   r     s,   	 'BJJ$$,,S#q9244"$$; &2::##++Ca8"$$+ %/BJJ,,44S#qA244"$$;%! 'BJJ$$,,S#q9244"$$; 'BJJ	 	rtt	 )bjj7
r   r   c                     e Zd Zej                  Zej
                  Zde de dZde de de de de de dZdZ e	j                  ej                  d      e	j                  e	j                  z  e	j                  z        Z e	j                  ej                  d      e	j                  e	j                  z  e	j                  z        Z e	j                  d	e d
e	j                  e	j                  z  e	j                  z        Z e	j                  ej                  d      e	j                  e	j                  z  e	j                  z        Z e	j                  de de	j                  e	j                  z  e	j                  z        Z e	j                  ej                  d      e	j                  e	j                  z  e	j                  z        Z e	j                  de de	j                  e	j                  z  e	j                  z        Z e	j                  de de	j                  e	j                  z  e	j                  z        Z e	j                  ej                  d      e	j                  e	j                  z  e	j                  z        ZeZ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%d)d        Z&e%d*d!       Z'd+d"Z(y#),r   r   r   zj)       # a container type
        [\(\[] [^\n]+ [\)\]]          # with the contents of the container
    r   r   zy
        ^([ ]*)   {0} \s*:   \s*$     # Google parameter header
        (  .* )                       # section
        (?:Args|Arguments|Parameters)z&Keyword\s(?:Args|Arguments|Parameters)z}
        \s*  ((?:\\?\*{0,2})?[\w\\]+) # identifier potentially with asterisks or escaped `\`
        \s*  ( [(]
            z
            (?:,\s+optional)?
            [)] )? \s* :                # optional type declaration
        \s*  (.*)                       # beginning of optional description
    Raisesz
        \s*  (zg) \s* :  # identifier
        \s*  (.*)                        # beginning of optional description
    Returns?
        \s* (za:)?        # identifier
        \s* (.*)                          # beginning of description
    z

        ^za:           # identifier
        \s* (.*)                       # Summary line / description
    Yields?Tc                   t        d | j                  j                  | j                        | j                  j                  | j                        | j
                  j                  | j                        | j                  j                  | j                        | j                  j                  | j                               fD              S )r   c              3  2   K   | ]  }t        |        y wr-   r   r   s     r   r   z4GoogleDocstring.matching_sections.<locals>.<genexpr>p  r   r   )	r   re_param_sectionr   r   re_raise_sectionre_returns_sectionre_yields_sectionre_property_returns_line_first_liner   s    r   r   z!GoogleDocstring.matching_sectionsn  s     	
 %%,,TXX6%%,,TXX6''..txx8&&--dhh7--44T5E5E5GH	
 	
 		
r   c                j    | j                   sy| j                  j                  | j                         d uS r   )r   r  r   r   s    r   r   zGoogleDocstring.has_params{  s,    xx$$++DHH5TAAr   c                    | j                   sy| j                  | j                        }|D ]5  }| j                  j	                  |      }|s!|j                  d      }|s5 y yNFr   Tr   _parse_sectionr  re_returns_liner   r   )r   entriesentryr   return_descs        r   r   zGoogleDocstring.has_returns  e    xx%%d&=&=> 	E((..u5E++a.K	 r   c                    | j                   sy| j                  | j                        }|D ]5  }| j                  j	                  |      }|s!|j                  d      }|s5 y yNFrh   Tr  )r   r  r  r   return_types        r   r   zGoogleDocstring.has_rtype  r  r   c                   | j                         }t        | j                  j                  |      xsU | j                  j                  |      xs8 | j
                  j                  |      xs | j                  j                  |             S r-   )r  r   r  r   r  r  r  )r   
first_lines     r   r   z$GoogleDocstring.has_property_returns  s     %%'
!!((4 9$$++J79&&--j99 %%,,Z8	
 
 	
r   c                    | j                   syt        | j                  j                  | j	                                     S r   )r   r   r  r   r  r   s    r   r   z!GoogleDocstring.has_property_type  s1    xxD11778H8H8JKLLr   c                    | j                   sy| j                  | j                        }|D ]5  }| j                  j	                  |      }|s!|j                  d      }|s5 y yr  r   r  r  re_yields_liner   r   )r   r  r  r   
yield_descs        r   r   zGoogleDocstring.has_yields  e    xx%%d&<&<= 	E''--e4EQJ	 r   c                    | j                   sy| j                  | j                        }|D ]5  }| j                  j	                  |      }|s!|j                  d      }|s5 y yr  r  )r   r  r  r   
yield_types        r   r   zGoogleDocstring.has_yields_type  r  r   c                   t               }| j                  | j                        }|D ]_  }| j                  j	                  |      }|s!|j                  d      }|j                  d      }|sF|j                  t        |             a |S )Nrh   r   )rJ   r  r  re_raise_liner   r   r   r8   )r   r   r  r  r   exc_typeexc_descs          r   rK   zGoogleDocstring.exceptions  s    %%%d&;&;< 	BE&&,,U3E{{1~H{{1~H6x@A	B r   c                   t               }t               }| j                  | j                        }|j                  | j                  | j                               |D ]  }| j
                  j                  |      }|s!|j                  d      }|j                  dd      }|j                  d      }|j                  d      }|r|j                  |       |s||j                  |        ||fS )Nrh   r   r   r      )
rJ   r  r  extendre_keyword_param_sectionre_param_liner   r   r   rm   )	r   r   r   r  r  r   
param_namer   
param_descs	            r   r   z GoogleDocstring.match_param_docs  s    $'E%(U%%d&;&;<t**4+H+HIJ 	0E&&,,U3EQJ#++D"5JQJQJ $$Z0##J/!	0$  000r   c                \    | j                   j                         j                  dd      d   S )N
rh   r   )r   r   r5   r   s    r   r  zGoogleDocstring._first_line  s%    xx &&tQ/22r   c                <    t        | j                  d            dz   S r   r
   r   section_matchs    r   min_section_indentz"GoogleDocstring.min_section_indent  s    =&&q)*Q..r   c                     yr   r]   )_s    r   _is_section_headerz"GoogleDocstring._is_section_header  s     r   c                   |j                  | j                        }|g S | j                  |      }g }g }d}|j                  d      j	                         D ]x  }|j                         st        |      }||k  r nU|r|}d}||k(  r7| j                  |      r n7|r"|j                  dj                  |             g }|j                  |       z |r |j                  dj                  |             |S )NTr   Fr,  )
r   r   r1  r   
splitlinesstripr   r4  r@   join)	r   
section_rer0  min_indentationr  r  is_firstlineindentations	            r   r  zGoogleDocstring._parse_section	  s    "))$((3 I11-@!''*557 	D::<+D1K_, "- o-**40 NN499U#34ELL-	0 NN499U+,r   Nr   r   r   r   r   r0  zre.Match[str]r   r   )r3  r   r   r   )r9  zre.Pattern[str]r   	list[str]))r   r   r   r   r   r   re_container_typere_multiple_type_re_section_templater4   r   formatr   r   Mr  r'  r(  r  r!  r  r  r  r  r  r   r   r   r   r   r   r   r   r   rK   r   r  staticmethodr1  r4  r  r]   r   r   r   r     s   %%G%%G9AgY 
ay' 333D2EQwiqQXPY Z

 "rzz##$DE
rttbdd
  *rzz##$MN
rttbdd 
 BJJ  	 	rttbdd
M "rzz##I.rttbdd0B BJJ  !	 	rttbddM $##K0"$$+2D !bjj  	 	rttbddO  *rzz

	 	 	rttbdd  #

##J/rtt1C %NO
B  	
M   143 / /  
%r   r   c                     e Zd ZdZ ej
                  ej                  d      ej                  ej                  z  ej                  z        Z
dZ ej
                  dej                   de dej                  ej                  z        Z ej
                  ej                  d      ej                  ej                  z  ej                  z        Z ej
                  dej                    d	ej                  ej                  z  ej                  z        Z ej
                  ej                  d
      ej                  ej                  z  ej                  z        Z ej
                  dej                   dej                  ej                  z  ej                  z        Z ej
                  ej                  d      ej                  ej                  z  ej                  z        ZeZdZddZedd       Zedd       Zy)r   z
        ^([ ]*)   {0}   \s*?$          # Numpy parameters header
        \s*     [-=]+   \s*?$          # underline
        (  .* )                        # section
    r   z.((['"]\w+\s*['"])|(\d+)|(True)|(False)|(None))z
        \s*  (?P<param_name>\*{0,2}\w+)(\s?(:|\n)) # identifier with potential asterisks
        \s*
        (?P<param_type>
         (
          (z)      # default type declaration
          (,\s+optional)?                           # optional 'optional' indication
         )?
         (
          {(z,?\s*)+}            # set of default values
         )?
         (?:$|\n)
        )?
        (
         \s* (?P<param_desc>.*)                     # optional description
        )?
    r   r   z^)$   # type declaration
        \s* (.*)                           # optional description
    r   z6
        \s* (?:\w+\s+:\s+)? # optional name
        (zc)$   # type declaration
        \s* (.*)                                # optional description
    r   Tc                t   t               }t               }| j                  | j                        }|j                  | j                  | j                               |D ]  }| j
                  j                  |      }|s!t        j                  d|      }|r%|j                  d      }|j                  d      }d}	nS|j                  d      }|j                  d      }	|j                  d      }|	t        j                  d|      r|}	|s|	r|	}|	r|j                  |       |s|j                  |        ||fS )zIMatches parameter documentation section to parameter documentation rules.z\s*(\*{0,2}\w+)\s*:?\n\s*\w*$r)  r   Nr*  z\s*(\*{0,2}\w+)\s*:.+$)
rJ   r  r  r&  r'  r(  r   r4   r   rm   )
r   r   r   r  r  r   re_only_descr)  r*  r   s
             r   r   zNumpyDocstring.match_param_docsu  s(   %5%%d&;&;<t**4+H+HIJ 	0E&&,,U3E 88$DeLL"[[6
"[[6
!
"[[6
"[[6
"[[6
 %"((3Le*T!+J "j!+J $$Z0##J/?	0B  000r   c                6    t        | j                  d            S r   r.  r/  s    r   r1  z!NumpyDocstring.min_section_indent  s    =&&q)**r   c                @    t        t        j                  d|             S )Nz\s*-+$)r   r4   r   )r<  s    r   r4  z!NumpyDocstring._is_section_header  s    BHHY-..r   Nr   r>  )r<  r   r   r   )r   r   r   rB  r4   r   rC  r   r   rD  r  re_default_valuer   rA  r(  r  r   r!  r  r  r  r  r   r   rE  r1  r4  r]   r   r   r   r   1  s    "rzz##$DE
rttbdd
 MBJJ
 ,,- .   	" 	rtt%M* "rzz##I.rttbdd0B BJJ%%& '	 	rttbddM $##K0"$$+2D !bjj


*
*	+ ,	
 	rttbddO #

##J/rtt1C %NO(1T + + / /r   r   )sphinxepytextgooglenumpydefault)r   r   r   r   )r   nodes.FunctionDefr   z
str | None)r   rQ  r   znodes.FunctionDef | None)r)   znodes.Returnr   r   )r   nodes.NodeNGr   z%nodes.NodeNG | UninferableBase | None)r6   r   r   r?  )r   rR  r   zset[nodes.ClassDef])r   rR  r   r   )r   Iterable[nodes.NodeNG]rX   rS  r   zIterable[nodes.NodeNG | None])rb   nodes.Argumentsr   zlist[nodes.NodeNG])rb   rT  r   r   )rP  )r   r   r   r   r   r{   )r   
__future__r   rV   r4   collections.abcr   r>   r   astroid.utilr   pylint.checkersr   r   r   r%   r+   r2   r8   rQ   rT   r[   re   rz   r   r{   r   r   r   r   r}   r]   r   r   <module>rY     s   
 . "  	 $   ( !'*0L$(
6rD	'	>T	"	28x 8A!14$6G 6GrP1i P1f3 3lRi Rjt/_ t/p r   