mercredi 17 mai 2017

Test docstring matches parameters

Imagine I have the following function:

def my_function(x, y):
    """
    Parameters
    ----------
    x : float
        First parameter.
    wrong : float
        This parameter is not in the function.
    wrong_as_well : float
        There is not even a third parameter in the function.
    """
    return x + y

There are tools in Python that help me check PEP 8 correctness, or find variables or imports that are not used in the code, or even detect functions with high cyclomatic complexity.

Is there any tool that would check that the name of the parameters described in the docstring match the parameters in the function?

Ideally this tool would be integrated into a testing framework (i.e.: pytest; just like pytest-pep8, pytest-flakes or pytest-mccabe).

Aucun commentaire:

Enregistrer un commentaire