Skip to content
Myr

Merge pull request #1970 from pbeza/empty-default-value-in-help-output

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Empty default value in help output

authored by David Lord · committed by GitHub · parents 10611b5, 1807058 · Browse files · 3 files+15 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−2 removed

  • tests:+10 added−0 removed
  • other:+5 added−2 removed

3 files+15 added−2 removed

modified:src/click/core.py+3 added-2 removed
2459 unmodified lines
24602461 def __init__(2462 self,2463 param_decls: t.Optional[t.Sequence[str]] = None,2464 show_default: bool = False,2464 show_default: t.Union[bool, str] = False,2465 prompt: t.Union[bool, str] = False,2466 confirmation_prompt: t.Union[bool, str] = False,2467 prompt_required: bool = True,2468 hide_input: bool = False,
278 unmodified lines
2747 )[1]2748 else:2749 default_string = str(default_value)27502751 if default_string:2751 extra.append(_("default: {default}").format(default=default_string))2752 extra.append(_("default: {default}").format(default=default_string))27532754 if isinstance(self.type, types._NumberRangeBase):2755 range_str = self.type._describe_range()2756
202 unmodified lines
modified:tests/test_options.py+10 added
726 unmodified lines
727 message = opt.get_help_record(ctx)[1]728 assert "[default: None]" not in message729730731def test_do_not_show_default_empty_multiple():732 """When show_default is True and multiple=True is set, it should not733 print empty default value in --help output.734 """735 opt = click.Option(["-a"], multiple=True, help="values", show_default=True)736 ctx = click.Context(click.Command("cli"))737 message = opt.get_help_record(ctx)[1]738 assert message == "values"739740741@pytest.mark.parametrize(742 ("args", "expect"),743 [744 (None, (None, None, ())),
51 unmodified lines
modified:CHANGES.rst+2 added
6 unmodified lines
78- ``is_bool_flag`` is not set to ``True`` if ``is_flag`` is ``False``.9 :issue:`1925`10- Bash version detection is locale independent. :issue:`1940`11- Empty ``default`` value is not shown for ``multiple=True``.12 :issue:`1969`131415Version 8.0.116-------------
889 unmodified lines