Skip to content

Does not generate docstring when function has default value of """. #305

@deathbychocolate

Description

@deathbychocolate

Describe the bug
Autodocstring does not generate a docstring when the method we are trying to document has """ as the default value to a parameter.

Versions (please complete the following information):

  • autoDocstring Version: 0.6.1
  • Operating System: MacOS
  • Vscode Version: 1.100.0

Original Code (with line to generate on):
It seems that multiline_delimiter: str = '"""' is causing the issue.

class ChatOpenai(Chat):
    """A chat session for communicating with Openai."""

    def __init__(
        self,
        model: str,
        role_user: str = "user",
        role_model: str = "assistant",
        context: bool = True,
        stream: bool = True,
        filepath: str = "",
        storage: bool = True,
        load_last: bool = False,
        multiline_delimiter: str = '"""',
    ) -> None:
        # generate on this line
        Chat.__init__(self)

        self._model: str = model
        self._role_user: str = role_user
        self._role_model: str = role_model
        self._context: bool = context
        self._stream: bool = stream
        self._filepath: str = filepath
        self._storage: bool = storage
        self._load_last: bool = load_last
        self._multiline_delimiter: str = multiline_delimiter
        self._messages: Messages = Storage().extract_messages() if self._load_last else Messages()

Expected Result:

class ChatOpenai(Chat):
    """A chat session for communicating with Openai."""

    def __init__(
        self,
        model: str,
        role_user: str = "user",
        role_model: str = "assistant",
        context: bool = True,
        stream: bool = True,
        filepath: str = "",
        storage: bool = True,
        load_last: bool = False,
        multiline_delimiter: str = '"""',
    ) -> None:
        """_summary_

        _extended_summary_

        Args:
            model (str): _description_
            role_user (str, optional): _description_. Defaults to "user".
            role_model (str, optional): _description_. Defaults to "assistant".
            context (bool, optional): _description_. Defaults to True.
            stream (bool, optional): _description_. Defaults to True.
            filepath (str, optional): _description_. Defaults to "".
            storage (bool, optional): _description_. Defaults to True.
            load_last (bool, optional): _description_. Defaults to False.
            multiline_delimiter (bool, optional): _description_. Defaults to '\"\"\"'.
        """
        Chat.__init__(self)

        self._model: str = model
        self._role_user: str = role_user
        self._role_model: str = role_model
        self._context: bool = context
        self._stream: bool = stream
        self._filepath: str = filepath
        self._storage: bool = storage
        self._load_last: bool = load_last
        self._multiline_delimiter: str = multiline_delimiter
        self._messages: Messages = Storage().extract_messages() if self._load_last else Messages()

Actual Result:

print("The autodocstring stub does not appear...")

Debug log:
Set autoDocstring.logLevel to "Debug", recreate the bug, and then copy the debug logs from the autoDocstring output channel.

No logs appear as it is not a programmatic error. It seems to be a regex issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions