Fix required=True not accounted for for simple argument
CommandHandler.__parse_args__ checks for the None value returned Argument.match() to possibly raise if no value got passed to a *required* argument. Unfortunately, SimpleArgument.match() never returns None but would instead return the empty string it receives (which is being stripped by the caller, __parse_args__()). As such, `@argument(..., required=True)` does not work and silently passes an empty string to the command handler. We fix this returning None early in SimpleArgument.match() when it receives an empty string value.
This commit is contained in:
parent
b4e8e5bfbb
commit
8220bcedf6
@ -403,6 +403,8 @@ class CustomArgument(Argument):
|
|||||||
|
|
||||||
class SimpleArgument(Argument):
|
class SimpleArgument(Argument):
|
||||||
def match(self, val: str, **kwargs) -> Tuple[str, Any]:
|
def match(self, val: str, **kwargs) -> Tuple[str, Any]:
|
||||||
|
if not val:
|
||||||
|
return "", None
|
||||||
if self.pass_raw:
|
if self.pass_raw:
|
||||||
return "", val
|
return "", val
|
||||||
res = re.split(r"\s", val, 1)[0]
|
res = re.split(r"\s", val, 1)[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user