Check for none instead of falsy in arg matching

This commit is contained in:
Tulir Asokan 2020-07-11 16:23:00 +03:00
parent 03a1fdaaf5
commit 4e767a10e4

View File

@ -129,7 +129,7 @@ class CommandHandler:
try:
remaining_val, call_args[arg.name] = arg.match(remaining_val.strip(), evt=evt,
instance=self.__bound_instance__)
if arg.required and not call_args[arg.name]:
if arg.required and call_args[arg.name] is None:
raise ValueError("Argument required")
except ArgumentSyntaxError as e:
await evt.reply(e.message + (f"\n{self.__mb_usage__}" if e.show_usage else ""))
@ -303,7 +303,7 @@ class CustomArgument(Argument):
orig_val = val
val = re.split(r"\s", val, 1)[0]
res = self.matcher(val)
if res:
if res is not None:
return orig_val[len(val):], res
return orig_val, None