
    c                        d Z ddlmZ ddlZddl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	k    rdd
lmZ ndd
lmZ  ej        d          ZddZ G d de          ZdS )z)Docstring checker from the basic checker.    )annotationsN)nodes)
interfaces)utils)_BasicChecker)is_overload_stubis_property_deleteris_property_setter)      )Literalz^_node1nodes.Module | nodes.ClassDef | nodes.FunctionDefreturn
str | Nonec                    	 | d         }n# t           $ r Y d S w xY wt          j        |          }|sd S t          |t          j                  sd S t          |j                  S )N__doc__)KeyErrorr   
safe_infer
isinstancer   Conststrvalue)r   	docstrings     Flib/python3.11/site-packages/pylint/checkers/base/docstring_checker.py_infer_dunder_doc_attributer   !   s|    O		   tt  ++I ti-- tys    
c                  >   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          d0d             Z	 ej        dd          d1d"            Z
 ej        dd          d2d$            ZeZd%ej        fd3d-Zd.S )4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.r   Nonec                B    | j         j                                         d S )N)linterstatsreset_undocumented)selfs    r   openzDocStringChecker.openl   s    ,,.....    r   nodes.Modulec                2    |                      d|           d S )Nmodule)_check_docstringr6   r   s     r   visit_modulezDocStringChecker.visit_moduleo   s    h-----r8   nodes.ClassDefc                    | j         j        j                            |j                  |                     d|           d S d S )Nclass)r3   configno_docstring_rgxmatchnamer<   r=   s     r   visit_classdefzDocStringChecker.visit_classdefs   sH    ;.44TY?? 	1!!'400000	1 	1r8   nodes.FunctionDefc                   | j         j        j                            |j                  |                                rdnd}t          |          st          |          st          |          rd S t          |j
                            d          t          j                  rd}t          j        |j
                            d                    rt           j        nt           j        }|j
                            d                                          D ]M}|                                dk    r|j        |v r)t          ||j                 t          j                  rd} nN|                     ||| |           d S t          |j
                            d          t          j                  r|                     ||           d S d S d S )NmethodfunctionT)futureFzbuiltins.object)report_missing
confidence)r3   rB   rC   rD   rE   	is_methodr
   r	   r   r   parentframer   ClassDefr   has_known_basesr   	INFERENCEINFERENCE_FAILURE	ancestorsqnameFunctionDefr<   Module)r6   r   ftype
overriddenrM   ancestors         r   visit_functiondefz"DocStringChecker.visit_functiondefx   s   ;.44TY?? 	 $ 0 0@HHjE"4((&t,, $D))
 $+++4+88%.II "
 ,T[->->d->-K-KLL6J((#5  !% 1 1 1 > > H H J J  H~~''+<< ! yH,  +U->2 2  &*
%%4J: &      DK--T-::ELII %%eT22222?	 	r8   T	node_type0Literal['class', 'function', 'method', 'module']r   rL   boolrM   interfaces.Confidencec                V   |j         r|j         j        nd}|t          |          }||sdS t          j        |          |j        z
  }|dk    r|sdS | j        j        j        }|dk    r|dk    r||k     rdS |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                  rrt          j        |j        d         j        j                  }t          |t$          j                  r/t          |j        t$          j                  r|j        j        dv rdS |dk    rd	}	n|dk    rd
}	nd}	|                     |	||           dS |                                sa|dk    r | j        j	        j
        dxx         dz  cc<   n| j        j	        j
        |xx         dz  cc<   |                     d||f|           dS dS )z,Check if the node has a non-empty docstring.Nr;   r/   rA   klass   r   >   r   bytesunicoder"   r$   r%   )r   rM   r   )r   argsrM   )doc_noder   r   r   get_node_last_linenolinenor3   rB   docstring_min_lengthr4   undocumentedbodyr   r   ExprCallr   funcastroidBoundMethodboundInstancerE   add_messagestrip)
r6   r]   r   rL   rM   r   lines	max_linesro   messages
             r   r<   z!DocStringChecker._check_docstring   s    ,0=BDM''d	 	:3D99I ,	! .t44t{BEH$ U  *?IH$ R EI<M G# ?!.w7771<7777!.y999Q>999	ty|UZ88 ty|15:>> '	!(:(?@@dG$788 ZJ 0> >  z*EE H$ 74g% 736W4JGGGGG"" 	G# ?!.w7771<7777!.y999Q>999!I<J      	 	r8   N)r   r1   )r   r9   r   r1   )r   r?   r   r1   )r   rG   r   r1   )
r]   r^   r   r   rL   r_   rM   r`   r   r1   )__name__
__module____qualname__msgsNO_REQUIRED_DOC_RGXoptionsr7   r   only_required_for_messagesr>   rF   r\   visit_asyncfunctiondefr   HIGHr<    r8   r   r   r   2   s        !2;<=
 '&89:;
 &%99:;
 3( 9:;
- DB . %	 
	
 #"D 	
G4/ / / / &U%&@BSTT. . . UT. &U%&?ARSS1 1 1 TS1 &U%&BDUVV      WV D /  $,6O8 8 8 8 8 8 8r8   r   )r   r   r   r   )r   
__future__r   resysrp   r   pylintr   pylint.checkersr   "pylint.checkers.base.basic_checkerr   pylint.checkers.utilsr   r	   r
   version_infotypingr   typing_extensionscompiler}   r   r   r   r8   r   <module>r      sS  
 0 / " " " " " " 				 



              ! ! ! ! ! ! < < < < < <          v *)))))) !bj&&        "c c c c c} c c c c cr8   