writer icon indicating copy to clipboard operation
writer copied to clipboard

Python Multiline function defs not working

Open tcmetzger opened this issue 3 years ago • 0 comments

If I create a docstring on a Python function with a multiline def statement, the generated doc string ends up in the middle of the function definition (instead of after it), effectively breaking the function.

This is what I get:

def my_function(
  """
  `my_function` takes two arguments, `x` and `y`, and returns the product of the
  two
  
  :param x: int = 2, defaults to 2
  :type x: int (optional)
  :param y: int = 5, defaults to 5
  :type y: int (optional)
  :return: 10
  """
    x: int = 2,
    y: int = 5,
    ):

    return x * y

This is what I'd expect to see:

def my_function(
    x: int = 2,
    y: int = 5,
    ):
    """
    `my_function` takes two arguments, `x` and `y`, and returns the product of the
    two
    
    :param x: int = 2, defaults to 2
    :type x: int (optional)
    :param y: int = 5, defaults to 5
    :type y: int (optional)
    :return: 10
    """
    
    return x * y

VS Code version info:

Version: 1.70.2 (user setup) Commit: e4503b30fc78200f846c62cf8091b76ff5547662 Date: 2022-08-16T05:35:13.448Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.19044

tcmetzger avatar Aug 22 '22 19:08 tcmetzger