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 May 31, 2024
1 parent 5630334 commit c8e6725
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 c8e6725

Please sign in to comment.