Skip to content

Commit

Permalink
chore: remove file noqa from rhel oval parser (#361)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* use from e to set exception cause

Signed-off-by: Will Murphy <[email protected]>

---------

Signed-off-by: Will Murphy <[email protected]>
  • Loading branch information
willmurphyscode authored Oct 25, 2023
1 parent 42a8af2 commit c03bf3c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/vunnel/providers/rhel/oval_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# flake8: noqa
from __future__ import annotations

import bz2
Expand All @@ -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.
{
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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_:
Expand Down

0 comments on commit c03bf3c

Please sign in to comment.