Skip to content

Commit be694ed

Browse files
committed
project: Fix raise-without-from-inside-except (B904)
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>
1 parent d5220dd commit be694ed

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/west/app/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ def delete(self, args):
169169
try:
170170
self.config.delete(args.name, configfile=configfile)
171171
return
172-
except KeyError:
172+
except KeyError as err:
173173
if i == len(configfiles) - 1:
174174
self.dbg(
175175
f'{args.name} was not set in requested location(s)')
176-
raise CommandError(returncode=1)
176+
raise CommandError(returncode=1) from err
177177
except PermissionError as pe:
178178
self._perm_error(pe, configfile, args.name)
179179

src/west/configuration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def _get(self, option, getter):
9999

100100
try:
101101
return getter(section, key)
102-
except (configparser.NoOptionError, configparser.NoSectionError):
103-
raise KeyError(option)
102+
except (configparser.NoOptionError, configparser.NoSectionError) as err:
103+
raise KeyError(option) from err
104104

105105
def set(self, option: str, value: Any):
106106
section, key = _InternalCF.parse_key(option)

src/west/manifest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1920,12 +1920,12 @@ def get_option(option, default=None):
19201920
current_abspath = topdir_abspath / current_relpath
19211921
try:
19221922
current_data = current_abspath.read_text(encoding=Manifest.encoding)
1923-
except FileNotFoundError:
1923+
except FileNotFoundError as err:
19241924
raise MalformedConfig(
19251925
f'file not found: manifest file {current_abspath} '
19261926
'(from configuration options '
19271927
f'manifest.path="{manifest_path_option}", '
1928-
f'manifest.file="{manifest_file}")')
1928+
f'manifest.file="{manifest_file}")') from err
19291929

19301930
current_repo_abspath = topdir_abspath / manifest_path
19311931

0 commit comments

Comments
 (0)