Skip to content

Commit

Permalink
buildchain, salt: use Python3 raise ... from ...
Browse files Browse the repository at this point in the history
Some future commit updates the version of `pylint` we use to validate
Python code, which adds a warning about using `raise ... from ...` when
applicable.
  • Loading branch information
NicolasT committed Dec 17, 2020
1 parent 4c3b462 commit 2209929
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions buildchain/buildchain/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def _get_image_info(name: str) -> versions.Image:
"""Retrieve an `Image` information by name from the versions listing."""
try:
return versions.CONTAINER_IMAGES_MAP[name]
except KeyError:
except KeyError as exc:
raise ValueError(
'Missing version for container image "{}"'.format(name)
)
) from exc

def _remote_image(
name: str, repository: str, **overrides: Any
Expand Down
8 changes: 4 additions & 4 deletions buildchain/buildchain/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ def task__build_deb_repositories() -> Iterator[types.TaskDict]:
def _rpm_package(name: str, sources: List[Path]) -> targets.RPMPackage:
try:
pkg_info = versions.RPM_PACKAGES_MAP[name]
except KeyError:
except KeyError as exc:
raise ValueError(
'Missing version for package "{}"'.format(name)
)
) from exc

# In case the `release` is of form "{build_id}.{os}", which is standard
build_id_str, _, _ = pkg_info.release.partition('.')
Expand Down Expand Up @@ -366,10 +366,10 @@ def _rpm_repository(
def _deb_package(name: str, sources: Path) -> targets.DEBPackage:
try:
pkg_info = versions.DEB_PACKAGES_MAP[name]
except KeyError:
except KeyError as exc:
raise ValueError(
'Missing version for package "{}"'.format(name)
)
) from exc

return targets.DEBPackage(
basename='_build_deb_packages',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def cleanup(volume_id):
device_path, str(exn)
),
exit_code=exn.errno,
)
) from exn
print("Device already freed")
finally:
os.close(device_handle)
Expand Down

0 comments on commit 2209929

Please sign in to comment.