#3010·click

Impossible to get single newlines in help text

Author: learn-moreCreated Jul 22, 2025Updated Sep 12, 2026
Labelshelp output

The expected format is:

  --annotations [disabled|comment]
                                  Specify the type of annotations to include in the XML output.
                                  'Disabled' - no annotations.
                                  'Comment' - annotations as comments.

The actual format is either:

  --annotations [disabled|comment]
                                  Specify the type of annotations to include in the XML output.

                                  'Disabled' - no annotations.
                                  'Comment' - annotations as comments.

or:

  --annotations [disabled|comment]
                                  Specify the type of annotations to include in the XML output. 'Disabled' - no annotations. 'Comment' - annotations as comments.

However the text either has no newlines, or it has double newlines. I expected this to work:

python
@click.option(
    "--annotations",
    type=click.Choice(Annotations, case_sensitive=False),
    default=Annotations.Comment,
    help="""Specify the type of annotations to include in the XML output.
    \b
    'Disabled' - no annotations.
    'Comment' - annotations as comments.""",
)

But that ends up without any newlines. Adding an extra blank line before the \b does work, but that also results in an extra blank line in the output (as seen above):

python
@click.option(
    "--annotations",
    type=click.Choice(Annotations, case_sensitive=False),
    default=Annotations.Comment,
    help="""Specify the type of annotations to include in the XML output.

    \b
    'Disabled' - no annotations.
    'Comment' - annotations as comments.""",
)

Environment:

  • Python version: 3.10.11
  • Click version: 8.2.1