Skip to content

Empty string default values are not displayed #2500

@m-freiberg

Description

@m-freiberg

If an option has a default value of "", the show_default option does not display anything.

Reproducible example:

import click

@click.group()
def test_cli() -> None:
    pass 


@test_cli.command(help="Test CLI")
@click.option("--test_value", type=str, default="", show_default=True)
def test_function(
    test_value: str
) -> None:
    print(test_value)


@click.group()
def cli() -> None:
    pass


cli.add_command(test_cli)
cli()

Expected to see a default displayed. Actual behavior:
image

Environment:

  • Python version: 3.11.3
  • Click version: 8.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions