Skip to content

Commit

Permalink
refactor: adhere to preview 'ruff' findings
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrake committed Nov 3, 2023
1 parent 9c7a85b commit 93e7a23
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/phylum/ci/ci_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from argparse import Namespace
from collections import OrderedDict
from functools import cached_property, lru_cache
from itertools import starmap
import json
import os
from pathlib import Path
Expand Down Expand Up @@ -114,8 +115,8 @@ def _find_potential_depfiles(self) -> None:
msg = "Phylum `find-lockable-files` command failed"
raise PhylumCalledProcessError(err, msg) from err
lockable_files: dict = json.loads(result)
self._potential_manifests = [LockfileEntry(*entry) for entry in lockable_files.get("manifests", [])]
self._potential_lockfiles = [LockfileEntry(*entry) for entry in lockable_files.get("lockfiles", [])]
self._potential_manifests = list(starmap(LockfileEntry, lockable_files.get("manifests", [])))
self._potential_lockfiles = list(starmap(LockfileEntry, lockable_files.get("lockfiles", [])))

@property
def potential_manifests(self) -> LockfileEntries:
Expand All @@ -141,7 +142,7 @@ def depfiles(self) -> Depfiles:
# flatten the list of lists
provided_arg_lockfiles = [LockfileEntry(path) for sub_list in arg_lockfiles for path in sub_list]
LOG.debug("Dependency files provided as arguments: %s", provided_arg_lockfiles)
valid_depfiles = self.filter_depfiles(provided_arg_lockfiles)
valid_depfiles = self._filter_depfiles(provided_arg_lockfiles)
if valid_depfiles:
LOG.debug("Valid provided dependency files: %s", valid_depfiles)
return valid_depfiles
Expand All @@ -154,7 +155,7 @@ def depfiles(self) -> Depfiles:
else:
LOG.debug("Detected dependency files: %s", detected_depfiles)
if detected_depfiles:
valid_depfiles = self.filter_depfiles(detected_depfiles)
valid_depfiles = self._filter_depfiles(detected_depfiles)
if valid_depfiles:
LOG.debug("Valid detected dependency files: %s", valid_depfiles)
return valid_depfiles
Expand All @@ -166,7 +167,7 @@ def depfiles(self) -> Depfiles:
raise SystemExit(textwrap.dedent(msg))

@progress_spinner("Filtering dependency files")
def filter_depfiles(self, provided_depfiles: LockfileEntries) -> Depfiles:
def _filter_depfiles(self, provided_depfiles: LockfileEntries) -> Depfiles:
"""Filter potential dependency files and return the valid ones in sorted order."""
depfiles: Depfiles = []
for provided_depfile in provided_depfiles:
Expand Down Expand Up @@ -541,9 +542,9 @@ def analyze(self) -> None:
If the command was expected to succeed, please report this as a bug."""
raise PhylumCalledProcessError(err, textwrap.dedent(msg)) from err

self.parse_analysis_result(analysis_result)
self._parse_analysis_result(analysis_result)

def parse_analysis_result(self, analysis_result: str) -> None:
def _parse_analysis_result(self, analysis_result: str) -> None:
"""Parse the results of a Phylum analysis command output."""
analysis = JobPolicyEvalResult(**json.loads(analysis_result))

Expand Down

0 comments on commit 93e7a23

Please sign in to comment.