dadadel / pyment

Format and convert Python docstrings and generates patches
GNU General Public License v3.0
905 stars 62 forks source link

Breaking existing numpy docstring. #128

Open galyfray opened 1 year ago

galyfray commented 1 year ago

When running pyment on a file with already existing docstrings pyment will try to add again the arguments.

Running pyment on the following file

def add(left: int, right: int) -> int:
    """
    Add two intergers together.

    Really high tech !

    Parameters
    ----------
    left : int :
        Left element to add
    right : int :
        right element to add

    Returns
    -------

    """
    return left + right

will result in this file (the bug still occurs with or without the -w arg):


def add(left: int, right: int) -> int:
    """
    Add two intergers together.

    Really high tech ! like woa !

    Parameters
    ----------
    left : int :
        Left element to add
    right : int :
        right element to add
    left: int :

    right: int :

    Returns
    -------

    """
    return left + right

I at first thought that pyment was hard checking for the presence of those two lines, but it does not seem to be the case :

def add(left: int, right: int) -> int:
    """
    Add two intergers together.

    Really high tech ! like woa !

    Parameters
    ----------
    left : int :
        Left element to add
    right : int :
        right element to add
    left : int :

    right : int :

    left: int :

    right: int :

    Returns
    -------

    """
    return left + right

Tested on python 3.10.8, pyment 0.3.3