From 66c2f07ca81649417347d85925cf33c5821f5929 Mon Sep 17 00:00:00 2001 From: mr-tz Date: Wed, 31 Jan 2024 11:25:32 +0100 Subject: [PATCH] remove BaseException usage --- scripts/lint.py | 5 ++--- scripts/setup-linter-dependencies.py | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/lint.py b/scripts/lint.py index 49ff70e6..b63c5346 100644 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -309,9 +309,8 @@ class InvalidAttckOrMbcTechnique(Lint): with data_path.open("rb") as fd: self.data = json.load(fd) self.enabled_frameworks = self.data.keys() - except BaseException: - # If linter-data.json is not present, or if an error happen - # we log an error and lint nothing. + except (FileNotFoundError, json.decoder.JSONDecodeError): + # linter-data.json missing, or JSON error: log an error and skip this lint logger.warning( "Could not load 'scripts/linter-data.json'. The att&ck and mbc information will not be linted." ) diff --git a/scripts/setup-linter-dependencies.py b/scripts/setup-linter-dependencies.py index cc8c0310..09a5feef 100644 --- a/scripts/setup-linter-dependencies.py +++ b/scripts/setup-linter-dependencies.py @@ -178,11 +178,8 @@ def main(args: argparse.Namespace) -> None: data["mbc"] = MbcExtractor().run() logging.info("Writing results to %s", args.output) - try: - with Path(args.output).open("w", encoding="utf-8") as jf: - json.dump(data, jf, indent=2) - except BaseException as e: - logging.error("Exception encountered when writing results: %s", e) + with Path(args.output).open("w", encoding="utf-8") as jf: + json.dump(data, jf, indent=2) if __name__ == "__main__":