From 5969b4f29e4b4a12ada88b87f4ccfe669c742f2c Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 8 Jan 2024 07:47:55 +0100 Subject: [PATCH] style: silence bugbear warning B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling --- yamllint/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yamllint/config.py b/yamllint/config.py index 5f0ef91e..9ce62549 100644 --- a/yamllint/config.py +++ b/yamllint/config.py @@ -76,7 +76,7 @@ def parse(self, raw_content): try: conf = yaml.safe_load(raw_content) except Exception as e: - raise YamlLintConfigError(f'invalid config: {e}') + raise YamlLintConfigError(f'invalid config: {e}') from e if not isinstance(conf, dict): raise YamlLintConfigError('invalid config: not a dict') @@ -95,7 +95,7 @@ def parse(self, raw_content): try: self.extend(base) except Exception as e: - raise YamlLintConfigError(f'invalid config: {e}') + raise YamlLintConfigError(f'invalid config: {e}') from e if 'ignore' in conf and 'ignore-from-file' in conf: raise YamlLintConfigError( @@ -143,7 +143,7 @@ def validate(self): try: rule = yamllint.rules.get(id) except Exception as e: - raise YamlLintConfigError(f'invalid config: {e}') + raise YamlLintConfigError(f'invalid config: {e}') from e self.rules[id] = validate_rule_conf(rule, self.rules[id])