
    ej                        d Z ddlm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lmZ dd	lmZmZmZ  ej$                  d
      Z	 	 	 	 ddZ G d de      Zy)z)Docstring checker from the basic checker.    )annotationsN)Literal)nodes)
interfaces)utils)_BasicChecker)is_overload_stubis_property_deleteris_property_setterz^_c                    	 | d   }t        j                  |      }|sy t        |t        j
                        sy t        |j                        S # t         $ r Y y w xY w)N__doc__)KeyErrorr   
safe_infer
isinstancer   Conststrvalue)node	docstrings     H/usr/lib/python3/dist-packages/pylint/checkers/base/docstring_checker.py_infer_dunder_doc_attributer      s\    O	   +Ii-y  s   A 	AAc                  R   e Zd Zdddddgifddddd	gifd
dddd	gifddddd	gifdZdeddddfddddddffZd"dZ ej                  dd      d#d       Z	 ej                  dd      d$d       Z
 ej                  dd      d%d       ZeZdej                  f	 	 	 	 	 	 	 	 	 d&d Zy!)'DocStringCheckerzEmpty %s docstringempty-docstringz^Used when a module, function, class or method has an empty docstring (it would be too easy ;).	old_names)W0132zold-empty-docstringzMissing module docstringmissing-module-docstringzNUsed when a module has no docstring. Empty modules do not require a docstring.)C0111zmissing-docstringzMissing class docstringmissing-class-docstringzNUsed when a class has no docstring. Even an empty class must have a docstring.z$Missing function or method docstringmissing-function-docstringzoUsed when a function or method has no docstring. Some special methods like __init__ do not require a docstring.)C0112C0114C0115C0116zno-docstring-rgxregexpz<regexp>zcRegular expression which should only match function or class names that do not require a docstring.)defaulttypemetavarhelpzdocstring-min-lengthintz<int>z[Minimum line length for functions/classes that require docstrings, shorter ones are exempt.c                L    | j                   j                  j                          y )N)linterstatsreset_undocumented)selfs    r   openzDocStringChecker.openg   s    ,,.    c                (    | j                  d|       y )Nmodule)_check_docstringr0   r   s     r   visit_modulezDocStringChecker.visit_modulej   s    h-r2   c                    | j                   j                  j                  j                  |j                        | j                  d|       y y )Nclass)r-   configno_docstring_rgxmatchnamer5   r6   s     r   visit_classdefzDocStringChecker.visit_classdefn   s=    ;;..44TYY?G!!'40 Hr2   c                   | j                   j                  j                  j                  |j                        |j                         rdnd}t        |      st        |      st        |      ry t        |j                  j                         t        j                        rd}t        j                  |j                  j                               rt         j"                  nt         j$                  }|j                  j                         j'                         D ]P  }|j)                         dk(  r|j                  |v s&t        ||j                     t        j*                        sNd} n | j-                  ||| |       y t        |j                  j                         t        j.                        r| j-                  ||       y y y )NmethodfunctionFzbuiltins.objectT)report_missing
confidence)r-   r:   r;   r<   r=   	is_methodr   r
   r	   r   parentframer   ClassDefr   has_known_basesr   	INFERENCEINFERENCE_FAILURE	ancestorsqnameFunctionDefr5   Module)r0   r   ftype
overriddenrC   ancestors         r   visit_functiondefz"DocStringChecker.visit_functiondefs   si   ;;..44TYY?G $ 0HjE"4(&t,#D)$++++-u~~>"
 ,,T[[->->-@A ((#55  !% 1 1 3 = = ? H~~'+<< yyH, +U->->2 &*
 %%4J: &  DKK--/>%%eT2? Hr2   Tc                   |j                   r|j                   j                  nd}|t        |      }||syt        j                  |      |j
                  z
  }|dk(  r|sy| j                  j                  j                  }|dk7  r|dkD  r||k  ry|dk(  r,| j                  j                  j                  dxx   dz  cc<   n+| j                  j                  j                  |xx   dz  cc<   |j                  rt        |j                  d   t        j                        rt        |j                  d   j                  t        j                        rt        j                   |j                  d   j                  j"                        }t        |t$        j&                        r=t        |j(                  t$        j*                        r|j(                  j,                  dv ry|dk(  rd	}	n
|dk(  rd
}	nd}	| j/                  |	||       y|j1                         ss|dk(  r,| j                  j                  j                  dxx   dz  cc<   n+| j                  j                  j                  |xx   dz  cc<   | j/                  d||f|       yy)z,Check if the node has a non-empty docstring.Nr4   r*   r9   klass   r   >   r   bytesunicoder   r   r    )r   rC   r   )r   argsrC   )doc_noder   r   r   get_node_last_linenolinenor-   r:   docstring_min_lengthr.   undocumentedbodyr   r   ExprCallr   funcastroidBoundMethodboundInstancer=   add_messagestrip)
r0   	node_typer   rB   rC   r   lines	max_linesra   messages
             r   r5   z!DocStringChecker._check_docstring   s    ,0==DMM''d	3D9I!..t4t{{BEH$U **??IH$REI<MG#!!..w71<7!!..y9Q>9		tyy|UZZ8tyy|115::> ''		!(:(:(?(?@dG$7$78ZJJ 0 0> zz*EEH$4g%36W4JG"G#!!..w71<7!!..y9Q>9!I<J   #r2   N)returnNone)r   znodes.Modulerl   rm   )r   znodes.ClassDefrl   rm   )r   znodes.FunctionDefrl   rm   )
rh   z0Literal['class', 'function', 'method', 'module']r   1nodes.Module | nodes.ClassDef | nodes.FunctionDefrB   boolrC   zinterfaces.Confidencerl   rm   )__name__
__module____qualname__msgsNO_REQUIRED_DOC_RGXoptionsr1   r   only_required_for_messagesr7   r>   rR   visit_asyncfunctiondefr   HIGHr5    r2   r   r   r   -   s    !2;<=
 '&89:;
 &%99:;
 3( 9:;
-DB . %	
	
 #"D	
G4/ &U%%&@BST. U. &U%%&?ARS1 T1 &U%%&BDUV  W D /  $,6OO8C8 @8 	8
 *8 
8r2   r   )r   rn   rl   z
str | None)r   
__future__r   retypingr   rb   r   pylintr   pylint.checkersr   "pylint.checkers.base.basic_checkerr   pylint.checkers.utilsr	   r
   r   compilert   r   r   ry   r2   r   <module>r      sb   
 0 " 	     ! <  !bjj&  
;  "c} cr2   