Skip to content
Myr

Merge pull request #2084 from pallets/count-type-help

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

count help doesn't show default range type

authored by David Lord · committed by GitHub · parents 3e88d3d, 3d029e0 · Browse files · 3 files+17 added−3 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+17 added−3 removed

  • tests:+10 added−2 removed
  • other:+7 added−1 removed

3 files+17 added−3 removed

modified:src/click/core.py+5 added-1 removed
2738 unmodified lines
27392740 if default_string:2741 extra.append(_("default: {default}").format(default=default_string))27422743 if isinstance(self.type, types._NumberRangeBase):2743 if (2744 isinstance(self.type, types._NumberRangeBase)2745 # skip count with default range type2746 and not (self.count and self.type.min == 0 and self.type.max is None)2747 ):2748 range_str = self.type._describe_range()27492750 if range_str:2751 extra.append(range_str)
200 unmodified lines
modified:tests/test_options.py+10 added-2 removed
312 unmodified lines
313 (click.IntRange(1), "x>=1"),314 (click.IntRange(max=32), "x<=32"),315 ],316)317def test_intrange_default_help_text(runner, type, expect):318 option = click.Option(["--count"], type=type, show_default=True, default=2)317def test_intrange_default_help_text(type, expect):318 option = click.Option(["--num"], type=type, show_default=True, default=2)319 context = click.Context(click.Command("test"))320 result = option.get_help_record(context)[1]321 assert expect in result322323324def test_count_default_type_help():325 """A count option with the default type should not show >=0 in help."""326 option = click.Option(["--couunt"], count=True, help="some words")327 context = click.Context(click.Command("test"))328 result = option.get_help_record(context)[1]329 assert result == "some words"330331332def test_toupper_envvar_prefix(runner):333 @click.command()334 @click.option("--arg")335 def cmd(arg):
468 unmodified lines
modified:CHANGES.rst+2 added
18 unmodified lines
19- Fix type annotation for ``type`` argument in ``prompt`` function.20 :issue:`2062`21- Fix overline and italic styles, which were incorrectly added when22 adding underline. :pr:`2058`23- An option with ``count=True`` will not show "[x>=0]" in help text.24 :issue:`2072`252627Version 8.0.128-------------
889 unmodified lines