autoDocstring
autoDocstring copied to clipboard
`NoReturn` type annotation shouldn't be treated as a return
Describe the bug
Python has a NoReturn type (docs) used to indicate that a function can never return (it's used by static analysis tools to analyse dead code zones).
Currently autoDocstring is treating this as a return type and adding it to the docstring. This should be treated like None and omitted from the docstring. Currently it's causing me lint issues (using darglint) that I have to manually fix. Darglint is correct here as it uses the AST to verify that the function can never return anything.
Versions (please complete the following information):
- autoDocstring Version: v0.6.1
- Operating System: MacOS Monterery, v12.3
- Vscode Version: 1.65.2
Original Code (with line to generate on):
from typing import NoReturn
def stop() -> NoReturn:
# Generate docstring on this line
raise RuntimeError("no way")
Expected Result:
from typing import NoReturn
def stop() -> NoReturn:
"""_summary_
Raises:
RuntimeError: _description_
"""
raise RuntimeError("no way")
Actual Result:
from typing import NoReturn
def stop() -> NoReturn:
"""_summary_
Raises:
RuntimeError: _description_
Returns:
NoReturn: _description_
"""
raise RuntimeError("no way")
Debug log:
[INFO 18:23:05.617] Generating Docstring at line: 5
[INFO 18:23:05.618] Docstring generated:
"""${1:_summary_}
Raises:
RuntimeError: ${2:_description_}
Returns:
${3:NoReturn}: ${4:_description_}
"""
[INFO 18:23:05.618] Inserting at position: 5 0
[INFO 18:23:05.624] Successfully inserted docstring
Additional context Thanks for your work on this project, it's saved me a lot of time documenting ❤️