Skip to content
Myr

Default count to 0

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 99f0da9 · Browse files · 2 files+15 added−9 removed
This commit

State

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

Diff stats

2 files+15 added−9 removed

  • tests:+4 added−0 removed
  • other:+11 added−9 removed

2 files+15 added−9 removed

modified:click/core.py+11 added-9 removed
833 unmodified lines
834 multiple=False, count=False, allow_from_autoenv=True,835 type=None, help=None, **attrs):836 default_is_missing = attrs.get('default', _missing) is _missing837 Parameter.__init__(self, param_decls, type=type, **attrs)838839 if prompt is True:840 prompt_text = self.name.replace('_', ' ').capitalize()841 elif prompt is False:842 prompt_text = None
2 unmodified lines
845 self.prompt = prompt_text846 self.confirmation_prompt = confirmation_prompt847 self.hide_input = hide_input848849 # Flags850 if is_flag is None:851 if flag_value is not None:852 is_flag = True853 else:854 is_flag = bool(self.secondary_opts)853855 if is_flag and default_is_missing:856 self.default = False856857 if flag_value is None:858 flag_value = not self.default859859 self.is_flag = is_flag860 self.flag_value = flag_value862 self.multiple = multiple863864 self.count = count865 if count and type is None:866 self.type = IntRange(min=0)867861 if self.is_flag and isinstance(self.flag_value, bool) \862 and type is None:863 self.type = BOOL864 self.is_bool_flag = True865 else:866 self.is_bool_flag = False867868 # Counting869 self.count = count870 if count:871 if type is None:872 self.type = IntRange(min=0)873 if default_is_missing:874 self.default = 0875876 self.multiple = multiple877 self.allow_from_autoenv = allow_from_autoenv878 self.help = help879 self.show_default = show_default880
197 unmodified lines
modified:tests/test_options.py+4 added
33 unmodified lines
34 assert result.exception35 assert 'Invalid value for "-v": 4 is not in the valid range of 0 to 3.' \36 in result.output3738 result = runner.invoke(cli, [])39 assert not result.exception40 assert result.output == 'verbosity=0\n'414243def test_multiple_required(runner):44 @click.command()45 @click.option('-m', '--message', multiple=True, required=True)46 def cli(message):
9 unmodified lines