autoDocstring icon indicating copy to clipboard operation
autoDocstring copied to clipboard

Trailing whitespaces

Open AlbertoFabbri93 opened this issue 3 years ago • 6 comments

Describe the bug When I generate a Google Style Docstring inside a function there are four trailing whitespaces after the three closing quotes, here they are marked with asterisks:

"""
    Read a file with names and messages and return it as a list

    Args:
        file_path (str): File to open

    Returns:
        list: List with tuples made of name + message
"""****

Versions:

  • autoDocstring Version: v0.5.3
  • Operating System: Microsoft Windows 10 Home v. 2004
  • Vscode Version: 1.50.0

AlbertoFabbri93 avatar Oct 11 '20 09:10 AlbertoFabbri93

Just for information, this does not happen to me, and we have almost

  • autoDocstring version: 0.5.3
  • Operating system: Windows 10 Pro for workstations
  • Vscode Version 1.50.1

Maybe you can share the exact function before using the autodocstring, I show mine.

Before:

def func(a, b):
    raise NotImplementedError

After:

def func(a, b):
    """[summary]

    Args:
        a ([type]): [description]
        b ([type]): [description]

    Raises:
        NotImplementedError: [description]
    """
    raise NotImplementedError

NumberPiOso avatar Oct 16 '20 02:10 NumberPiOso

I tried with another function, before:

def from_xyLabyrinth_to_xyMath(position_xLabyrinth, position_yLabyrinth):
    position_xMath = position_xLabyrinth + 1
    position_yMath = 10 - position_yLabyrinth
    return (position_xMath, position_yMath)

after:

def from_xyLabyrinth_to_xyMath(position_xLabyrinth, position_yLabyrinth):
    """
    [summary]

    Args:
        position_xLabyrinth ([type]): [description]
        position_yLabyrinth ([type]): [description]

    Returns:
        [type]: [description]
    """    
    position_xMath = position_xLabyrinth + 1
    position_yMath = 10 - position_yLabyrinth
    return (position_xMath, position_yMath)

but the problem remains.

To insert the docstring I created a new line after the def function_name line, pressed ctrl+shift+p and selected Generate Docstring.

Versions: autoDocstring Version: v0.5.3 Operating System: Microsoft Windows 10 Home v. 20H2 Vscode Version: 1.50.1

AlbertoFabbri93 avatar Oct 25 '20 21:10 AlbertoFabbri93

I have the same issue and I discovered that if my cursor is already indented when clicking cmd+shift+2, it will add the trailing whitespaces. If the cursor is not indented, it doesn't add them. Hopefully this is helpful until a fix is added.

erin-stuelke avatar Dec 15 '20 15:12 erin-stuelke

+1, please fix

lukasleuschen avatar Jan 10 '21 16:01 lukasleuschen

Oh I understand the problem. It has never happened for me because I have the files.trimTrailingWhitespace vscode setting that will always remove trailing whitespace before I run the command. I can fix this but I also recommend turning on that setting. It's really useful.

NilsJPWerner avatar Mar 08 '21 04:03 NilsJPWerner

I am also sometimes experiencing this. Using google style docstrings. Can't tell by now when exactly it happens.

JOJ0 avatar Apr 27 '21 07:04 JOJ0