From 61bfc6140c7cc15cab932efaf789196d415912a7 Mon Sep 17 00:00:00 2001 From: jce Date: Fri, 29 Nov 2024 12:00:02 +0100 Subject: [PATCH] Fatal error when a mandatory key is missing from the config; no more print when a checker is not explicitly disabled in the config --- src/mlx/warnings/warnings.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mlx/warnings/warnings.py b/src/mlx/warnings/warnings.py index 4357b56e..ae13fef2 100644 --- a/src/mlx/warnings/warnings.py +++ b/src/mlx/warnings/warnings.py @@ -207,14 +207,15 @@ def config_parser(self, config): ''' # activate checker for checker in self.public_checkers: - try: + if checker.name in config: checker_config = config[checker.name] - if bool(checker_config['enabled']): - self.activate_checker(checker) - checker.parse_config(checker_config) - print("Config parsing for {name} completed".format(name=checker.name)) - except KeyError as err: - print("Incomplete config. Missing: {key}".format(key=err)) + try: + if bool(checker_config['enabled']): + self.activate_checker(checker) + checker.parse_config(checker_config) + print("Config parsing for {name} completed".format(name=checker.name)) + except KeyError as err: + raise WarningsConfigError(f"Incomplete config. Missing: {err}") from err def write_counted_warnings(self, out_file): ''' Writes counted warnings to the given file