-
-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Labels
Description
Describe the bug
When using autoDocstring to generate a docstring for a function that returns a union type like str | None, the generated docstring omits parentheses around the return type. This causes a rendering issue in VS Code, where the return type and summary are not properly parsed or displayed. Adding parentheses around the union type (e.g., (str | None)) fixes the issue.
Versions (please complete the following information):
- autoDocstring Version: 0.6.1
- Operating System: Windows 10 WSL 2 Ubuntu 20.04 LTS
- Vscode Version: 1.100.2
Original Code (with line to generate on):
def foo() -> str | None:
passExpected Result:
def foo() -> str | None:
"""_summary_
Returns:
(str | None): _description_
"""
passActual Result:
def foo() -> str | None:
"""_summary_
Returns:
str | None: _description_
"""
passDebug log:
[INFO 11:47:02.670] Generating Docstring at line: 339
[INFO 11:47:02.671] Docstring generated:
"""${1:_summary_}
Returns:
${2:str | None}: ${3:_description_}
"""
[INFO 11:47:02.671] Inserting at position: 339 0
[INFO 11:47:02.679] Successfully inserted docstring
Additional context
Without parentheses around return type:

With:

Reactions are currently unavailable