Closed effigies closed 3 years ago
I'm from MLH and I'm thinking of working on this issue, however I'm unsure of what type does default
take when multiple
is True
or when nargs
is set. Does it expect list/tuple or basically any iterable? Also will just putting the return
statement causing the TypeError inside a try
block suffice or do I add checks before returning?
multiple
or nargs
expect a list/tuple. multiple
and nargs
together expect a list/tuple of lists/tuples, although that's not particularly important here. For now any iterable should be allowed, that code is checking all value sources, not only the default. A try
block sounds fine, but I would isolate checking that it's iterable from doing the conversion, since the ParamType
might raise TypeError
for its own reasons:
try:
iter_value = iter(value)
except TypeError:
raise TypeError(...)
return tuple(... for x in iter_value)
Expected Behavior
In the following command, I add an option
--multiple
with the metadatamultiple=True
, but the defaultFalse
instead of[False]
.Ideally, the traceback should indicate that the
--multiple
option has a bad default.Actual Behavior
Tell us what happens instead.
I discovered this while running tests on pre-released dependencies, picking up click 8.0.0a1, which no longer accepts the above. The offending case was in a subcommand with many options, so it was not as obvious as it would be with a good error message.
Environment