autoDocstring icon indicating copy to clipboard operation
autoDocstring copied to clipboard

Weird behaviour when defining conditional value for the function argument

Open lnxpy opened this issue 8 months ago • 0 comments

Describe the bug When you set a conditional value for the function argument, the default value shown in the doc is weirdly formatted!

Versions (please complete the following information):

  • autoDocstring Version: v0.6.1
  • Operating System: MacOS Sonoma 14.4.1
  • Vscode Version: 1.90.0

Issue:

def greeting(name: str = "John" if is_administrator else "Jamy") -> None:
    ...

After numpy doc generation:

def greeting(name: str = "John" if is_administrator else "Jamy") -> None:
    """_summary_

    Args:
        name (str, optional): _description_. Defaults to "John"ifis_administratorelse"Jamy".
    """                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...

Apparently, the rest of the string after the = symbol is considered as the default value for the parameter which is not true in some cases.

lnxpy avatar Jun 08 '24 21:06 lnxpy