build/parser: detect invalid defaults
This commit is contained in:
parent
4730ee2288
commit
0f7ea96812
|
@ -225,6 +225,13 @@ class LiteXArgumentParser(argparse.ArgumentParser):
|
|||
# Injects arguments default values
|
||||
if len(self._args_default):
|
||||
argparse.ArgumentParser.set_defaults(self, **self._args_default)
|
||||
# Catch defaults which do not match any arguments - typos?
|
||||
remaining = list(self._args_default.keys())
|
||||
for action in self._actions:
|
||||
if action.dest in remaining:
|
||||
remaining.remove(action.dest)
|
||||
if len(remaining) > 0:
|
||||
raise ValueError(f"set_default() for invalid argument(s): {remaining}")
|
||||
|
||||
# Parse args.
|
||||
self._args = argparse.ArgumentParser.parse_args(self, args, namespace)
|
||||
|
|
Loading…
Reference in New Issue