Skip to content

Commit

Permalink
build/parser: detect invalid defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Dennison committed Dec 22, 2023
1 parent 98c19bb commit 37c8c01
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions litex/build/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def parse_args(self, args=None, namespace=None):
# 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)
Expand Down

0 comments on commit 37c8c01

Please sign in to comment.