Skip to content

Commit

Permalink
project: Fix raise-without-from-inside-except (B904)
Browse files Browse the repository at this point in the history
Derived from flake8-bugbear, see
https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
  • Loading branch information
pdgendt committed Nov 5, 2024
1 parent d5220dd commit be694ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/west/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ def delete(self, args):
try:
self.config.delete(args.name, configfile=configfile)
return
except KeyError:
except KeyError as err:
if i == len(configfiles) - 1:
self.dbg(
f'{args.name} was not set in requested location(s)')
raise CommandError(returncode=1)
raise CommandError(returncode=1) from err
except PermissionError as pe:
self._perm_error(pe, configfile, args.name)

Expand Down
4 changes: 2 additions & 2 deletions src/west/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def _get(self, option, getter):

try:
return getter(section, key)
except (configparser.NoOptionError, configparser.NoSectionError):
raise KeyError(option)
except (configparser.NoOptionError, configparser.NoSectionError) as err:
raise KeyError(option) from err

def set(self, option: str, value: Any):
section, key = _InternalCF.parse_key(option)
Expand Down
4 changes: 2 additions & 2 deletions src/west/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,12 +1920,12 @@ def get_option(option, default=None):
current_abspath = topdir_abspath / current_relpath
try:
current_data = current_abspath.read_text(encoding=Manifest.encoding)
except FileNotFoundError:
except FileNotFoundError as err:
raise MalformedConfig(
f'file not found: manifest file {current_abspath} '
'(from configuration options '
f'manifest.path="{manifest_path_option}", '
f'manifest.file="{manifest_file}")')
f'manifest.file="{manifest_file}")') from err

current_repo_abspath = topdir_abspath / manifest_path

Expand Down

0 comments on commit be694ed

Please sign in to comment.