Skip to content

Feature Request (insert_license): Use multiline comment for python files #87

Open

Description

@matroscoe

For python files if I have a larger license text it would be nice if I could encapsulate it inside a multi-line comment so that it looks like

"""
<license-text>
"""

instead of

# <license text>
# <license text continued...>

Activity

  1. Lucas-C commented on Jan 26, 2024

    @Lucas-C
    Owner

    Hi @matroscoe

    Sure, this feature could be added.
    Would you like to submit a PR?

    I think that a new --comment-style argument flag would have to be added,
    so that one could set --comment-style=docstring.

  2. peterjc commented on Sep 2, 2024

    @peterjc

    You can get very close using '--comment-style="""||"""' in your pre-commit configuration, i.e. three double quotes for comment start, nothing for comment continuation, and three double quotes for comment end. It would give you:

    """
     <license text>
     <license text continued...>
    """
    

    Note the unwanted single leading space, a side effect of the current default comment marker of "#" being treated implicitly as "# " when appending the license. See also #79.

    It may be that you can automatically get rid of those leading spaces by running something like ruff format afterwards, giving a usable work-around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions