AlkantarClanX12

Your IP : 18.119.127.13


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/pydocstyle/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pydocstyle/__pycache__/checker.cpython-311.pyc

�

�܋fT���B�dZddlZddlZddlZddlmZddlmZm	Z	ddl
mZ
ddlm
Z
ddlmZdd	lmZdd
lmZmZmZmZmZmZmZmZmZmZmZmZddlm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(d
Z)dd�Z*Gd�d��Z+e��Z,						dd�Z-d�Z.d�Z/d�Z0d�Z1d�Z2dS)z5Parsed source code checkers for docstring violations.�N)�
namedtuple)�chain�	takewhile)�compile)�dedent�)�
violations)�IllegalConfiguration)�AllError�Class�
Definition�Function�Method�Module�NestedClass�NestedFunction�Package�
ParseError�Parser�StringIO)�common_prefix_length�is_blank�log�pairwise�strip_non_alphanumeric)�IMPERATIVE_BLACKLIST�IMPERATIVE_VERBS�stem)�checkFc������fd�}|S)Nc�$���|_�|_|S�N)�
_check_for�	_terminal)�f�kind�terminals ���c/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pydocstyle/checker.py�	decoratorzcheck_for.<locals>.decorator(s������������)r&r'r)s`` r(�	check_forr,'s*����������
�r*c�|�eZdZdZdZdZed��Z				d,d�Ze	d���Z
eed	�
��d���Z
eed	�
��d���Zee��d
���Zee��d���Zee��d���Zee��d���Zed���Zee��d���Zee��d���Zee��d���Zee��d���Zee��d���Zee��d���Zed���Zee��d���Zee��d���Zee��d���Z ee��d���Z!ee��d���Z"ee��d���Z#ee��d���Z$ed ���Z%e&d!���Z'e&d"���Z(e&d#���Z)ed$���Z*ed%���Z+ed&���Z,e&d'���Z-ed(���Z.d)�Z/d*�Z0ee��d+���Z1dS)-�ConventionCheckerz�Checker for PEP 257, NumPy and Google conventions.

    D10x: Missing docstrings
    D20x: Whitespace issues
    D30x: Docstring formatting
    D40x: Docstring content issues

    )
z
Short SummaryzExtended Summary�
Parameters�Returns�YieldszOther Parameters�Raises�See Also�Notes�
References�Examples�
Attributes�Methods)�Args�	Arguments�	Attentionr7�Caution�Danger�Error�Exampler6�Hint�	ImportantzKeyword ArgszKeyword Argumentsr8�Noter4�Returnr0r2r5r3�Tip�Todo�Warning�Warnings�Warns�Yieldr1z"^\s*(\w+)\s*(\(.*?\))?\s*:\n?\s*.+NFc#�6�K�|�in||_||_tt|��|��}|D]�}|jD]�}	d}
t||	j��r�|jdk}�duot�fd�|j	D����}|s|s|s|	|||j
��}
nd}
t|
d��r|
n|
g}|D]Z}
|
�V|s|
j|jvrF|	j
�d��}|\}}}|
�||���|
V�|	jrd}
n�[|
rn�ڌ�dS)NF�allc3�n�K�|]/}t��|j����dkV��0dS)rN)�len�findall�name)�.0�dec�ignore_decoratorss  �r(�	<genexpr>z1ConventionChecker.check_source.<locals>.<genexpr>�s]�����K�K���-�5�5�c�h�?�?�@�@�1�D�K�K�K�K�K�Kr*�__iter__z.
)�explanation�
definitionT)�property_decorators�ignore_self_only_init�parser�checks�
isinstancer#�skipped_error_codes�any�
decorators�	docstring�hasattr�code�__doc__�	partition�set_contextr$)�self�source�filenamerRrW�ignore_inline_noqarX�modulerV�
this_check�	terminate�skipping_all�decorator_skip�error�errorsrc�message�_rUs   `               r(�check_sourcezConventionChecker.check_source�s������&�-�B�B�3F�	
� �&;��"��x��'�'��2�2�� �!	�!	�J�"�k� 
� 
�
�!�	��j�*�*?�@�@�&�#-�#A�U�#J�L�%6�d�%B�&�s�K�K�K�K�#-�#8�K�K�K�H�H�N�
+�%�2>�%�,�%�!+�
� �*�j�.B�!�!���!%��&-�e�Z�&@�&@�M�U�U�u�g�F�!'�
&�
&�� �,�.�-�$�z��1O�O�O�(2�(:�(D�(D�U�(K�(K�I�6?�3�G�Q��!�-�-�,7�J�.����#(�K�K�K�)�3�&�,0�	� %������E���A!	�!	r*c��d�tt|�������D��}t|d����S)Nc�2�g|]}t|d���|��S)r#)r`)rPrjs  r(�
<listcomp>z,ConventionChecker.checks.<locals>.<listcomp>�s8��
�
�
���z�<�0�0�
��
�
�
r*c��|jSr")r$)rjs r(�<lambda>z*ConventionChecker.checks.<locals>.<lambda>�s��j�6J�2J�r*��key)�vars�type�values�sorted)rerKs  r(rZzConventionChecker.checks�sS��
�
�"�4��:�:�.�.�5�5�7�7�
�
�
��
�c�J�J�K�K�K�Kr*T)r'c�6�����fd�}|s��jr�ttjttjttjt|ttj
t�fd�ttj
i}|t�����SdSdS)a�D10{0,1,2,3}: Public definitions should have docstrings.

        All modules should normally have docstrings.  [...] all functions and
        classes exported by a module should also have docstrings. Public
        methods (including the __init__ constructor) should also have
        docstrings.

        Note: Public (exported) definitions are either those with names listed
              in __all__ variable (if present), or those that do not start
              with a single underscore.

        c�����jrtj��S�jr4�jrt�j��dkrdStj��S�jstj	��SdS)Nr)
�is_magicr	�D105�is_initrXrM�param_names�D107�is_overload�D102)rVres��r(�method_violationzCConventionChecker.check_docstring_missing.<locals>.method_violation�sy����"�
)�!��(�(�(��!�
)��.� ��J�2�3�3�q�8�8��4�!��(�(�(��)�
)�!��(�(�(��4r*c�<���jstj��ndSr")r�r	�D103)rVs�r(rwz;ConventionChecker.check_docstring_missing.<locals>.<lambda>�s#���%�1��J�O�-�-�-��r*N)�	is_publicrr	�D100r�D101r�D106rrr�rr�D104r{)rerVr_r��codess``   r(�check_docstring_missingz)ConventionChecker.check_docstring_missing�s�����	�	�	�	�	�	��	-�Z�1�	-��
���z���Z�_��(��
�����������E�+�5��j�)�)�*�,�,�,�	-�	-�	-�	-r*c�v�|r4ttj|����rtj��SdSdS)z�D419: Docstring is empty.

        If the user provided a docstring but it was empty, it is like they never provided one.

        NOTE: This used to report as D10X errors.

        N)r�ast�literal_evalr	�D419�rerVr_s   r(�check_docstring_emptyz'ConventionChecker.check_docstring_empty�sH���	%��#�"2�9�"=�"=�>�>�	%��?�$�$�$�	%�	%�	%�	%r*c��|rztj|���d��}t|��dkrBt	d�|D����}|dkr%tjt|����SdSdSdS)z�D200: One-liner docstrings should fit on one line with quotes.

        The closing quotes are on the same line as the opening quotes.
        This looks better for one-liners.

        �
rc3�8K�|]}t|���dV��dS)rN�r�rP�ls  r(rSz5ConventionChecker.check_one_liners.<locals>.<genexpr>s-����%J�%J�A�h�q�k�k�%J�a�%J�%J�%J�%J�%J�%Jr*N)r�r��splitrM�sumr	�D200)rerVr_�lines�non_empty_liness     r(�check_one_linersz"ConventionChecker.check_one_liners�s����	7��$�Y�/�/�5�5�d�;�;�E��5�z�z�A�~�~�"%�%J�%J��%J�%J�%J�"J�"J��"�a�'�'�%�?�3�u�:�:�6�6�6�	7�	7��~�'�'r*c#��K�|�rZ|j�|��\}}}ttt|�d��dd�����}ttt|�d��dd�����}t
ttt|������}t
tt|����}	|dkrtj|��V�t|��sH|	dkrD|	dkr"td���|��stj|	��V�dSdSdSdSdS)z�D20{1,2}: No blank lines allowed around function/method docstring.

        There's no blank line either before or after the docstring unless directly
        followed by an inner function or class.
        r�N���rrz"\s+(?:(?:class|def|async def)\s|@))rfrc�list�maprr�r�r�bool�reversedr	�D201rK�re�match�D202)
re�functionr_�beforerq�after�
blanks_before�blanks_after�blanks_before_count�blanks_after_counts
          r(�check_no_blank_beforez'ConventionChecker.check_no_blank_beforesf�����	>�'��8�8��C�C��F�A�u� ��X�v�|�|�D�/A�/A�#�2�#�/F�!G�!G�H�H�M���H�e�k�k�$�.?�.?����.C� D� D�E�E�L�"%�i��h�}�6M�6M�&N�&N�"O�"O��!$�Y�t�\�%B�%B�!C�!C��"�a�'�'� �o�&9�:�:�:�:�:��|�$�$�
>�);�q�)@�)@�
'�!�+�+��@�A�A�G�G��N�N�,�%�/�*<�=�=�=�=�=�=�=�!	>�	>�
>�
>�)@�)@�
,�+r*c#�K�|�rN|j�|��\}}}ttt|�d��dd�����}ttt|�d��dd�����}t
ttt|������}t
tt|����}	|dkrtj|��V�|dkrtj|��V�t|��s |	dkrtj|	��V�dSdSdSdS)a�D20{3,4}: Class docstring should have 1 blank line around them.

        Insert a blank line before and after all docstrings (one-line or
        multi-line) that document a class -- generally speaking, the class's
        methods are separated from each other by a single blank line, and the
        docstring needs to be offset from the first method by a blank line;
        for symmetry, put a blank line between the class header and the
        docstring.

        r�Nr�rr)rfrcr�r�rr�r�rr�r�r	�D211�D203rK�D204)
re�class_r_r�rqr�r�r�r�r�s
          r(�check_blank_before_after_classz0ConventionChecker.check_blank_before_after_classsR����(�	:�%�}�6�6�y�A�A��F�A�u� ��X�v�|�|�D�/A�/A�#�2�#�/F�!G�!G�H�H�M���H�e�k�k�$�.?�.?����.C� D� D�E�E�L�"%�i��h�}�6M�6M�&N�&N�"O�"O��!$�Y�t�\�%B�%B�!C�!C��"�a�'�'� �o�&9�:�:�:�:�:�"�a�'�'� �o�&9�:�:�:�:�:��|�$�$�
:�);�q�)@�)@� �o�&8�9�9�9�9�9�9�9�	:�	:�
:�
:�)@�)@r*c�v�|r�tj|������d��}t	|��dkrhtt
t|dd�����}ttt|����}|dkrtj|��SdSdSdS)a�D205: Put one blank line between summary line and description.

        Multi-line docstrings consist of a summary line just like a one-line
        docstring, followed by a blank line, followed by a more elaborate
        description. The summary line may be used by automatic indexing tools;
        it is important that it fits on one line and is separated from the
        rest of the docstring by a blank line.

        r�rN)
r�r��stripr�rMr�r�rr�rr�r	�D205)rerVr_r��post_summary_blanks�blanks_counts      r(�check_blank_after_summaryz+ConventionChecker.check_blank_after_summary@s����	9��$�Y�/�/�5�5�7�7�=�=�d�C�C�E��5�z�z�A�~�~�&*�3�x��q�r�r��+C�+C�&D�&D�#�"�9�T�3F�#G�#G�H�H���1�$�$�%�?�<�8�8�8�
	9�	9��~�%�$r*c�t�|j�|��\}}}|�d��\}}}|S)z9Return the indentation of the docstring's opening quotes.r�)rfrc�
rpartition)rVr_�before_docstringrq�indents     r(�_get_docstring_indentz'ConventionChecker._get_docstring_indentSs@��",�!2�!<�!<�Y�!G�!G���!�Q�'�2�2�4�8�8���1�f��
r*c#��K�|�rP|�||��}|�d���t���dk�r�fd�t���D���d��D��}t	d��t	d�|��|z��krt
j��V�t|��dkrt|dd���|kst|��d	kr!|d|krt
j	��V�t|��d	kr.t|��|krt
j
��V�dSdSdSdSdS)
z�D20{6,7,8}: The entire docstring should be indented same as code.

        The entire docstring is indented the same as the quotes at its
        first line.

        r�rc�Z��g|]'\}}|��|dz
�d���%|��(S)r�\)�endswith)rP�i�liner�s   �r(ruz2ConventionChecker.check_indent.<locals>.<listcomp>gsS��������4���"'�q�1�u��!6�!6�t�!<�!<�����r*c�J�g|] }t|���t|����!Sr+)r�
leading_spacer�s  r(ruz2ConventionChecker.check_indent.<locals>.<listcomp>ls+��N�N�N��(�1�+�+�N�=��+�+�N�N�Nr*z 	�Nr�r)r�r�rM�	enumerate�set�joinr	�D206�min�D208�D207)rerVr_r��indentsr�s     @r(�check_indentzConventionChecker.check_indentZs�������	,��/�/�
�I�F�F�F��O�O�D�)�)�E��5�z�z�A�~�~�����#,�U�#3�#3�����
O�N�U�N�N�N���u�:�:��R�W�W�W�%5�%5��%>�!?�!?�?�?�$�/�+�+�+�+�+���L�L�1�$�$��W�S�b�S�\�):�):�V�)C�)C���L�L�1�$�$����v�)=�)=�$�/�+�+�+�+�+��w�<�<�!�#�#��G���v�(=�(=�$�/�+�+�+�+�+�+�+�%	,�	,��~�$�#�(=�(=r*c��|r�d�tj|���d��D��}t|��dkrD|�d��d���dvrtj��SdSdSdS)z�D209: Put multi-line docstring closing quotes on separate line.

        Unless the entire docstring fits on a line, place the closing
        quotes on a line by themselves.

        c�0�g|]}t|���|��Sr+r�r�s  r(ruzHConventionChecker.check_newline_after_last_paragraph.<locals>.<listcomp>s4��������{�{�����r*r�rr�)�"""�'''N)r�r�r�rMr�r	�D209�rerVr_r�s    r(�"check_newline_after_last_paragraphz4ConventionChecker.check_newline_after_last_paragraphvs����	-����)�)�4�4�:�:�4�@�@����E�
�5�z�z�A�~�~��?�?�4�(�(��,�2�2�4�4�N�J�J�%�?�,�,�,�	-�	-��~�J�Jr*c��|r�tj|���d��}|d�d��s.t	|��dkr0|d�d��rt
j��SdSdSdS)z8D210: No whitespaces allowed surrounding docstring text.r�r� rN)r�r�r��
startswithrMr�r	�D210r�s    r(�check_surrounding_whitespacesz/ConventionChecker.check_surrounding_whitespaces�s����	)��$�Y�/�/�5�5�d�;�;�E��a��#�#�C�(�(�
)��u�:�:��?�?��!�H�%�%�c�*�*�#�"��(�(�(�	)�	)�#�?�?�?r*c�\�|r�gd�}tj|���d��}t|��dkrk|�d��d������}||vrt
j��St
j��SdSdS)z�D21{2,3}: Multi-line docstring summary style check.

        A multi-line docstring summary should start either at the first,
        or separately at the second line of a docstring.

        )r�r�zu"""zu'''zr"""zr'''zur"""zur'''r�rrN)	r�r�r�rMr��lowerr	�D212�D213)rerVr_�start_tripler��firsts      r(�check_multi_line_summary_startz0ConventionChecker.check_multi_line_summary_start�s����	-�	�	�	�L��$�Y�/�/�5�5�d�;�;�E��5�z�z�A�~�~�!����-�-�a�0�6�6�8�8�>�>�@�@���L�(�(�%�?�,�,�,�%�?�,�,�,�%	-�	-��~r*c�8�|r�dtj|��vrtd��}ntd��}|�|��sMtd��}|�|���d��}tj|��SdSdS)a�D300: Use """triple double quotes""".

        For consistency, always use """triple double quotes""" around
        docstrings. Use r"""raw triple double quotes""" if you use any
        backslashes in your docstrings. For Unicode docstrings, use
        u"""Unicode triple-quoted strings""".

        Note: Exception to this is made if the docstring contains
              """ quotes in its body.

        r�z[uU]?[rR]?'''[^'].*z[uU]?[rR]?"""[^"].*z[uU]?[rR]?("+|'+).*rN)r�r�r�r��groupr	�D300)rerVr_�regex�illegal_matcher�illegal_quotess      r(�check_triple_double_quotesz,ConventionChecker.check_triple_double_quotes�s����	7���(��3�3�3�3��1�2�2����1�2�2���;�;�y�)�)�
7�"$�%?�"@�"@��!0�!6�!6�y�!A�!A�!G�!G��!J�!J��!��~�6�6�6�	7�	7�
7�
7r*c��|rJtd���|��r*|�d��stj��SdSdSdS)aXD301: Use r""" if any backslashes in a docstring.

        Use r"""raw triple double quotes""" if you use any backslashes
        (\) in your docstrings.

        Exceptions are backslashes for line-continuation and unicode escape
        sequences \N... and \u... These are considered intended unescaped
        content in docstrings.
        z	\\[^\nuN])�r�urN)r��searchr�r	�D301r�s   r(�check_backslashesz#ConventionChecker.check_backslashes�sp��
�	%��<� � �'�'�	�2�2�	%��(�(��5�5�	%�
�?�$�$�$�	%�	%�	%�	%�	%�	%r*c���|retj|������d��d}|�|��s||d��SdSdS)aFirst line ends with one of `chars`.

        First line of the docstring should end with one of the characters in `chars`.
        `chars` supports either a `str` or an `Iterable[str]`. If the condition is
        evaluated to be false, it raises `violation`.

        r�rr�N)r�r�r�r�r�)r_�chars�	violation�summary_lines    r(�_check_ends_withz"ConventionChecker._check_ends_with�sz���	3��+�I�6�6�<�<�>�>�D�D�T�J�J�1�M�L��(�(��/�/�
3� �y��b�!1�2�2�2�	3�	3�
3�
3r*c�D�|�|dtj��S)z}D400: First line should end with a period.

        The [first line of a] docstring is a phrase ending in a period.

        �.)r�r	�D400r�s   r(�check_ends_with_periodz(ConventionChecker.check_ends_with_period�s���$�$�Y��Z�_�E�E�Er*c�D�|�|dtj��S)z�D415: should end with proper punctuation.

        The [first line of a] docstring is a phrase ending in a period,
        question mark, or exclamation point

        )r��!�?)r�r	�D415r�s   r(�check_ends_with_punctuationz-ConventionChecker.check_ends_with_punctuation�s%���$�$���
��
�
�	
r*c�(��|�r|js�|�|j��s�tj|�����}|r�t
|���d��}|�����tvrtj|��Stj
t�����}|rG�|vrEt|�fd����}tj|���|��SdSdSdSdSdSdS)aD401: First line should be in imperative mood: 'Do', not 'Does'.

        [Docstring] prescribes the function or method's effect as a command:
        ("Do this", "Return that"), not as a description; e.g. don't write
        "Returns the pathname ...".

        rc�$��t�|��Sr")r)r%�
check_words �r(rwz9ConventionChecker.check_imperative_mood.<locals>.<lambda>s���&:�:�q�&I�&I�r*rxN)�is_test�is_propertyrWr�r�r�rr�r�rr	�D401br�getr�max�D401�
capitalize)rer�r_�stripped�
first_word�
correct_forms�bestrs       @r(�check_imperative_moodz'ConventionChecker.check_imperative_moodsU���
�	J��$�	J��(�(��)A�B�B�	J�
�'�	�2�2�8�8�:�:�H��
J�3�H�N�N�4D�4D�Q�4G�H�H�
�'�-�-�/�/�
��!5�5�5�%�+�J�7�7�7� 0� 4�T�*�5E�5E� F� F�
� �J�Z�}�%D�%D��%�I�I�I�I����D�&�?�4�?�?�+<�+<�j�I�I�I�)	J�	J�	J�	J�	J�	J�
J�
J�J�J�%D�%Dr*c���|rrtj|������d��d}|jdz|�dd��vrt
j��SdSdS)z�D402: First line should not be function's or method's "signature".

        The one-line docstring should NOT be a "signature" reiterating the
        function/method parameters (which can be obtained by introspection).

        r�r�(r�r�N)r�r�r�r�rO�replacer	�D402)rer�r_�
first_lines    r(�check_no_signaturez$ConventionChecker.check_no_signature"s{���	)��)�)�4�4�:�:�<�<�B�B�4�H�H��K�J��}�s�"�j�&8�&8��b�&A�&A�A�A�!��(�(�(�	)�	)�A�Ar*c�P�|r�tj|�����d}||���krdS|D]}|tjvr	|dkrdS�||���kr)tj|���|��SdSdS)z�D403: First word of the first line should be properly capitalized.

        The [first line of a] docstring is a phrase ending in a period.

        rN�')	r�r�r��upper�string�
ascii_lettersrr	�D403)rer�r_r�chars     r(�check_capitalizedz#ConventionChecker.check_capitalized/s����	L��)�)�4�4�:�:�<�<�Q�?�J��Z�-�-�/�/�/�/���"�
�
���v�3�3�3������F�F���Z�2�2�4�4�4�4�!��z�'<�'<�'>�'>�
�K�K�K�	L�	L�5�4r*c�B�|r|jrtj��SdSdS)a"D418: Function decorated with @overload shouldn't contain a docstring.

        Functions that are decorated with @overload are definitions,
        and are for the benefit of the type checker only,
        since they will be overwritten by the non-@overload-decorated definition.

        N)r�r	�D418)rer�r_s   r(�check_if_neededz!ConventionChecker.check_if_needed@s8���	%��-�	%��?�$�$�$�	%�	%�	%�	%r*c��|sdStj|�����}|sdSt|���d��}|���dkrt
j��SdS)z�D404: First word of the docstring should not be `This`.

        Docstrings should use short, simple language. They should not begin
        with "This class is [..]" or "This module contains [..]".

        Nr�this)r�r�r�rr�r�r	�D404)rer�r_rrs     r(�check_starts_with_thisz(ConventionChecker.check_starts_with_thisLs����	��F��#�I�.�.�4�4�6�6���	��F�+�H�N�N�,<�,<�Q�,?�@�@�
�������'�'��?�$�$�$�(�'r*c�N���j�����j��������}|dk}gd�}t	�fd�|D����}t|��p|}|pt�j��}|o|S)aCheck if the suspected context is really a section header.

        Lets have a look at the following example docstring:
            '''Title.

            Some part of the docstring that specifies what the function
            returns. <----- Not a real section name. It has a suffix and the
                            previous line is not empty and does not end with
                            a punctuation sign.

            This is another line in the docstring. It describes stuff,
            but we forgot to add a blank line between it and the section name.
            Parameters  <-- A real section name. The previous line ends with
            ----------      a period, therefore it is in a new
                            grammatical context.
            param : int
            examples : list  <------- Not a section - previous line doesn't end
                A list of examples.   with punctuation.
            notes : list  <---------- Not a section - there's text after the
                A list of notes.      colon.

            Notes:  <--- Suspected as a context because there's a suffix to the
            -----        section, but it's a colon so it's probably a mistake.
            Bla.

            '''

        To make sure this is really a section we check these conditions:
            * There's no suffix to the section name or it's just a colon AND
            * The previous line is empty OR it ends with punctuation.

        If one of the conditions is true, we will consider the line as
        a section name.
        �:)	�,�;r��-r��/�]�}�)c3�p�K�|]0}�j����|��V��1dSr")�
previous_liner�r�)rP�x�contexts  �r(rSz:ConventionChecker._is_docstring_section.<locals>.<genexpr>�sQ�����.
�.
�:;�G�!�'�'�)�)�2�2�1�5�5�.
�.
�.
�.
�.
�.
r*)r�r��lstrip�section_namer]rr4)r6�section_name_suffix�section_suffix_is_only_colon�punctuation�prev_line_ends_with_punctuation�#this_line_looks_like_a_section_name�%prev_line_looks_like_end_of_paragraphs`      r(�_is_docstring_sectionz'ConventionChecker._is_docstring_section_s����J
�L��� � �'�'��(<�(B�(B�(D�(D�E�E�K�K�M�M�	�(;�c�'A�$�D�D�D��*-�.
�.
�.
�.
�?J�.
�.
�.
�+
�+
�'�

�(�)�)�I�-I�	,�

,�N�x��8M�/N�/N�	.�

0�
6�5�	
r*c#�jK�d}|jD]}t|��sn4|dz
}�tj|��V�tj|��V�dS|j|}d�t
|�������dk}|s6tj|��V�|dkrtj|��V�dSdS|dkrtj	|��V�|���dt|��zkrDtjt|��|t|�������V�t|��|krtj
|��V�|dz}|t|j��kr|j|}	t|	��ra|j|d�}
td�|
����stj|��V�dStj|��V�dSdStj|��V�dS)a_D4{07,08,09,12,14}, D215: Section underline checks.

        Check for correct formatting for docstring sections. Checks that:
            * The line that follows the section name contains
              dashes (D40{7,8}).
            * The amount of dashes is equal to the length of the section
              name (D409).
            * The section's content does not begin in the line that follows
              the section header (D412).
            * The section has no content (D414).
            * The indentation of the dashed line is equal to the docstring's
              indentation (D215).
        rrNr�r.)�following_linesrr	�D407�D414r�r�r��D412�D408rM�D409r��D215)�clsr8r6�indentation�blank_lines_after_headerr��non_empty_line�dash_line_found�line_after_dashes_index�line_after_dashes�
rest_of_liness           r(�#_check_blanks_and_section_underlinez5ConventionChecker._check_blanks_and_section_underline�s�����"$%� ��+�	�	�D��D�>�>�
���$��)�$�$��/�,�/�/�/�/�/��/�,�/�/�/�/�/��F� �0�1I�J���'�'�#�n�&:�&:�&<�&<�"=�"=�>�>�#�E���"	4��/�,�/�/�/�/�/�'�!�+�+� �o�l�3�3�3�3�3�3�3�,�+�(�!�+�+� �o�l�3�3�3�3�3��#�#�%�%��s�<�/@�/@�)@�@�@� �o���%�%� ���,�,�.�.�/�/�������^�,�,�{�:�:� �o�l�3�3�3�3�3�&>��&B�#�'��W�-D�)E�)E�E�E�$+�$;�+�%�!��-�.�.�<�$+�$;�/�0�0�%�M�$�B�G�G�M�$:�$:�;�;�<�(�o�l�;�;�;�;�;�;�;�(�o�l�;�;�;�;�;�;�;�<�<�!�o�l�3�3�3�3�3�3�3r*c#�NK�|�||��}|j���}|j|vr ||vrtj||j��V�t|j��|krtj|��V�|jrt|jd��s4|j
rtj|��V�ntj|��V�t|j
��stj|��V�|�|||��Ed{V��dS)a�D4{05,10,11,13}, D214: Section name checks.

        Check for valid section names. Checks that:
            * The section name is properly capitalized (D405).
            * The section is not over-indented (D214).
            * There's a blank line after the section (D410, D413).
            * There's a blank line before the section (D411).

        Also yields all the errors from `_check_blanks_and_section_underline`.
        r�N)r�r8�titler	�D405r�r��D214rAr�is_last_section�D413�D410r4�D411rP)rHr_rVr6�valid_section_namesrI�capitalized_sections       r(�_check_common_sectionz'ConventionChecker._check_common_section�sm�����/�/�
�I�F�F��%�2�8�8�:�:��
� �(;�;�;�#�':�:�:��/�"5�w�7K�L�L�L�L�L����&�&��4�4��/�"5�6�6�6�6�6��&�	;�h��#�B�'�/
�/
�	;��&�
;� �o�&9�:�:�:�:�:�:� �o�&9�:�:�:�:�:���-�.�.�	7��/�"5�6�6�6�6�6��:�:���+�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
r*c#�K�|�||��}|j���}|�||||j��Ed{V��|j����|j��}|r.tj	||j�����V�|dkr|�
|||��Ed{V��dSdS)a*D406: NumPy-style section name checks.

        Check for valid section names. Checks that:
            * The section name has no superfluous suffix to it (D406).

        Additionally, also yield all violations from `_check_common_section`
        which are style-agnostic section checks.
        Nr/)r�r8rRr[�NUMPY_SECTION_NAMESr�r�r7r	�D406�_check_parameters_section)rHr_rVr6rIrZ�suffixs       r(�_check_numpy_sectionz&ConventionChecker._check_numpy_sections$�����/�/�
�I�F�F��%�2�8�8�:�:���,�,��z�7�C�,C�
�
�	
�	
�	
�	
�	
�	
�	
���#�#�%�%�,�,�W�-A�B�B���	M��/�"5�w�|�7I�7I�7K�7K�L�L�L�L�L��,�.�.��4�4��:�w���
�
�
�
�
�
�
�
�
�/�.r*c#�K�t��}t|j��}d�|j���dd���d��}t||dd���D]�\}}t|��|kr�tt|����tt|����kr�|�	��rsd|vr|�dd��\}}	n|�	��}|�d��}
|
D])}|�
|�	�����*��t�||��Ed{V��dS)z�D417: `Parameters` section check for numpy style.

        Check for a valid `Parameters` section. Checks that:
            * The section documents all function arguments (D417)
                except `self` or `cls` if it is a method.

        r�z\
r�rNr+r,)
r�r�r�r�rArr��ziprMr��addr.�_check_missing_args)r_rVr6�docstring_args�section_level_indent�content�current_line�	next_line�
parameters�parameter_type�parameter_list�	parameters            r(r_z+ConventionChecker._check_parameters_section s���������,�W�\�:�:��
�I�I�g�-�.�.�6�6�v�r�B�B�H�H��N�N�	�(+�7�G�A�B�B�K�'@�'@�	:�	:�#�L�)��|�,�,�0D�D�D��
�i�0�0�1�1��-��5�5�6�6�7�7��O�O�%�%�7��,�&�&�1=�1C�1C�C��1K�1K�.�J���".�!3�!3�!5�!5�J�",�!1�!1�#�!6�!6��!/�:�:�I�"�&�&�y���'8�'8�9�9�9�9��$�8�8��J�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
r*c#���
K�t��}|jr7|jd}|dt|�������
t	d��
fd�|jD���������}g}|�d���D]D}|dd����s|�	|���4|dxx|z
cc<�E|D]K}tj�|��}	|	r(|�
|	�d�����Lt�||��Ed{V��dS)	aD417: `Args` section checks.

        Check for a valid `Args` or `Argument` section. Checks that:
            * The section documents all function arguments (D417)
                except `self` or `cls` if it is a method.

        Documentation for each arg should start at the same indentation
        level. For example, in this case x and y are distinguishable::

            Args:
                x: Lorem ipsum dolor sit amet
                y: Ut enim ad minim veniam

        In the case below, we only recognize x as a documented parameter
        because the rest of the content is indented as if it belongs
        to the description for x::

            Args:
                x: Lorem ipsum dolor sit amet
                    y: Ut enim ad minim veniam
        rNr�c�J��g|]}|����s|dk�|�� S)r��r�)rPr��leading_whitespacess  �r(ruz9ConventionChecker._check_args_section.<locals>.<listcomp>qsC����������':�;�;��@D�r�z�z��?I�z�zr*T)�keependsrr�)r�rArMr7rr�r��
splitlines�isspace�appendr.�GOOGLE_ARGS_REGEXr�rdr�re)r_rVr6rfr�args_content�
args_sectionsr��sectionr�rrs          @r(�_check_args_sectionz%ConventionChecker._check_args_sectionPs������.�����"�	J� �0��3�J�",�-H��J�4E�4E�4G�4G�0H�0H�/H�-H�"I����I�I����� '� 7����
�
�
�
��%�'�'�	��
� �+�+�T�+�:�:�	*�	*�D�����8�#�#�%�%�
*��$�$�T�*�*�*�*��b�!�!�!�T�)�!�!�!�!�$�	3�	3�G�%�7�=�=�g�F�F�E��
3��"�"�5�;�;�q�>�>�2�2�2��$�8�8��J�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
r*c#�TK�t|t��r�t|j��}|jdkr|js
|dd�}d�|D��}t
|��|z
}|r@tjd�	t|����|j��V�dSdSdS)a3D417: Yield error for missing arguments in docstring.

        Given a list of arguments found in the docstring and the
        callable definition, it checks if all the arguments of the
        callable are present in the docstring, else it yields a
        D417 with a list of missing arguments.

        �methodrNc�0�g|]}t|���|��Sr+)�is_def_arg_private)rP�arg_names  r(ruz9ConventionChecker._check_missing_args.<locals>.<listcomp>�s6������)�(�3�3�����r*z, )r[r�get_function_argsrfr&�	is_staticr�r	�D417r�r}rO)rfrV�
function_args�missing_argss    r(rez%ConventionChecker._check_missing_args�s������j�(�+�+�	�-�j�.?�@�@�M���(�*�*�:�3G�*� -�a�b�b� 1�
��� -����M�
�}�-�-��>�L��
� �o��I�I�f�\�2�2�3�3�Z�_��������	�	�
�
r*c#�K�|j���}|�||||j��Ed{V��|j����|j��}|dkr1tj|dz|j�����V�|dvr|�	|||��Ed{V��dSdS)a�D416: Google-style section name checks.

        Check for valid section names. Checks that:
            * The section does not contain any blank line between its name
              and content (D412).
            * The section is not empty (D414).
            * The section name has colon as a suffix (D416).

        Additionally, also yield all violations from `_check_common_section`
        which are style-agnostic section checks.
        Nr+)r9r:)
r8rRr[�GOOGLE_SECTION_NAMESr�r�r7r	�D416r{)rHr_rVr6rZr`s      r(�_check_google_sectionz'ConventionChecker._check_google_section�s
����&�2�8�8�:�:���,�,��z�7�C�,D�
�
�	
�	
�	
�	
�	
�	
�	
���#�#�%�%�,�,�W�-A�B�B���S�=�=��/�#�c�)�7�<�+=�+=�+?�+?���
�
�
��"7�7�7��.�.�y�*�g�N�N�N�N�N�N�N�N�N�N�N�8�7r*c
#�r����	K�d�|D���	�	fd���fd�t���D��}tdd�����fd�|D��}d�|D��}t|d��D]H\}}|�d	n|j}�|j|j|j�|jd
z|�|j|du��V��IdS)aGenerate `SectionContext` objects for valid sections.

        Given a list of `valid_section_names`, generate an
        `Iterable[SectionContext]` which provides:
            * Section Name
            * String value of the previous line
            * The section line
            * Following lines till the next section
            * Line index of the beginning of the section in the docstring
            * Boolean indicating whether the section is the last section.
        for each valid section.

        c�6�g|]}|�����Sr+)r�)rP�ss  r(ruz;ConventionChecker._get_section_contexts.<locals>.<listcomp>�s ��F�F�F�Q�q�w�w�y�y�F�F�Fr*c�N��t|�����}|�vSr")�get_leading_wordsr�)�_line�result�lower_section_namess  �r(�_suspected_as_sectionzFConventionChecker._get_section_contexts.<locals>._suspected_as_section�s$���&�u�{�{�}�}�5�5�F��0�0�0r*c�0��g|]\}}�|���|��Sr+r+)rPr�r�r�s   �r(ruz;ConventionChecker._get_section_contexts.<locals>.<listcomp>�s>���%
�%
�%
��!�T�1F�1F�t�1L�1L�%
�
�%
�%
�%
r*�SectionContext)r8r4r�rA�original_indexrUc	3��K�|]S}�t�|������|dz
�|�|dzd�|d��V��TdS)rNF)r�r�)rPr�r�r�s  ��r(rSz:ConventionChecker._get_section_contexts.<locals>.<genexpr>�s������

�

��
�N�!�%��(�.�.�"2�"2�3�3��a�!�e���a���a�!�e�g�g����

�
�

�

�

�

�

�

r*c3�NK�|] }t�|���|V��!dSr")r.r?)rP�cs  r(rSz:ConventionChecker._get_section_contexts.<locals>.<genexpr>�sJ����
�
��#4�#J�#J�1�#M�#M�
�
�
�
�
�
�
�
r*Nr�r)r�rrr�r8r4r�)
r�rY�suspected_section_indices�contexts�a�b�endr�r�r�s
`      @@@r(�_get_section_contextsz'ConventionChecker._get_section_contexts�s_��������G�F�2E�F�F�F��	1�	1�	1�	1�	1�
%
�%
�%
�%
�&�u�-�-�%
�%
�%
�!�$��
�

�

��

�

�

�

�

�/�

�

�

��
�
��
�
�
���X�t�,�,�		�		�D�A�q��	�"�"�q�'7�C� �.��������a�&��*�S�0�1�� ��T�	�
��
�
�
�
�		�		r*c#�K�d}|�||j��D]!}d}|�|||��Ed{V���"|S)a�NumPy-style docstring sections checks.

        Check the general format of a sectioned docstring:
            '''This is my one-liner.

            Short Summary
            -------------
            This is my summary.

            Returns
            -------
            None.

            '''

        Section names appear in `NUMPY_SECTION_NAMES`.
        Yields all violation from `_check_numpy_section` for each valid
        Numpy-style section.
        FTN)r�r]ra)rer�rVr_�found_any_numpy_section�ctxs      r(�_check_numpy_sectionsz'ConventionChecker._check_numpy_sections	sk����(#(���-�-�e�T�5M�N�N�	M�	M�C�&*�#��0�0��J��L�L�L�L�L�L�L�L�L�L�&�&r*c#�K�|�||j��D]}|�|||��Ed{V��� dS)a�Google-style docstring section checks.

        Check the general format of a sectioned docstring:
            '''This is my one-liner.

            Note:
                This is my summary.

            Returns:
                None.

            '''

        Section names appear in `GOOGLE_SECTION_NAMES`.
        Yields all violation from `_check_google_section` for each valid
        Google-style section.
        N)r�r�r�)rer�rVr_r�s     r(�_check_google_sectionsz(ConventionChecker._check_google_sections$sl����$�-�-��4�,�
�
�	N�	N�C��1�1�)�Z��M�M�M�M�M�M�M�M�M�M�	N�	Nr*c#��K�|sdS|�d��}t|��dkrdS|�|||��Ed{V��}|s|�|||��Ed{V��dSdS)zCheck for docstring sections.Nr��)r�rMr�r�)rerVr_r��found_numpys     r(�check_docstring_sectionsz*ConventionChecker.check_docstring_sections;s������	��F�����%�%���u�:�:��>�>��F�!%�!;�!;��:�y�"
�"
�
�
�
�
�
�
���	��2�2��z�9���
�
�
�
�
�
�
�
�
�	�	r*)NNFF)2�__name__�
__module__�__qualname__rbr]r�r�rwrr�propertyrZr,r
r�r�r�rr�rr�r��staticmethodr�r�r�r�r�r�r�r�rrrrr"r%r)r?�classmethodrPr[rar_r{rer�r�r�r�r�r+r*r(r.r.0s����������� ��H��	
����4� � �#�/�/�/�/�b�L�L��X�L��Y�z�D�)�)�)�*-�*-�*�)�*-�X�Y�z�D�)�)�)�	%�	%�*�)�	%��Y�z���7�7���7��Y�x���>�>���>�0�Y�u���:�:���:�@�Y�z���9�9���9�$����\���Y�z���,�,���,�6�Y�z���-�-���-�"�Y�z���	)�	)���	)��Y�z���-�-���-�6�Y�z���7�7���7�4�Y�z���%�%���%�(�3�3��\�3��Y�z���F�F���F��Y�z���	
�	
���	
��Y�x���J�J���J�<�Y�x���
)�
)���
)��Y�x���L�L���L� �Y�x���	%�	%���	%��Y�z���%�%���%�$�9
�9
��\�9
�v�A4�A4��[�A4�F�&
�&
��[�&
�P����[��.�-
�-
��\�-
�^�9
�9
��\�9
�v����\��8�O�O��[�O�2�C�C��\�C�J'�'�'�6N�N�N�.�Y�z���������r*r.c	#��K�|�|�td���|�|}n\|�Itttj�����t|��z
��}ntjj}|D]�}tj	d|��	tj|��5}	|	���}
ddd��n#1swxYwYt���|
|||||��D]}t|dd��}||vr|V����#t t"t$f$r$}tjd||��|V�Yd}~��d}~wtj$rt+d|z��V�Y��wxYwdS)a�Generate docstring errors that exist in `filenames` iterable.

    By default, the PEP-257 convention is checked. To specifically define the
    set of error codes to check for, supply either `select` or `ignore` (but
    not both). In either case, the parameter should be a collection of error
    code strings, e.g., {'D100', 'D404'}.

    When supplying `select`, only specified error codes will be reported.
    When supplying `ignore`, all error codes which were not specified will be
    reported.

    Note that ignored error code refer to the entire set of possible
    error codes, which is larger than just the PEP-257 convention. To your
    convenience, you may use `pydocstyle.violations.conventions.pep257` as
    a base set to add or remove errors from.

    `ignore_inline_noqa` controls if `# noqa` comments are respected or not.

    `ignore_self_only_init` controls if D107 is reported on __init__ only containing `self`.

    Examples
    ---------
    >>> check(['pydocstyle.py'])
    <generator object check at 0x...>

    >>> check(['pydocstyle.py'], select=['D100'])
    <generator object check at 0x...>

    >>> check(['pydocstyle.py'], ignore=conventions.pep257 - {'D100'})
    <generator object check at 0x...>

    Nz@Cannot pass both select and ignore. They are mutually exclusive.zChecking file %s.razError in file %s: %szinvalid syntax in file %s)r
r�r�r	�
ErrorRegistry�get_error_codes�conventions�pep257r�info�tk�open�readr.rr�getattr�OSErrorrr�warning�
TokenError�SyntaxError)
�	filenames�select�ignorerRrWrhrX�
checked_codesrg�filerfrnras
             r(rrQs����R��f�0�"�
+�
�
�	
�
�	��
�
�	�	���
�(�8�8�:�:�;�;�c�&�k�k�I�
�
�
�
�#�.�5�
��F�F����$�h�/�/�/�	F����"�"�
%�d�������
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%�*�,�,�9�9���!�#�"�%�
��

 �

 ���u�f�d�3�3���=�(�(��K�K�K��

 ����:�.�	�	�	��K�.��%�@�@�@��K�K�K�K�K�K�K�K������}�	F�	F�	F��9�H�D�E�E�E�E�E�E�E�	F����'F�FsC�D�%C�:D�C
	�
D�
C
	�AD�E3�+E
�
&E3�2E3c�4�td�|D����S)zBReturn a boolean indicating if `string` only has ascii characters.c3�<K�|]}t|��dkV��dS)�N)�ord)rPr!s  r(rSzis_ascii.<locals>.<genexpr>�s,����2�2�4�s�4�y�y�3��2�2�2�2�2�2r*)rK�rs r(�is_asciir��s���2�2�6�2�2�2�2�2�2r*c�j�td���|�����S)z'Return any leading space from `string`.z\s*)r�r�r�r�s r(r�r��s(��
�f�:�:���F�#�#�)�)�+�+�+r*c��td���|�����}|�|���SdS)z{Return any leading set of words from `line`.

    For example, if `line` is "  Hello world!!!", returns "Hello world".
    z[\w ]+N)r�r�r�r�)r�r�s  r(r�r��sA��
�	�]�]�
 �
 ������
.�
.�F�
���|�|�~�~���r*c�,�|�d��S)z<Return a boolean indicating if the argument name is private.rqrq)r�s r(rr�s�����s�#�#�#r*c���	tj|�����jdj}n#t
$rgcYSwxYw|j}|j}d�t||��D��S)z;Return the function arguments given the source-code string.rc��g|]	}|j��
Sr+)�arg)rP�arg_nodes  r(ruz%get_function_args.<locals>.<listcomp>�s��L�L�L�X�H�L�L�L�Lr*)r�rYr7�body�argsr��
kwonlyargsr)�function_source�function_arg_node�	arg_nodes�kwonly_arg_nodess    r(r�r��s�����I�o�&<�&<�&>�&>�?�?�D�Q�G�L���������	�	�	�����"�&�I�(�3��L�L��y�:J�)K�)K�L�L�L�Ls�69�A�A)F)NNNNFF)3rbr�r�tokenizer��collectionsr�	itertoolsrrr�r�textwraprr�r	�configr
�parserrrr
rrrrrrrrr�utilsrrrrr�	wordlistsrrr�__all__r,r.rYrr�r�r�rr�r+r*r(�<module>r�sp��;�;�
�
�
�
�
�
�
�
�����"�"�"�"�"�"�&�&�&�&�&�&�&�&�������������������(�(�(�(�(�(�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
���������������D�C�C�C�C�C�C�C�C�C�
������[�[�[�[�[�[�[�[�| 	�����
������KF�KF�KF�KF�\3�3�3�
,�,�,�
���$�$�$�
M�M�M�M�Mr*