autoDocstring
autoDocstring copied to clipboard
Weird behaviour when defining conditional value for the function argument
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.