
    Be{0                        d 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
mZmZ ddlmZ ddlmZ d	Z ed
g d      Z G d d      Z G d d      Zej+                  dd      Zej/                  dd      Zej/                  dd      Zej/                  dd      Zej/                  dd      Zej/                  dd      Zej/                  dd      Zej/                  dd      Zej/                  d d!      Zej+                  d"d#      Z e j/                  d$d%d&      Z!e j/                  d'd(d&      Z"e j/                  d)d*d&      Z#e j/                  d+d,d&      Z$e j/                  d-d.d&      Z%e j/                  d/d0d&      Z&e j/                  d1d2      Z'e j/                  d3d4      Z(e j/                  d5d6      Z)e j/                  d7d8      Z*e j/                  d9d:      Z+e j/                  d;d<d&      Z,e j/                  d=d>      Z-e j/                  d?d@      Z.e j/                  dAdBdC      Z/e j/                  dDdEdF      Z0ej+                  dGdH      Z1e1j/                  dIdJdK      Z2e1j/                  dLdM      Z3e1j/                  dNdO      Z4ej+                  dPdQ      Z5e5j/                  dRdSdT      Z6e5j/                  dUdVdW      Z7e5j/                  dUdXdY      Z8e5j/                  dZd[      Z9e5j/                  d\d]d^      Z:e5j/                  d_d`      Z;e5j/                  dadbd^      Z<e5j/                  dcddd^      Z=e5j/                  dedfdC      Z>e5j/                  dgdhdC      Z?e5j/                  didjdk      Z@e5j/                  dldmdC      ZAe5j/                  dndodC      ZBe5j/                  dpdqdC      ZCe5j/                  drdsdC      ZDe5j/                  dtdudC      ZEe5j/                  dvdwdT      ZFe5j/                  dxdyd^      ZGe5j/                  dzd{d|      ZHe5j/                  d}d~      ZIe5j/                  dd      ZJ G d deK      ZL eMej                               ZO eLeOh dz
  eOh dz
  eOh dz
  d      ZPy)zDocstring violation definition.    )
namedtuple)partial)	dropwhile)AnyCallableIterableListOptional   )
Definitionis_blank)ErrorErrorRegistryconventionsErrorParams)code
short_desccontextc            
           e Zd ZdZdZdZdedededee   ddf
d	Zd
e	deddfdZ
 ed       Z ed       Zedefd       Zedefd       ZdefdZdefdZdd defdZy)r   zError in docstring style.Fr   r   r   
parametersreturnNc                 X    || _         || _        || _        || _        d| _        d| _        y)zYInitialize the object.

        `parameters` are specific to the created error.

        N)r   r   r   r   
definitionexplanation)selfr   r   r   r   s        5lib/python3.12/site-packages/pydocstyle/violations.py__init__zError.__init__   s/     	$$    r   r   c                      || _         || _        y)z+Set the source code context for this error.N)r   r   )r   r   r   s      r   set_contextzError.set_context+   s    $&r   c                 B    | j                   j                  j                  S N)r   modulenamer   s    r   <lambda>zError.<lambda>0   s    T__%;%;%@%@ r   c                 .    | j                   j                  S r#   )r   error_linenor&   s    r   r'   zError.<lambda>1   s    !=!= r   c                     | j                    d| j                   }| j                  , | j                  j                  | j                   }|d| dz  }|S )z(Return the message to print to the user.z: z ())r   r   r   formatr   )r   retspecific_error_msgs      r   messagezError.message3   s\     2doo./<<#!4!4!4doo!FR*+1--C
r   c                    | j                   yd}| j                   j                  j                  d      }| j                   j                  }t	        t        t	        t        t        t        |                              }t        t        |t        |      z               }d| d}t        |      D ]1  \  }}|rd|z   }||j                  ||z   |      z  }|dkD  s+|dz  } |S  |S )	z,Return the source code lines for this error. T)keependsz{:z}:{}    z        ...
)r   source
splitlinesstartlistreversedr   r   lenstr	enumerater,   )	r   r5   linesoffsetlines_strippednumbers_widthline_formatnlines	            r   r=   zError.lines<   s     ??"&&1141@&&T)Hhuo>?@
 C^)< <=>M?'2 0 	GAtTzk((VT::F1u/)	 r   c                    | j                   r6dj                  d | j                   j                  d      D              | _         d}| j                  r| j                  r|dz  }n;| j                  r| j                  s|dz  }n| j                  r| j                  s|dz  } |j
                  di dD ci c]  }|t        | |       c}S c c}w )	N
c              3   8   K   | ]  }t        |      r|  y wr#   r   ).0ls     r   	<genexpr>z Error.__str__.<locals>.<genexpr>T   s      )x{)s   z1{filename}:{line} {definition}:
        {message}z

{explanation}

{lines}
z


{lines}
z

{explanation}

)filenamerC   r   r/   r   r=    )r   joinsplitr5   explainr,   getattr)r   templater%   s      r   __str__zError.__str__R   s    #yy )++11$7)  D H;;4<<88H[['H\\$++//Hx 

 gdD))

 	

s   0C	c                     t        |       S r#   )r;   r&   s    r   __repr__zError.__repr__l   s    4yr   otherc                 d    | j                   | j                  f|j                   |j                  fk  S r#   )rJ   rC   )r   rT   s     r   __lt__zError.__lt__o   s'    tyy)U^^UZZ,HHHr   )__name__
__module____qualname____doc__rN   r5   r;   r   r   r   r!   propertyrJ   rC   r/   r=   rQ   rS   boolrV   rK   r   r   r   r      s    # GF     	 
 c]  
 &'j 's 't '
 @AH=>D   s  *
 
4# IG I Ir   r   c                   x    e Zd ZdZg Z G d d      Zedededefd       Zede	e   fd       Z
edefd	       Zy
)r   z1A registry of all error codes, divided to groups.c                   X    e Zd ZdZdededdfdZ	 ddeded	ee   deee   ge	f   fd
Z
y)ErrorRegistry.ErrorGroupz#A group of similarly themed errors.prefixr%   r   Nc                 .    || _         || _        g | _        y)zInitialize the object.

            `Prefix` should be the common prefix for errors in this group,
            e.g., "D1".
            `name` is the name of the group (its subject).

            N)r`   r%   errors)r   r`   r%   s      r   r   z!ErrorRegistry.ErrorGroup.__init__{   s     !DKDIDKr   
error_code
error_descerror_contextc                 v    t        |||      }t        t        g| }| j                  j	                  |       |S )z9Create an error, register it to this group and return it.)r   r   r   rb   append)r   rc   rd   re   error_paramsfactorys         r   create_errorz%ErrorRegistry.ErrorGroup.create_error   s8     'z:}MLe3l3GKK|,Nr   r#   )rW   rX   rY   rZ   r;   r   r
   r   r   r   rj   rK   r   r   
ErrorGroupr_   x   sc    1
	3 
	c 
	d 
	  ,0			 	 $C=		
 x}ou,-	r   rk   r`   r%   r   c                 `    | j                  ||      }| j                  j                  |       |S )z'Create a new error group and return it.)rk   groupsrg   )clsr`   r%   groups       r   create_groupzErrorRegistry.create_group   s+     vt,

% r   c              #   l   K   | j                   D ]!  }|j                  D ]  }|j                    # yw)zYield all registered codes.N)rm   rb   r   )rn   ro   errors      r   get_error_codeszErrorRegistry.get_error_codes   s8      ZZ 	!E !jj !	!s   24c                    t        d | j                  D              }dd|dz   z  z   dz   }d|dz   dz  z   d	z   }d
}| j                  D ]  }||z  }||z  }|dd|j                   dj                  |dz         z   d	z   z  }||z  }|j                  D ]M  }||z  }|d|j
                  j                  d      z   dz   |j                  j                  |dz         z   d	z   z  }O  ||z  }|S )z;Output the registry as reStructuredText, for documentation.c              3   h   K   | ]*  }|j                   D ]  }t        |j                          , y wr#   )rb   r:   r   )rG   ro   rr   s      r   rI   z'ErrorRegistry.to_rst.<locals>.<genexpr>   s<      

    !
!
s   02z+------+-   z+
|	   r3   z|
r1   z**   z| r   )maxrm   r%   centerrb   r   r   ljust)rn   max_lensep_line
blank_linetablero   rr   s          r   to_rstzErrorRegistry.to_rst   s:     

 

 '!)<<uDGaK3..6
ZZ 	EXEZESR

|2.55gkBBUJJEZE !jj''*+ &&,,Wq[9: 		 	r   N)rW   rX   rY   rZ   rm   rk   classmethodr;   rp   r   rs   r   rK   r   r   r   r   s   sw    ;F : # S Z   ! ! ! s  r   r   D1zMissing DocstringsD100z"Missing docstring in public moduleD101z!Missing docstring in public classD102z"Missing docstring in public methodD103z$Missing docstring in public functionD104z#Missing docstring in public packageD105z!Missing docstring in magic methodD106z(Missing docstring in public nested classD107zMissing docstring in __init__D2zWhitespace IssuesD200z5One-line docstring should fit on one line with quotesz	found {0}D201z0No blank lines allowed before function docstringD202z/No blank lines allowed after function docstringD203z,1 blank line required before class docstringD204z+1 blank line required after class docstringD205z:1 blank line required between summary line and descriptionD206z2Docstring should be indented with spaces, not tabsD207zDocstring is under-indentedD208zDocstring is over-indentedD209z@Multi-line docstring closing quotes should be on a separate lineD210z1No whitespaces allowed surrounding docstring textD211z-No blank lines allowed before class docstringD212z;Multi-line docstring summary should start at the first lineD213z<Multi-line docstring summary should start at the second lineD214zSection is over-indentedz{0!r}D215z"Section underline is over-indentedzin section {0!r}D3zQuotes IssuesD300zUse """triple double quotes"""zfound {0}-quotesD301z*Use r""" if any backslashes in a docstringD302z+Deprecated: Use u""" for Unicode docstringsD4zDocstring Content IssuesD400z#First line should end with a periodz	not {0!r}D401z'First line should be in imperative moodzperhaps '{0}', not '{1}'z7First line should be in imperative mood; try rephrasingzfound '{0}'D402z3First line should not be the function's "signature"D403z;First word of the first line should be properly capitalizedz{0!r}, not {1!r}D404z0First word of the docstring should not be `This`D405z+Section name should be properly capitalizedD406z&Section name should end with a newlineD407z&Missing dashed underline after sectionD408zDSection underline should be in the line following the section's nameD409z5Section underline should match the length of its namez1Expected {0!r} dashes in section {1!r}, got {2!r}D410z Missing blank line after sectionD411z!Missing blank line before sectionD412z?No blank lines allowed between a section header and its contentD413z%Missing blank line after last sectionD414zSection has no contentD415zHFirst line should end with a period, question mark, or exclamation pointD416z$Section name should end with a colonD417z.Missing argument descriptions in the docstringz;argument(s) {0} are missing descriptions in {1!r} docstringD418zGFunction/ Method decorated with @overload shouldn't contain a docstringD419zDocstring is emptyc                       e Zd ZdedefdZy)AttrDictitemr   c                     | |   S r#   rK   )r   r   s     r   __getattr__zAttrDict.__getattr__  s    Dzr   N)rW   rX   rY   r;   r   r   rK   r   r   r   r     s      r   r   >   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   >	   r   r   r   r   r   r   r   r   r   >   r   r   r   r   r   r   r   r   r   r   r   r   )pep257numpygoogleN)QrZ   collectionsr   	functoolsr   	itertoolsr   typingr   r   r   r	   r
   parserr   utilsr   __all__r   r   r   rp   D1xxrj   r   r   r   r   r   r   r   r   D2xxr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   D3xxr   r   r   D4xxr   r   D401br   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   dictr   setrs   
all_errorsr   rK   r   r   <module>r      s   % "   : :  
3 (IJ_I _IDJ JZ !!$(<=
( 
' 
( 
* 
) 
' 
. 
#
 !!$(;<
>
 
6
 
5
 
2
 
1
 
@
 
8 
! 
  
F 
7 
3
 
A 
B 

 
( !!$8
$
 
0 
1
 !!$(BC
)
 
-
 	
=	
 
: 
A
 
6 
1
 
,
 
,
 
K
 
;7
 
&
 
'
 
E
 
+
 

 
	%  
*
 
4A 
N 
t 
 ..01
 

* 


 

E13r   