File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def audit(session: Session) -> None:
3535 try :
3636 vulnerabilities = Vulnerabilities .load_from_pip_audit (working_directory = Path ())
3737 except PipAuditException as e :
38- session .error (e .return_code , e .stdout , e .stderr )
38+ session .error (e .returncode , e .stdout , e .stderr )
3939
4040 security_issue_dict = vulnerabilities .security_issue_dict
4141 print (json .dumps (security_issue_dict , indent = 2 ))
Original file line number Diff line number Diff line change 3232
3333@dataclass
3434class PipAuditException (Exception ):
35- return_code : int
35+ returncode : int
3636 stdout : str
3737 stderr : str
3838
39- def __init__ (self , subprocess_output : subprocess .CompletedProcess ) -> None :
40- self .return_code = subprocess_output .returncode
41- self .stdout = subprocess_output .stdout
42- self .stderr = subprocess_output .stderr
39+ @classmethod
40+ def from_subprocess (cls , proc : subprocess .CompletedProcess ) -> PipAuditException :
41+ return cls (proc .returncode , proc .stdout , proc .stderr )
4342
4443
4544class VulnerabilitySource (str , Enum ):
@@ -172,7 +171,7 @@ def audit_poetry_files(working_directory: Path) -> str:
172171 cwd = working_directory ,
173172 ) # nosec
174173 if output .returncode != 0 :
175- raise PipAuditException ( subprocess_output = output )
174+ raise PipAuditException . from_subprocess ( output )
176175
177176 with tempfile .TemporaryDirectory () as path :
178177 tmpdir = Path (path )
@@ -192,7 +191,7 @@ def audit_poetry_files(working_directory: Path) -> str:
192191 # they both map to returncode = 1, so we have our own logic to raise errors
193192 # for the case of 2) and not 1).
194193 if not search (PIP_AUDIT_VULNERABILITY_PATTERN , output .stderr .strip ()):
195- raise PipAuditException ( subprocess_output = output )
194+ raise PipAuditException . from_subprocess ( output )
196195 return output .stdout
197196
198197
You can’t perform that action at this time.
0 commit comments