Skip to content
Myr

Fixed a bug in argument handling

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 c7299c4 · Browse files · 2 files+12 added−1 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+12 added−1 removed

  • tests:+11 added−0 removed
  • other:+1 added−1 removed

2 files+12 added−1 removed

modified:click/core.py+1 added-1 removed
1171 unmodified lines
1172 if required is None:1173 if attrs.get('default') is not None:1174 required = False1175 else:1176 required = attrs.get('nargs', 0) > 01176 required = attrs.get('nargs', 1) > 01177 Parameter.__init__(self, param_decls, required=required, **attrs)11781179 def make_metavar(self):1180 if self.metavar is not None:
31 unmodified lines
modified:tests/test_arguments.py+11 added
143 unmodified lines
144 assert result.exit_code == 2145 assert 'Missing argument "arg"' in result.output146147148def test_missing_arg(runner):149 @click.command()150 @click.argument('arg')151 def cmd(arg):152 click.echo('arg:' + arg)153154 result = runner.invoke(cmd, [])155 assert result.exit_code == 2156 assert 'Missing argument "arg".' in result.output157158159def test_implicit_non_required(runner):160 @click.command()161 @click.argument('f', default='test')162 def cli(f):
29 unmodified lines