From c03bf3c412fe4b7c4a9b92fb6a712c23356e5753 Mon Sep 17 00:00:00 2001 From: William Murphy Date: Wed, 25 Oct 2023 10:45:05 -0400 Subject: [PATCH] chore: remove file noqa from rhel oval parser (#361) * chore: remove file level noqa for rhel oval parser Switch to linter suppressions on individual lines so that the set of suppressed rules stops growing. Accept some automatic fixes. Signed-off-by: Will Murphy * use from e to set exception cause Signed-off-by: Will Murphy --------- Signed-off-by: Will Murphy --- src/vunnel/providers/rhel/oval_parser.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/vunnel/providers/rhel/oval_parser.py b/src/vunnel/providers/rhel/oval_parser.py index 6309a92f..a1dbcec4 100644 --- a/src/vunnel/providers/rhel/oval_parser.py +++ b/src/vunnel/providers/rhel/oval_parser.py @@ -1,4 +1,3 @@ -# flake8: noqa from __future__ import annotations import bz2 @@ -14,7 +13,7 @@ class Parser: - _url_mappings_ = [ + _url_mappings_ = [ # noqa: RUF012 # Legacy data for RHEL:5 - no longer available from endpoint after 1st July, 2023; however, it is available in the # preload archive. { @@ -85,12 +84,12 @@ def _get_sha256_map(self, base_url: str, manifest_path: str, oval_paths: list[st self.logger.info(f"finish processing manifest from {manifest_url}") return path_to_sha - else: + else: # noqa: RET505 error = f"GET {manifest_url} failed with HTTP error {r.status_code}" self.logger.error(error) raise Exception(error) - except: - raise Exception("Error fetching/processing sha256") + except Exception as e: + raise Exception("Error fetching/processing sha256") from e @utils.retry_with_backoff() def _download_oval_file(self, base_url: str, oval_url_path: str, path_to_sha: dict[str, str]) -> str: @@ -136,11 +135,11 @@ def _download_oval_file(self, base_url: str, oval_url_path: str, path_to_sha: di fp.write(sha256sum) return sha256sum - else: + else: # noqa: RET505 raise Exception(f"GET {oval_url} failed with HTTP error {r.status_code}") except Exception: self.logger.exception("error downloading OVAL file") - raise Exception("error downloading OVAL file") + raise Exception("error downloading OVAL file") # noqa: B904 else: self.logger.info(f"stored checksum matches server checksum for {xml_file_path}. Skipping download") return latest_sha256 @@ -165,8 +164,6 @@ def _download(self): if not skip_download: self._download_oval_file(base_url, p, path_to_sha) - return None - def xml_paths(self): paths = [] for m in self._url_mappings_: