From ca73a3b03f28f4a24799bb19cf8122ca25b7efd8 Mon Sep 17 00:00:00 2001 From: William Murphy Date: Thu, 1 Aug 2024 09:47:34 -0400 Subject: [PATCH] chore: remove unneeded noqa, enable lint for same (#648) Previously, RUF100 was disabled, meaning that ruff would pass even if there were noqa comments that were not needed. Remove unneeded noqa comments and enable this lint. This is important because unneeded noqa comments leave the door open for re-introducing linter errors that are previously fixed. Aside from the pyproject.toml change, this diff was generated by running: ruff check . --extend-select RUF100 --fix Signed-off-by: Will Murphy --- pyproject.toml | 1 - src/vunnel/cli/cli.py | 4 ++-- src/vunnel/provider.py | 2 +- src/vunnel/providers/amazon/parser.py | 2 +- src/vunnel/providers/github/parser.py | 2 +- src/vunnel/providers/nvd/manager.py | 2 +- src/vunnel/providers/nvd/overrides.py | 2 +- src/vunnel/providers/oracle/parser.py | 2 +- src/vunnel/providers/rhel/oval_parser.py | 2 +- src/vunnel/providers/rhel/parser.py | 2 +- src/vunnel/providers/ubuntu/git.py | 2 +- src/vunnel/providers/ubuntu/parser.py | 4 ++-- src/vunnel/providers/wolfi/parser.py | 4 ++-- src/vunnel/schema.py | 2 +- src/vunnel/utils/oval_parser.py | 2 +- 15 files changed, 17 insertions(+), 18 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 764cdad6..334a0bd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -187,7 +187,6 @@ ignore = [ "PGH004", # no blanked "noqa" usage, can be improved over time, but not now "PLR2004", # a little too agressive, not allowing any magic numbers "PLW2901", # "Outer for loop variable X overwritten by inner assignment target", not useful in most cases - "RUF100", # no blanket "noqa" usage, can be improved over time, but not now "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` -- not compatible with python 3.9 (even with __future__ import) ] diff --git a/src/vunnel/cli/cli.py b/src/vunnel/cli/cli.py index 5967dbdc..7183f48f 100644 --- a/src/vunnel/cli/cli.py +++ b/src/vunnel/cli/cli.py @@ -92,7 +92,7 @@ def show_config(cfg: config.Application) -> None: logging.info("showing application config") class IndentDumper(yaml.Dumper): - def increase_indent(self, flow: bool = False, indentless: bool = False) -> None: # noqa: ARG002 + def increase_indent(self, flow: bool = False, indentless: bool = False) -> None: return super().increase_indent(flow, False) def enum_asdict_factory(data: list[tuple[str, Any]]) -> dict[Any, Any]: @@ -189,7 +189,7 @@ class CurrentState: error: str | None = None enabled: bool = True - def format(self, fill: str) -> str: # noqa: A003 + def format(self, fill: str) -> str: if self.error: return f"""\ {fill} unable to load state: {self.error}""" diff --git a/src/vunnel/provider.py b/src/vunnel/provider.py index e9fbea85..b48c3dd7 100644 --- a/src/vunnel/provider.py +++ b/src/vunnel/provider.py @@ -44,7 +44,7 @@ class OnErrorConfig: # the number of seconds to wait between retries retry_delay: int = 5 # what to do with the input directory when an error occurs - input: InputStatePolicy = InputStatePolicy.KEEP # noqa: A003 + input: InputStatePolicy = InputStatePolicy.KEEP # what to do with the result directory when an error occurs results: ResultStatePolicy = ResultStatePolicy.KEEP diff --git a/src/vunnel/providers/amazon/parser.py b/src/vunnel/providers/amazon/parser.py index b9774ab0..b9301b9a 100644 --- a/src/vunnel/providers/amazon/parser.py +++ b/src/vunnel/providers/amazon/parser.py @@ -36,7 +36,7 @@ class Parser: _rss_file_name_ = "{}_rss.xml" _html_dir_name_ = "{}_html" - def __init__( # noqa: PLR0913 + def __init__( self, workspace, download_timeout=125, diff --git a/src/vunnel/providers/github/parser.py b/src/vunnel/providers/github/parser.py index b04418f7..6c05ea88 100644 --- a/src/vunnel/providers/github/parser.py +++ b/src/vunnel/providers/github/parser.py @@ -49,7 +49,7 @@ class Parser: - def __init__( # noqa: PLR0913 + def __init__( self, workspace, token, diff --git a/src/vunnel/providers/nvd/manager.py b/src/vunnel/providers/nvd/manager.py index e1b862bf..5efa6a8b 100644 --- a/src/vunnel/providers/nvd/manager.py +++ b/src/vunnel/providers/nvd/manager.py @@ -45,7 +45,7 @@ def __init__( # noqa: PLR0913 download_timeout=download_timeout, ) - self.urls = [self.api._cve_api_url_] # noqa: SLF001 + self.urls = [self.api._cve_api_url_] self.schema = schema def get( diff --git a/src/vunnel/providers/nvd/overrides.py b/src/vunnel/providers/nvd/overrides.py index aa549df6..4a61cf01 100644 --- a/src/vunnel/providers/nvd/overrides.py +++ b/src/vunnel/providers/nvd/overrides.py @@ -17,7 +17,7 @@ class NVDOverrides: __file_name__ = "nvd-overrides.tar.gz" __extract_name__ = "nvd-overrides" - def __init__( # noqa: PLR0913 + def __init__( self, enabled: bool, url: str, diff --git a/src/vunnel/providers/oracle/parser.py b/src/vunnel/providers/oracle/parser.py index 771303fc..6a45af37 100644 --- a/src/vunnel/providers/oracle/parser.py +++ b/src/vunnel/providers/oracle/parser.py @@ -115,7 +115,7 @@ def _is_ksplice_version(cls, version) -> bool: epoch, version, release = rpm.split_fullversion(version) return cls.ksplice_regex.match(release) is not None - def filter(self, vuln_dict: dict) -> dict: # noqa: A003 + def filter(self, vuln_dict: dict) -> dict: """ Filters affected packages and ELSAs that are for ksplice packages since the matching logic for these in Grype isn't diff --git a/src/vunnel/providers/rhel/oval_parser.py b/src/vunnel/providers/rhel/oval_parser.py index 00631297..0d91226e 100644 --- a/src/vunnel/providers/rhel/oval_parser.py +++ b/src/vunnel/providers/rhel/oval_parser.py @@ -67,7 +67,7 @@ def _download_oval_file(self, base_url: str, oval_url_path: str): extracted.write(uncchunk) self.logger.info(f"finish downloading OVAL file from {oval_url}") - else: # noqa: RET505 + else: raise Exception(f"GET {oval_url} failed with HTTP error {r.status_code}") except Exception: self.logger.exception("error downloading OVAL file") diff --git a/src/vunnel/providers/rhel/parser.py b/src/vunnel/providers/rhel/parser.py index 344928b6..ef40bc12 100644 --- a/src/vunnel/providers/rhel/parser.py +++ b/src/vunnel/providers/rhel/parser.py @@ -866,7 +866,7 @@ def get(self, skip_if_exists=False): class AffectedRelease: - def __init__(self, name=None, version=None, platform=None, rhsa_id=None, module=None): # noqa: PLR0913 + def __init__(self, name=None, version=None, platform=None, rhsa_id=None, module=None): self.name = name self.version = version self.platform = platform diff --git a/src/vunnel/providers/ubuntu/git.py b/src/vunnel/providers/ubuntu/git.py index 6078cb6d..2af3f765 100644 --- a/src/vunnel/providers/ubuntu/git.py +++ b/src/vunnel/providers/ubuntu/git.py @@ -53,7 +53,7 @@ class GitWrapper: _head_rev_cmd_ = "git rev-parse HEAD" _ubuntu_server_503_message = "error: RPC failed; HTTP 503 curl 22 The requested URL returned error: 503" - def __init__( # noqa: PLR0913 + def __init__( self, source: str, branch: str, diff --git a/src/vunnel/providers/ubuntu/parser.py b/src/vunnel/providers/ubuntu/parser.py index 0882ca99..8b541ff6 100644 --- a/src/vunnel/providers/ubuntu/parser.py +++ b/src/vunnel/providers/ubuntu/parser.py @@ -742,7 +742,7 @@ def worker(fn, cve_id: str, *args, **kwargs): self._delete_merged_cve(cve_id) self.logger.info("finish processing deletes") - def _process_cve( # noqa: PLR0913 + def _process_cve( self, cve_id: str, cve_rel_path: str, @@ -982,7 +982,7 @@ def _merge_cve(self, cve_id: str, cve_rel_path: str, cve_abs_path: str, repo_cur return parsed_cve - def _resolve_patches_using_history( # noqa: C901, PLR0912, PLR0915, PLR0913 + def _resolve_patches_using_history( # noqa: C901, PLR0912, PLR0915 self, cve_id: str, cve_rel_path: str, diff --git a/src/vunnel/providers/wolfi/parser.py b/src/vunnel/providers/wolfi/parser.py index 85b356e4..eab90366 100644 --- a/src/vunnel/providers/wolfi/parser.py +++ b/src/vunnel/providers/wolfi/parser.py @@ -14,13 +14,13 @@ class Parser: _release_ = "rolling" _secdb_dir_ = "secdb" - def __init__( # noqa: PLR0913 + def __init__( self, workspace, url: str, namespace: str, download_timeout: int = 125, - logger: logging.Logger | None = None, # noqa: PLR0913 + logger: logging.Logger | None = None, ): self.download_timeout = download_timeout self.secdb_dir_path = os.path.join(workspace.input_path, self._secdb_dir_) diff --git a/src/vunnel/schema.py b/src/vunnel/schema.py index 18c4cfda..e5d1f898 100644 --- a/src/vunnel/schema.py +++ b/src/vunnel/schema.py @@ -54,7 +54,7 @@ def MatchExclusionSchema(version: str = MATCH_EXCLUSION_SCHEMA_VERSION) -> Schem def GithubSecurityAdvisorySchema(version: str = GITHUB_SECURITY_ADVISORY_SCHEMA_VERSION) -> Schema: return Schema( version=version, - url=f"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/github-security-advisory/schema-{version}.json", # noqa: E501 + url=f"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/github-security-advisory/schema-{version}.json", ) diff --git a/src/vunnel/utils/oval_parser.py b/src/vunnel/utils/oval_parser.py index 44352340..e1f8f94d 100644 --- a/src/vunnel/utils/oval_parser.py +++ b/src/vunnel/utils/oval_parser.py @@ -58,7 +58,7 @@ def get_opener(filename: str) -> Callable: return open -def parse(dest_file: str, config: Config, vuln_dict: dict | None = None): # noqa: C901, PLR0912 +def parse(dest_file: str, config: Config, vuln_dict: dict | None = None): """ Parse the oval file and return a dictionary with tuple (ID, namespace) as the key and tuple (version, vulnerability-dictionary) as the value