o
    bR                     @   sd   d Z ddlmZmZmZ ddlZddlZddlZddlm	Z	m
Z
mZ ddlmZ G dd de	ZdS )zUnit tests for the pylint checkers in :mod:`pylint.extensions.check_docs`,
in particular the parameter documentation checker `DocstringChecker`
    )divisionprint_functionabsolute_importN)CheckerTestCaseMessage
set_config)DocstringParameterCheckerc                   @   s,  e Zd ZdZeZddi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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d0d1 Zd2d3 Zd4d5 Zd6d7 Z d8d9 Z!d:d; Z"d<d= Z#d>d? Z$d@dA Z%dBdC Z&dDdE Z'dFdG Z(dHdI Z)dJdK Z*dLdM Z+dNdO Z,dPdQ Z-e.j/j0e1j2dR dSkdTdUdVdW Z3dXdY Z4dZd[ Z5d\d] Z6d^d_ Z7d`da Z8dbdc Z9ddde Z:dfdg Z;dhdi Z<djdk Z=dldm Z>dndo Z?dpdq Z@drds ZAg dtZBeBg du ZCe.j/DdveCdwdx ZEe.j/DdveCdydz ZFe.j/DdveCd{d| ZGe.j/Dd}eBd~d ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZMdd ZNdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z]dd Z^dS )TestParamDocCheckerz'Tests for pylint_plugin.ParamDocCheckeraccept_no_param_docFc                 C   \   t d}| td|ddtd|dd | j| W d   dS 1 s'w   Y  dS )zcExample of a function with missing Sphinx parameter documentation in
        the docstring
        z
        def function_foo(x, y, z):
            '''docstring ...

            :param x: bla

            :param int z: bar
            '''
            pass
        missing-param-docymsg_idnodeargsmissing-type-doczx, yNastroidextract_nodeassertAddsMessagesr   checkervisit_functiondefselfr    r   e/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/test/extensions/test_check_docs.py,test_missing_func_params_in_sphinx_docstring&   s   


"z@TestParamDocChecker.test_missing_func_params_in_sphinx_docstringc                 C   r   )ziExample of a function with missing Google style parameter
        documentation in the docstring
        z
        def function_foo(x, y, z):
            '''docstring ...

            Args:
                x: bla
                z (int): bar

            some other stuff
            '''
            pass
        r   r   r   r   r   Nr   r   r   r   r   ,test_missing_func_params_in_google_docstring@   s   

"z@TestParamDocChecker.test_missing_func_params_in_google_docstringc                 C   D   t d}|   | j| W d   dS 1 sw   Y  dS )jExample of a function with missing Google style parameter
        documentation in the docstring.
        z
        def function_foo(x: int, y: bool, z):
            '''docstring ...

            Args:
                x: bla
                y: blah blah
                z (int): bar

            some other stuff
            '''
            pass
        Nr   r   assertNoMessagesr   r   r   r   r   r   =test_missing_func_params_with_annotations_in_google_docstring\      

"zQTestParamDocChecker.test_missing_func_params_with_annotations_in_google_docstringc                 C   r!   )r"   z
        def function_foo(x: int, y: bool, z: int = 786):
            '''docstring ...

            Args:
                x: bla
                y: blah blah
                z: bar

            some other stuff
            '''
            pass
        Nr#   r   r   r   r   5test_default_arg_with_annotations_in_google_docstringp   r&   zITestParamDocChecker.test_default_arg_with_annotations_in_google_docstringc                 C   sP   t d}| td|dd | j| W d   dS 1 s!w   Y  dS )r"   z
        def function_foo(x, y: bool, z):
            '''docstring ...

            Args:
                x: bla
                y: blah blah
                z (int): bar

            some other stuff
            '''
            pass
        r   xr   Nr   r   r   r   r   Etest_missing_func_params_with_partial_annotations_in_google_docstring   s   
"zYTestParamDocChecker.test_missing_func_params_with_partial_annotations_in_google_docstringc                 C   r!   )r"   a*  
        def area(bottomleft: Point, topright: Point) -> float:
            '''Calculate area of fake rectangle.
                Args:
                    bottomleft: bottom left point of rectangle
                    topright: top right point of rectangle
            '''
            pass
        Nr#   r   r   r   r   0test_non_builtin_annotations_in_google_docstring      

	"zDTestParamDocChecker.test_non_builtin_annotations_in_google_docstringc                 C   r!   )r"   a6  
        def get_midpoint(bottomleft: Point, topright: Point) -> Point:
            '''Calculate midpoint of fake rectangle.
                Args:
                    bottomleft: bottom left point of rectangle
                    topright: top right point of rectangle
            '''
            pass
        Nr#   r   r   r   r   ?test_non_builtin_annotations_for_returntype_in_google_docstring   r,   zSTestParamDocChecker.test_non_builtin_annotations_for_returntype_in_google_docstringc                 C   r!   )zuExample of a function with Google style parameter splitted
        in Args and Keyword Args in the docstring
        aV  
        def my_func(this, other, that=True):
            '''Prints this, other and that

                Args:
                    this (str): Printed first
                    other (int): Other args

                Keyword Args:
                    that (bool): Printed second
            '''
            print(this, that, other)
        Nr#   r   r   r   r   7test_func_params_and_keyword_params_in_google_docstring   r&   zKTestParamDocChecker.test_func_params_and_keyword_params_in_google_docstringc              
   C   st   t d}| td|ddtd|ddtd|ddtd|dd | j| W d	   d	S 1 s3w   Y  d	S )
zExample of a function with Google style parameter splitted
        in Args and Keyword Args in the docstring but with wrong keyword args
        aW  
        def my_func(this, other, that=True):
            '''Prints this, other and that

                Args:
                    this (str): Printed first
                    other (int): Other args

                Keyword Args:
                    these (bool): Printed second
            '''
            print(this, that, other)
        r   )thatr   r   differing-param-doc)Zthesediffering-type-docNr   r   r   r   r   =test_func_params_and_wrong_keyword_params_in_google_docstring   s2   
"zQTestParamDocChecker.test_func_params_and_wrong_keyword_params_in_google_docstringc                 C   r   )zhExample of a function with missing NumPy style parameter
        documentation in the docstring
        a  
        def function_foo(x, y, z):
            '''docstring ...

            Parameters
            ----------
            x:
                bla
            z: int
                bar

            some other stuff
            '''
            pass
        r   r   r   r   r   Nr   r   r   r   r   +test_missing_func_params_in_numpy_docstring   s   

"z?TestParamDocChecker.test_missing_func_params_in_numpy_docstringT)r
   c                 C   r!   )zkExample of a function with no parameter documentation at all

        No error message is emitted.
        
        def function_foo(x, y):
            '''docstring ...

            missing parameter documentation'''
            pass
        Nr#   r   r   r   r   +test_tolerate_no_param_documentation_at_all  s   

"z?TestParamDocChecker.test_tolerate_no_param_documentation_at_allc                 C   s\   t d}| td|ddtd|dd | j| W d   dS 1 s'w   Y  dS )z~Example of a function with no parameter documentation at all

        Missing documentation error message is emitted.
        r4   r   r   r   r   Nr   r   r   r   r   1test_don_t_tolerate_no_param_documentation_at_all%  s   

"zETestParamDocChecker.test_don_t_tolerate_no_param_documentation_at_allc                 C   r!   )zgExample for the usage of "For the parameters, see"
        to suppress missing-param warnings.
        z
        def function_foo(x, y):
            '''docstring ...

            For the parameters, see :func:`blah`
            '''
            pass
        Nr#   r   r   r   r   /test_see_tolerate_no_param_documentation_at_all=  s   

"zCTestParamDocChecker.test_see_tolerate_no_param_documentation_at_allc                 C   s2   |j D ]}t|tjrt|dr| j| qdS )zVisit all methods of a class node

        :param node: class node
        :type node: :class:`astroid.scoped_nodes.Class`
        nameN)body
isinstancer   FunctionDefhasattrr   r   )r   r   Z	body_itemr   r   r   _visit_methods_of_classL  s   
z+TestParamDocChecker._visit_methods_of_classc                 C   d   t d}|jd }| td|ddtd|dd | | W d   dS 1 s+w   Y  dS )	zmExample of a class method with missing parameter documentation in
        the Sphinx style docstring
        z
        class Foo(object):
            def method_foo(self, x, y):
                '''docstring ...

                missing parameter documentation

                :param x: bla
                '''
                pass
        r   r   r   r   r   r   Nr   r   r9   r   r   r=   r   r   Zmethod_noder   r   r   .test_missing_method_params_in_sphinx_docstringW  s    


"zBTestParamDocChecker.test_missing_method_params_in_sphinx_docstringc                 C   r>   )	zmExample of a class method with missing parameter documentation in
        the Google style docstring
        z
        class Foo(object):
            def method_foo(self, x, y):
                '''docstring ...

                missing parameter documentation

                Args:
                    x: bla
                '''
                pass
        r   r   r   r   r   r   Nr?   r@   r   r   r   .test_missing_method_params_in_google_docstrings  s    


"zBTestParamDocChecker.test_missing_method_params_in_google_docstringc                 C   r>   )	zlExample of a class method with missing parameter documentation in
        the Numpy style docstring
        a)  
        class Foo(object):
            def method_foo(self, x, y):
                '''docstring ...

                missing parameter documentation

                Parameters
                ----------
                x:
                    bla
                '''
                pass
        r   r   r   r   r   r   Nr?   r@   r   r   r   -test_missing_method_params_in_numpy_docstring  s    


"zATestParamDocChecker.test_missing_method_params_in_numpy_docstringc                 C   r!   )zlExample of a function with correctly documented parameters and
        return values (Sphinx style)
        a  
        def function_foo(xarg, yarg, zarg, warg):
            '''function foo ...

            :param xarg: bla xarg
            :type xarg: int

            :parameter yarg: bla yarg
            :type yarg: my.qualified.type

            :arg int zarg: bla zarg

            :keyword my.qualified.type warg: bla warg

            :return: sum
            :rtype: float
            '''
            return xarg + yarg
        Nr#   r   r   r   r   -test_existing_func_params_in_sphinx_docstring  s   

"zATestParamDocChecker.test_existing_func_params_in_sphinx_docstringc                 C   r!   )zlExample of a function with correctly documented parameters and
        return values (Google style)
        a  
        def function_foo(xarg, yarg, zarg, warg):
            '''function foo ...

            Args:
                xarg (int): bla xarg
                yarg (my.qualified.type): bla
                    bla yarg

                zarg (int): bla zarg
                warg (my.qualified.type): bla warg

            Returns:
                float: sum
            '''
            return xarg + yarg
        Nr#   r   r   r   r   -test_existing_func_params_in_google_docstring  s   

"zATestParamDocChecker.test_existing_func_params_in_google_docstringc                 C   r!   )zkExample of a function with correctly documented parameters and
        return values (Numpy style)
        a  
        def function_foo(xarg, yarg, zarg, warg):
            '''function foo ...

            Parameters
            ----------
            xarg: int
                bla xarg
            yarg: my.qualified.type
                bla yarg

            zarg: int
                bla zarg
            warg: my.qualified.type
                bla warg

            Returns
            -------
            float
                sum
            '''
            return xarg + yarg
        Nr#   r   r   r   r   ,test_existing_func_params_in_numpy_docstring  s   

"z@TestParamDocChecker.test_existing_func_params_in_numpy_docstringc              
   C   s   t d}| td|ddtd|ddtd|ddtd	|d
d | j| W d   n1 s2w   Y  t d}| td|ddtd	|dd | j| W d   dS 1 s^w   Y  dS )z~Example of functions with inconsistent parameter names in the
        signature and in the Sphinx style documentation
        a.  
        def function_foo(xarg, yarg, zarg):
            '''function foo ...

            :param xarg1: bla xarg
            :type xarg: int

            :param yarg: bla yarg
            :type yarg1: float

            :param str zarg1: bla zarg
            '''
            return xarg + yarg
        r   z
xarg, zargr   r   )z
yarg, zargr0   zxarg1, zarg1r1   )zyarg1, zarg1Nz
        def function_foo(xarg, yarg):
            '''function foo ...

            :param yarg1: bla yarg
            :type yarg1: float

            For the other parameters, see bla.
            '''
            return xarg + yarg
        Zyarg1r   r   r   r   r   2test_wrong_name_of_func_params_in_sphinx_docstring  sP   


"zFTestParamDocChecker.test_wrong_name_of_func_params_in_sphinx_docstringc              
   C      t d}| td|ddtd|ddtd|ddtd|dd | j| W d	   n1 s2w   Y  t d
}| td|ddtd|dd | j| W d	   d	S 1 s^w   Y  d	S )z~Example of functions with inconsistent parameter names in the
        signature and in the Google style documentation
        a  
        def function_foo(xarg, yarg, zarg):
            '''function foo ...

            Args:
                xarg1 (int): bla xarg
                yarg (float): bla yarg

                zarg1 (str): bla zarg
            '''
            return xarg + yarg
        r   rG   r   r   r0   rH   r1   Nz
        def function_foo(xarg, yarg):
            '''function foo ...

            Args:
                yarg1 (float): bla yarg

            For the other parameters, see bla.
            '''
            return xarg + yarg
        rI   r   r   r   r   r   2test_wrong_name_of_func_params_in_google_docstring<  sP   


"zFTestParamDocChecker.test_wrong_name_of_func_params_in_google_docstringc              
   C   rK   )z}Example of functions with inconsistent parameter names in the
        signature and in the Numpy style documentation
        aE  
        def function_foo(xarg, yarg, zarg):
            '''function foo ...

            Parameters
            ----------
            xarg1: int
                bla xarg
            yarg: float
                bla yarg

            zarg1: str
                bla zarg
            '''
            return xarg + yarg
        r   rG   r   r   r0   rH   r1   Na  
        def function_foo(xarg, yarg):
            '''function foo ...

            Parameters
            ----------
            yarg1: float
                bla yarg

            For the other parameters, see bla.
            '''
            return xarg + yarg
        rI   r   r   r   r   r   1test_wrong_name_of_func_params_in_numpy_docstringw  sP   


"zETestParamDocChecker.test_wrong_name_of_func_params_in_numpy_docstringc                 C   r!   )zExample for the usage of "For the other parameters, see" to avoid
        too many repetitions, e.g. in functions or methods adhering to a
        given interface (Sphinx style)
        z
        def function_foo(xarg, yarg):
            '''function foo ...

            :param yarg: bla yarg
            :type yarg: float

            For the other parameters, see :func:`bla`
            '''
            return xarg + yarg
        Nr#   r   r   r   r   5test_see_sentence_for_func_params_in_sphinx_docstring     

"zITestParamDocChecker.test_see_sentence_for_func_params_in_sphinx_docstringc                 C   r!   )zExample for the usage of "For the other parameters, see" to avoid
        too many repetitions, e.g. in functions or methods adhering to a
        given interface (Google style)
        z
        def function_foo(xarg, yarg):
            '''function foo ...

            Args:
                yarg (float): bla yarg

            For the other parameters, see :func:`bla`
            '''
            return xarg + yarg
        Nr#   r   r   r   r   5test_see_sentence_for_func_params_in_google_docstring  rO   zITestParamDocChecker.test_see_sentence_for_func_params_in_google_docstringc                 C   r!   )zExample for the usage of "For the other parameters, see" to avoid
        too many repetitions, e.g. in functions or methods adhering to a
        given interface (Numpy style)
        a  
        def function_foo(xarg, yarg):
            '''function foo ...

            Parameters
            ----------
            yarg: float
                bla yarg

            For the other parameters, see :func:`bla`
            '''
            return xarg + yarg
        Nr#   r   r   r   r   4test_see_sentence_for_func_params_in_numpy_docstring  s   

"zHTestParamDocChecker.test_see_sentence_for_func_params_in_numpy_docstringc                 C   Z   t d}| td|ddtd|dd | | W d   dS 1 s&w   Y  dS )Example of a class with missing constructor parameter documentation
        (Sphinx style)

        Everything is completely analogous to functions.
        z
        class ClassFoo(object):
            '''docstring foo

            :param y: bla
            
            missing constructor parameter documentation
            '''

            def __init__(self, x, y):
                pass

        r   r(   r   r   r   Nr   r   r   r   r=   r   r   r   r   "test_constr_params_in_class_sphinx  s   

"z6TestParamDocChecker.test_constr_params_in_class_sphinxc                 C   rR   )Example of a class with missing constructor parameter documentation
        (Google style)

        Everything is completely analogous to functions.
        a  
        class ClassFoo(object):
            '''docstring foo

            Args:
                y: bla
            
            missing constructor parameter documentation
            '''

            def __init__(self, x, y):
                pass

        r   r(   r   r   r   NrT   r   r   r   r   "test_constr_params_in_class_google  s   

"z6TestParamDocChecker.test_constr_params_in_class_googlec                 C   rR   )Example of a class with missing constructor parameter documentation
        (Numpy style)

        Everything is completely analogous to functions.
        a*  
        class ClassFoo(object):
            '''docstring foo

            Parameters
            ----------
            y:
                bla
            
            missing constructor parameter documentation
            '''

            def __init__(self, x, y):
                pass

        r   r(   r   r   r   NrT   r   r   r   r   !test_constr_params_in_class_numpy2  s   

"z5TestParamDocChecker.test_constr_params_in_class_numpyc                 C   B   t d}|   | | W d   dS 1 sw   Y  dS )z|Example of a class with correct constructor parameter documentation
        and an attributes section (Numpy style)
        aM  
        class ClassFoo(object):
            '''
            Parameters
            ----------
            foo : str
                Something.

            Attributes
            ----------
            bar : str
                Something.
            '''
            def __init__(self, foo):
                self.bar = None
        Nr   r   r$   r=   r   r   r   r   0test_constr_params_and_attributes_in_class_numpyT  s   

"zDTestParamDocChecker.test_constr_params_and_attributes_in_class_numpyc                 C   r>   )	rS   a  
        class ClassFoo(object):
            def __init__(self, x, y):
                '''docstring foo constructor

                :param y: bla

                missing constructor parameter documentation
                '''

                pass

        r   r   r(   r   r   r   Nr?   r   r   Zconstructor_noder   r   r   !test_constr_params_in_init_sphinxk      


"z5TestParamDocChecker.test_constr_params_in_init_sphinxc                 C   r>   )	rV   a  
        class ClassFoo(object):
            def __init__(self, x, y):
                '''docstring foo constructor

                Args:
                    y: bla

                missing constructor parameter documentation
                '''
                pass

        r   r   r(   r   r   r   Nr?   r]   r   r   r   !test_constr_params_in_init_google  r_   z5TestParamDocChecker.test_constr_params_in_init_googlec                 C   r>   )	rX   aE  
        class ClassFoo(object):
            def __init__(self, x, y):
                '''docstring foo constructor

                Parameters
                ----------
                y:
                    bla

                missing constructor parameter documentation
                '''
                pass

        r   r   r(   r   r   r   Nr?   r]   r   r   r    test_constr_params_in_init_numpy  s    


"z4TestParamDocChecker.test_constr_params_in_init_numpyc                 C   rZ   )z=Example usage of "For the parameters, see" in class docstringz
        class ClassFoo(object):
            '''docstring foo

            For the parameters, see :func:`bla`
            '''

            def __init__(self, x, y):
                '''init'''
                pass

        Nr[   r   r   r   r   ,test_see_sentence_for_constr_params_in_class     

"z@TestParamDocChecker.test_see_sentence_for_constr_params_in_classc                 C   rZ   )z<Example usage of "For the parameters, see" in init docstringz
        class ClassFoo(object):
            '''foo'''

            def __init__(self, x, y):
                '''docstring foo constructor

                For the parameters, see :func:`bla`
                '''
                pass

        Nr[   r   r   r   r   +test_see_sentence_for_constr_params_in_init  rc   z?TestParamDocChecker.test_see_sentence_for_constr_params_in_initc                 C      t d}|jd }| td||jfdtd|ddtd|ddtd|ddtd|dd | | W d	   d	S 1 s?w   Y  d	S )
zExample of a class with missing constructor parameter documentation
        in both the init docstring and the class docstring
        (Sphinx style)

        Everything is completely analogous to functions.
        ay  
        class ClassFoo(object):
            '''docstring foo

            :param y: None

            missing constructor parameter documentation
            '''

            def __init__(self, x, y):
                '''docstring foo

                :param y: bla

                missing constructor parameter documentation
                '''
                pass

        r   multiple-constructor-docr   r   r(   r   r   Nr   r   r9   r   r   r8   r=   r]   r   r   r   +test_constr_params_in_class_and_init_sphinx  s>   

"z?TestParamDocChecker.test_constr_params_in_class_and_init_sphinxc                 C   re   )
zExample of a class with missing constructor parameter documentation
        in both the init docstring and the class docstring
        (Google style)

        Everything is completely analogous to functions.
        a  
        class ClassFoo(object):
            '''docstring foo

            Args:
                y: bla

            missing constructor parameter documentation
            '''

            def __init__(self, x, y):
                '''docstring foo

                Args:
                    y: bla

                missing constructor parameter documentation
                '''
                pass

        r   rf   r   r   r(   r   r   Nrg   r]   r   r   r   +test_constr_params_in_class_and_init_google#  s>   

"z?TestParamDocChecker.test_constr_params_in_class_and_init_googlec                 C   re   )
zExample of a class with missing constructor parameter documentation
        in both the init docstring and the class docstring
        (Numpy style)

        Everything is completely analogous to functions.
        a  
        class ClassFoo(object):
            '''docstring foo

            Parameters
            ----------
            y:
                bla

            missing constructor parameter documentation
            '''

            def __init__(self, x, y):
                '''docstring foo

                Parameters
                ----------
                y:
                    bla

                missing constructor parameter documentation
                '''
                pass

        r   rf   r   r   r(   r   r   Nrg   r]   r   r   r   *test_constr_params_in_class_and_init_numpyX  s>   

"z>TestParamDocChecker.test_constr_params_in_class_and_init_numpyr      zEnabled on Python 3)reasonc                 C   s\   t d}| td|ddtd|dd | j| W d    d S 1 s'w   Y  d S )Nz
        def my_func(arg, *, kwonly, missing_kwonly):
            """The docstring

            :param int arg: The argument.
            :param bool kwonly: A keyword-arg.
            """
        r   )Zmissing_kwonlyr   r   r   r   r   r   r   $test_kwonlyargs_are_taken_in_account  s   
	"z8TestParamDocChecker.test_kwonlyargs_are_taken_in_accountc                 C   P   t d}| td|dd | j| W d    d S 1 s!w   Y  d S )Na(  
        def my_func(named_arg, *args):
            """The docstring

            :param named_arg: Returned
            :type named_arg: object
            :returns: Maybe named_arg
            :rtype: object or None
            """
            if args:
                return named_arg
        r   r   r   r   r   r   r   r   test_warns_missing_args_sphinx     
"z2TestParamDocChecker.test_warns_missing_args_sphinxc                 C   rn   )Na-  
        def my_func(named_arg, **kwargs):
            """The docstring

            :param named_arg: Returned
            :type named_arg: object
            :returns: Maybe named_arg
            :rtype: object or None
            """
            if kwargs:
                return named_arg
        r   kwargsr   r   r   r   r   r    test_warns_missing_kwargs_sphinx  rq   z4TestParamDocChecker.test_warns_missing_kwargs_sphinxc                 C   rn   )Na  
        def my_func(named_arg, *args):
            """The docstring

            Args:
                named_arg (object): Returned

            Returns:
                object or None: Maybe named_arg
            """
            if args:
                return named_arg
        r   ro   r   r   r   r   r   r   test_warns_missing_args_google     
"z2TestParamDocChecker.test_warns_missing_args_googlec                 C   rn   )Na  
        def my_func(named_arg, **kwargs):
            """The docstring

            Args:
                named_arg (object): Returned

            Returns:
                object or None: Maybe named_arg
            """
            if kwargs:
                return named_arg
        r   rr   r   r   r   r   r   r    test_warns_missing_kwargs_google  rv   z4TestParamDocChecker.test_warns_missing_kwargs_googlec                 C   rn   )NaZ  
        def my_func(named_arg, *args):
            """The docstring

            Args
            ----
            named_arg : object
                Returned

            Returns
            -------
                object or None
                    Maybe named_arg
            """
            if args:
                return named_arg
        r   ro   r   r   r   r   r   r   test_warns_missing_args_numpy     
"z1TestParamDocChecker.test_warns_missing_args_numpyc                 C   rn   )Na_  
        def my_func(named_arg, **kwargs):
            """The docstring

            Args
            ----
            named_arg : object
                Returned

            Returns
            -------
                object or None
                    Maybe named_arg
            """
            if kwargs:
                return named_arg
        r   rr   r   r   r   r   r   r   test_warns_missing_kwargs_numpy  ry   z3TestParamDocChecker.test_warns_missing_kwargs_numpyc                 C   D   t d}|   | j| W d    d S 1 sw   Y  d S )NaT  
        def my_func(named_arg, *args):
            """The docstring

            :param named_arg: Returned
            :type named_arg: object
            :param args: Optional arguments
            :returns: Maybe named_arg
            :rtype: object or None
            """
            if args:
                return named_arg
        r#   r   r   r   r   #test_finds_args_without_type_sphinx*     

"z7TestParamDocChecker.test_finds_args_without_type_sphinxc                 C   r{   )NaZ  
        def my_func(named_arg, **kwargs):
            """The docstring

            :param named_arg: Returned
            :type named_arg: object
            :param kwargs: Keyword arguments
            :returns: Maybe named_arg
            :rtype: object or None
            """
            if kwargs:
                return named_arg
        r#   r   r   r   r   %test_finds_kwargs_without_type_sphinx;  r}   z9TestParamDocChecker.test_finds_kwargs_without_type_sphinxc                 C   r{   )NaC  
        def my_func(named_arg, *args):
            """The docstring

            Args:
                named_arg (object): Returned
                *args: Optional arguments

            Returns:
                object or None: Maybe named_arg
            """
            if args:
                return named_arg
        r#   r   r   r   r   #test_finds_args_without_type_googleL     

"z7TestParamDocChecker.test_finds_args_without_type_googlec                 C   r{   )NaJ  
        def my_func(named_arg, **kwargs):
            """The docstring

            Args:
                named_arg (object): Returned
                **kwargs: Keyword arguments

            Returns:
                object or None: Maybe named_arg
            """
            if kwargs:
                return named_arg
        r#   r   r   r   r   %test_finds_kwargs_without_type_google^  r   z9TestParamDocChecker.test_finds_kwargs_without_type_googlec                 C   r{   )Na  
        def my_func(named_arg, *args):
            """The docstring

            Args
            ----
            named_arg : object
                Returned
            args :
                Optional Arguments

            Returns
            -------
                object or None
                    Maybe named_arg
            """
            if args:
                return named_arg
        r#   r   r   r   r   "test_finds_args_without_type_numpyp     

"z6TestParamDocChecker.test_finds_args_without_type_numpyc                 C   r{   )NaT  
        def my_func(named_arg, **kwargs):
            """The docstring

            Args:
                named_arg (`example.value`): Returned
                **kwargs: Keyword arguments

            Returns:
                `example.value`: Maybe named_arg
            """
            if kwargs:
                return named_arg
        r#   r   r   r   r   %test_finds_args_with_xref_type_google  r   z9TestParamDocChecker.test_finds_args_with_xref_type_googlec                 C   r{   )Na  
        def my_func(named_arg, *args):
            """The docstring

            Args
            ----
            named_arg : `example.value`
                Returned
            args :
                Optional Arguments

            Returns
            -------
                `example.value`
                    Maybe named_arg
            """
            if args:
                return named_arg
        r#   r   r   r   r   $test_finds_args_with_xref_type_numpy  r   z8TestParamDocChecker.test_finds_args_with_xref_type_numpyc                 C   r{   )Na  
        def my_func(named_arg, **kwargs):
            """The docstring

            Args
            ----
            named_arg : object
                Returned
            kwargs :
                Keyword arguments

            Returns
            -------
                object or None
                    Maybe named_arg
            """
            if kwargs:
                return named_arg
        r#   r   r   r   r   $test_finds_kwargs_without_type_numpy  r   z8TestParamDocChecker.test_finds_kwargs_without_type_numpy)zdict(str,str)zdict[str,str]z
tuple(int)zlist[tokenize.TokenInfo])zdict(str, str)zdict[str, str]z
int or strztuple(int or str)ztuple(int) or list(int)z%tuple(int or str) or list(int or str)complex_typec                 C   J   t d|}|   | j| W d    d S 1 sw   Y  d S )Nz
        def my_func(named_arg):
            """The docstring

            :param named_arg: Returned
            :type named_arg: {0}

            :returns: named_arg
            :rtype: {0}
            """
            return named_arg
        r   r   formatr$   r   r   r   r   r   r   r   r    test_finds_multiple_types_sphinx     
"z4TestParamDocChecker.test_finds_multiple_types_sphinxc                 C   r   )Nz
        def my_func(named_arg):
            """The docstring

            Args:
                named_arg ({0}): Returned

            Returns:
                {0}: named_arg
            """
            return named_arg
        r   r   r   r   r    test_finds_multiple_types_google  r   z4TestParamDocChecker.test_finds_multiple_types_googlec                 C   r   )Na&  
        def my_func(named_arg):
            """The docstring

            Args
            ----
            named_arg : {0}
                Returned

            Returns
            -------
                {0}
                    named_arg
            """
            return named_arg
        r   r   r   r   r   test_finds_multiple_types_numpy  s   
"z3TestParamDocChecker.test_finds_multiple_types_numpycontainer_typec                 C   r   )Nz
        def my_func(named_arg):
            """The docstring

            :param {0} named_arg: Returned

            :returns: named_arg
            :rtype: {0}
            """
            return named_arg
        r   )r   r   r   r   r   r   )test_finds_compact_container_types_sphinx  s   

"z=TestParamDocChecker.test_finds_compact_container_types_sphinxc                 C   r{   )Na  
        def do_something(param1, param2, param3=(), param4=[], param5=[], param6=True):
            """Do something.

            Args:
                param1 (str): Description.
                param2 (dict(str, int)): Description.
                param3 (tuple(str), optional): Defaults to empty. Description.
                param4 (List[str], optional): Defaults to empty. Description.
                param5 (list[tuple(str)], optional): Defaults to empty. Description.
                param6 (bool, optional): Defaults to True. Description.

            Returns:
                int: Description.
            """
            return param1, param2, param3, param4, param5, param6
        r#   r   r   r   r   &test_ignores_optional_specifier_google  s   

"z:TestParamDocChecker.test_ignores_optional_specifier_googlec                 C   r{   )Na  
        def do_something(param, param2='all'):
            """Do something.

            Parameters
            ----------
            param : str
                Description.
            param2 : str, optional
                Description (the default is 'all').

            Returns
            -------
            int
                Description.
            """
            return param, param2
        r#   r   r   r   r   %test_ignores_optional_specifier_numpy3  s   

"z9TestParamDocChecker.test_ignores_optional_specifier_numpyc                 C   r{   )Na  
        from fake_package import BadError

        def do_something(): #@
            """Do something.

            Raises:
                ~fake_package.exceptions.BadError: When something bad happened.
            """
            raise BadError("A bad thing happened.")
        r#   r   r   r   r   test_finds_short_name_exceptionI  s   

"z3TestParamDocChecker.test_finds_short_name_exceptionc                 C   T   t d\}}| td|dd | j| W d   dS 1 s#w   Y  dS )zvExample of a setter having missing raises documentation in
        the Sphinx style docstring of the property
        a(  
        class Foo(object):
            @property
            def foo(self): #@
                '''docstring ...

                :type: int
                '''
                return 10

            @foo.setter
            def foo(self, value):
                raise AttributeError() #@
        missing-raises-docAttributeErrorr   Nr   r   r   r   r   Zvisit_raiser   Zproperty_noder   r   r   r   ,test_finds_missing_raises_from_setter_sphinxX  s   "z@TestParamDocChecker.test_finds_missing_raises_from_setter_sphinxc                 C   r   )zvExample of a setter having missing raises documentation in
        the Google style docstring of the property
        a  
        class Foo(object):
            @property
            def foo(self): #@
                '''int: docstring

                Include a "Raises" section so that this is identified
                as a Google docstring and not a Numpy docstring.

                Raises:
                    RuntimeError: Always
                '''
                raise RuntimeError()
                return 10

            @foo.setter
            def foo(self, value):
                raises AttributeError() #@
        r   r   r   Nr   r   r   r   r   ,test_finds_missing_raises_from_setter_googler  s   "z@TestParamDocChecker.test_finds_missing_raises_from_setter_googlec                 C   r   )zuExample of a setter having missing raises documentation in
        the Numpy style docstring of the property
        a"  
        class Foo(object):
            @property
            def foo(self): #@
                '''int: docstring

                Include a "Raises" section so that this is identified
                as a Numpy docstring and not a Google docstring.

                Raises
                ------
                RuntimeError
                    Always
                '''
                raise RuntimeError()
                return 10

            @foo.setter
            def foo(self, value):
                raises AttributeError() #@
        r   r   r   Nr   r   r   r   r   +test_finds_missing_raises_from_setter_numpy  s   "z?TestParamDocChecker.test_finds_missing_raises_from_setter_numpyc                 C   r   )zjExample of a setter having missing raises documentation in
        its own Sphinx style docstring
        a  
        class Foo(object):
            @property
            def foo(self):
                '''docstring ...

                :type: int
                :raises RuntimeError: Always
                '''
                raise RuntimeError()
                return 10

            @foo.setter
            def foo(self, value): #@
                '''setter docstring ...

                :type: None
                '''
                raise AttributeError() #@
        r   r   r   Nr   r   Zsetter_noder   r   r   r   *test_finds_missing_raises_in_setter_sphinx  s   "z>TestParamDocChecker.test_finds_missing_raises_in_setter_sphinxc                 C   r   )zzExample of a setter having missing raises documentation in
        its own Google style docstring of the property
        a7  
        class Foo(object):
            @property
            def foo(self):
                '''int: docstring ...

                Raises:
                    RuntimeError: Always
                '''
                raise RuntimeError()
                return 10

            @foo.setter
            def foo(self, value): #@
                '''setter docstring ...

                Raises:
                    RuntimeError: Never
                '''
                if True:
                    raise AttributeError() #@
                raise RuntimeError()
        r   r   r   Nr   r   r   r   r   r     s   "c                 C   r   )zyExample of a setter having missing raises documentation in
        its own Numpy style docstring of the property
        a  
        class Foo(object):
            @property
            def foo(self):
                '''int: docstring ...

                Raises
                ------
                RuntimeError
                    Always
                '''
                raise RuntimeError()
                return 10

            @foo.setter
            def foo(self, value): #@
                '''setter docstring ...

                Raises
                ------
                RuntimeError
                    Never
                '''
                if True:
                    raise AttributeError() #@
                raise RuntimeError()
        r   r   r   Nr   r   r   r   r   r     s   "c                 C   r!   )z^Example of a property having return documentation in
        a Sphinx style docstring
        z
        class Foo(object):
            @property
            def foo(self): #@
                '''docstring ...

                :type: int
                '''
                return 10
        Nr#   r   r   r   r   &test_finds_property_return_type_sphinx     


"z:TestParamDocChecker.test_finds_property_return_type_sphinxc                 C   r!   )^Example of a property having return documentation in
        a Google style docstring
        a  
        class Foo(object):
            @property
            def foo(self): #@
                '''int: docstring ...

                Raises:
                    RuntimeError: Always
                '''
                raise RuntimeError()
                return 10
        Nr#   r   r   r   r   &test_finds_property_return_type_google-     

"z:TestParamDocChecker.test_finds_property_return_type_googlec                 C   r!   )]Example of a property having return documentation in
        a numpy style docstring
        a8  
        class Foo(object):
            @property
            def foo(self): #@
                '''int: docstring ...

                Raises
                ------
                RuntimeError
                    Always
                '''
                raise RuntimeError()
                return 10
        Nr#   r   r   r   r   %test_finds_property_return_type_numpy@     

"z9TestParamDocChecker.test_finds_property_return_type_numpyc                 C   H   t d\}}|   | j| W d   dS 1 sw   Y  dS )fExample of a property having missing return documentation in
        a Sphinx style docstring
        a  
        class Foo(object):
            @property
            def foo(self) -> int: #@
                '''docstring ...

                :raises RuntimeError: Always
                '''
                raise RuntimeError()
                return 10 #@
        Nr   r   r$   r   visit_returnr   r   r   r   1test_finds_annotation_property_return_type_sphinxU  s   
"zETestParamDocChecker.test_finds_annotation_property_return_type_sphinxc                 C   R   t d\}}| td|d | j| W d   dS 1 s"w   Y  dS )r   z
        class Foo(object):
            @property
            def foo(self): #@
                '''docstring ...

                :raises RuntimeError: Always
                '''
                raise RuntimeError()
                return 10 #@
        missing-return-type-docr   r   Nr   r   r   r   r   r   r   r   r   r   .test_finds_missing_property_return_type_sphinxg  s   "zBTestParamDocChecker.test_finds_missing_property_return_type_sphinxc                 C   r   )r   a  
        class Foo(object):
            @property
            def foo(self) -> int: #@
                '''docstring ...

                Raises:
                    RuntimeError: Always
                '''
                raise RuntimeError()
                return 10 #@
        Nr   r   r   r   r   1test_finds_annotation_property_return_type_google}  s   
"zETestParamDocChecker.test_finds_annotation_property_return_type_googlec                 C   r   )r   a  
        class Foo(object):
            @property
            def foo(self): #@
                '''docstring ...

                Raises:
                    RuntimeError: Always
                '''
                raise RuntimeError()
                return 10 #@
        r   r   Nr   r   r   r   r   .test_finds_missing_property_return_type_google  s   "zBTestParamDocChecker.test_finds_missing_property_return_type_googlec                 C   r   )r   a6  
        class Foo(object):
            @property
            def foo(self): #@
                '''docstring ...

                Raises
                ------
                RuntimeError
                    Always
                '''
                raise RuntimeError()
                return 10 #@
        r   r   Nr   r   r   r   r   -test_finds_missing_property_return_type_numpy  s   "zATestParamDocChecker.test_finds_missing_property_return_type_numpyc                 C   \   t d\}}| td|dtd|d | j| W d   dS 1 s'w   Y  dS )zuExample of a class function trying to use `type` as return
        documentation in a Sphinx style docstring
        z
        class Foo(object):
            def foo(self): #@
                '''docstring ...

                :type: int
                '''
                return 10 #@
        missing-return-docr   r   Nr   r   Z	func_noder   r   r   r   ,test_ignores_non_property_return_type_sphinx  s   	"z@TestParamDocChecker.test_ignores_non_property_return_type_sphinxc                 C   r   )zuExample of a class function trying to use `type` as return
        documentation in a Google style docstring
        a   
        class Foo(object):
            def foo(self): #@
                '''int: docstring ...

                Raises:
                    RuntimeError: Always
                '''
                raise RuntimeError()
                return 10 #@
        r   r   r   Nr   r   r   r   r   ,test_ignores_non_property_return_type_google  s   "z@TestParamDocChecker.test_ignores_non_property_return_type_googlec                 C   r   )tExample of a class function trying to use `type` as return
        documentation in a numpy style docstring
        a%  
        class Foo(object):
            def foo(self): #@
                '''int: docstring ...

                Raises
                ------
                RuntimeError
                    Always
                '''
                raise RuntimeError()
                return 10 #@
        r   r   r   Nr   r   r   r   r   +test_ignores_non_property_return_type_numpy  s   "z?TestParamDocChecker.test_ignores_non_property_return_type_numpyc                 C   r   )r   a,  
        class Foo(object):
            def foo(self) -> int: #@
                '''int: docstring ...

                Raises
                ------
                RuntimeError
                    Always
                '''
                raise RuntimeError()
                return 10 #@
        r   r   Nr   r   r   r   r   .test_non_property_annotation_return_type_numpy  s   "zBTestParamDocChecker.test_non_property_annotation_return_type_numpyc                 C   r!   )pExample of an abstract method documenting the return type that an
        implementation should return.
        z
        import abc
        class Foo(object):
            @abc.abstractmethod
            def foo(self): #@
                '''docstring ...

                :returns: Ten
                :rtype: int
                '''
                return 10
        Nr#   r   r   r   r   -test_ignores_return_in_abstract_method_sphinx#  r   zATestParamDocChecker.test_ignores_return_in_abstract_method_sphinxc                 C   r!   )r   z
        import abc
        class Foo(object):
            @abc.abstractmethod
            def foo(self): #@
                '''docstring ...

                Returns:
                    int: Ten
                '''
                return 10
        Nr#   r   r   r   r   -test_ignores_return_in_abstract_method_google6  r   zATestParamDocChecker.test_ignores_return_in_abstract_method_googlec                 C   r!   )r   a!  
        import abc
        class Foo(object):
            @abc.abstractmethod
            def foo(self): #@
                '''docstring ...

                Returns
                -------
                int
                    Ten
                '''
                return 10
        Nr#   r   r   r   r   ,test_ignores_return_in_abstract_method_numpyI  r   z@TestParamDocChecker.test_ignores_return_in_abstract_method_numpyc                 C   r!   )zExample of an abstract
        z
        class Foo(object):
            def foo(self, arg): #@
                '''docstring ...

                :param arg: An argument.
                :type arg: int
                '''
                raise NotImplementedError()
        Nr#   r   r   r   r   -test_ignores_raise_notimplementederror_sphinx^  s   


"zATestParamDocChecker.test_ignores_raise_notimplementederror_sphinxc                 C   r!   )fExample of a method documenting the return type that an
        implementation should return.
        z
        class Foo(object):
            def foo(self, arg): #@
                '''docstring ...

                Args:
                    arg (int): An argument.
                '''
                raise NotImplementedError()
        Nr#   r   r   r   r   r   n  r   c                 C   r!   )r   a  
        class Foo(object):
            def foo(self, arg): #@
                '''docstring ...

                Parameters
                ----------
                arg : int
                    An argument.
                '''
                raise NotImplementedError()
        Nr#   r   r   r   r   r     r   N)`__name__
__module____qualname____doc__r   ZCHECKER_CLASSZCONFIGr   r    r%   r'   r*   r+   r-   r.   r2   r3   r   r5   r6   r7   r=   rA   rB   rC   rD   rE   rF   rJ   rL   rM   rN   rP   rQ   rU   rW   rY   r\   r^   r`   ra   rb   rd   rh   ri   rj   pytestmarkZskipifsysversion_inform   rp   rt   ru   rw   rx   rz   r|   r~   r   r   r   r   r   r   ZCONTAINER_TYPESZCOMPLEX_TYPESZparametrizer   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	      s    %
=;A "  "359
	



! #'r	   )r   
__future__r   r   r   r   r   r   Zpylint.testutilsr   r   r   Zpylint.extensions.docparamsr   r	   r   r   r   r   <module>   s   