Validate the configuration against the parser.
(config: Dict[str, Any], parser: ArgumentParser)
| 17 | |
| 18 | |
| 19 | def validate_config(config: Dict[str, Any], parser: ArgumentParser) -> None: |
| 20 | """Validate the configuration against the parser.""" |
| 21 | actions = [action.dest for action in parser._actions] |
| 22 | for action in parser._actions: |
| 23 | if hasattr(action, "option_strings"): |
| 24 | actions.extend(opt.lstrip("-") for opt in action.option_strings) |
| 25 | |
| 26 | for key in config.keys(): |
| 27 | if key not in actions: |
| 28 | raise KeyError(f"Invalid configuration key: {key}") |
| 29 | return config |
| 30 | |
| 31 | |
| 32 | def get_args_from_config(config_file: str, parser: ArgumentParser) -> Namespace: |
no outgoing calls
no test coverage detected