autoDocstring icon indicating copy to clipboard operation
autoDocstring copied to clipboard

Literals with quotations produce odd outputs

Open irm-codebase opened this issue 7 months ago • 0 comments

Describe the bug Adding `Literal["something", "otherthing"] will lead to a very weird output by autoDocstring:

Versions (please complete the following information):

  • autoDocstring Version: 0.6.1
  • Operating System: Linux Fedora 39
  • Vscode Version: 1.90

Original Code (with line to generate on):

    def _add_component(
        self,
        name: str,
        component_dict: Optional[Tp],
        component_setter: Callable,
        component_type: Literal[
            "variables", "global_expressions", "constraints", "objectives"
        ],
        break_early: bool = True,
    ) -> Optional[parsing.ParsedBackendComponent]:
        """_summary_

        Args:
            name (str): _description_
            component_dict (Optional[Tp]): _description_
            component_setter (Callable): _description_
            component_type (Literal[ "variables", "global_expressions", "constraints", "objectives" ]): _description_
            break_early (bool, optional): _description_. Defaults to True.

        Raises:
            BackendError: _description_

        Returns:
            Optional[parsing.ParsedBackendComponent]: _description_
        """

Expected Result:

component_type (Literal[ "variables", "global_expressions", "constraints", "objectives"]): _description_

Actual Result:

component_type (Literal[ "variables", "global_expressions", "constraints", "objectives" ]): _description_

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

[INFO 20:41:27.969] autoDocstring was activated
[INFO 21:00:00.535] Generating Docstring at line: 252
[INFO 21:00:00.538] Docstring generated:
        """${1:_summary_}

        Args:
            name (${2:str}): ${3:_description_}
            component_dict (${4:Optional[Tp]}): ${5:_description_}
            component_setter (${6:Callable}): ${7:_description_}
            component_type (${8:Literal[ "variables", "global_expressions", "constraints", "objectives" ]}): ${9:_description_}
            break_early (${10:bool}, optional): ${11:_description_}. Defaults to True.

        Raises:
            BackendError: ${12:_description_}

        Returns:
            ${13:Optional[parsing.ParsedBackendComponent]}: ${14:_description_}
        """
[INFO 21:00:00.538] Inserting at position: 252 0
[INFO 21:00:00.546] Successfully inserted docstring

irm-codebase avatar Jun 25 '24 19:06 irm-codebase