Skip to content

Commit e88856c

Browse files
committed
fix typo and clean up wait_until_complete checks
1 parent b5da690 commit e88856c

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

python/lib/sift_client/resources/reports.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ async def wait_until_complete(
353353
job is not a rule evaluation job.
354354
"""
355355
if report is not None and job is not None:
356-
raise ValueError("exactly one of report or report_job must be provided")
356+
raise ValueError("exactly one of report or job must be provided")
357+
if report is None and job is None:
358+
raise ValueError("either report or job must be provided")
357359

358360
report_id: str | None = None
359361
job_id: str | None = None
@@ -365,25 +367,20 @@ async def wait_until_complete(
365367
else:
366368
job_id = report.job_id
367369
report_id = report.id_
368-
elif job is not None:
370+
else:
369371
if isinstance(job, str):
370372
job_obj = await self.client.async_.jobs.get(job_id=job)
371-
if not isinstance(job_obj.job_details, RuleEvaluationDetails):
372-
raise ValueError("job is not a rule evaluation job")
373373
job_id = job
374-
report_id = job_obj.job_details.report_id
374+
job_details = job_obj.job_details
375375
else:
376-
if not isinstance(job.job_details, RuleEvaluationDetails):
377-
raise ValueError("job is not a rule evaluation job")
378376
job_id = job.id_
379-
report_id = job.job_details.report_id
380-
else:
381-
raise ValueError("either report or job must be provided")
377+
job_details = job.job_details
378+
if not isinstance(job_details, RuleEvaluationDetails):
379+
raise ValueError("job is not a rule evaluation job")
380+
report_id = job_details.report_id
382381

383-
if not report_id:
384-
raise ValueError("report_id must be set")
385-
if not job_id:
386-
raise ValueError("job_id must be set")
382+
if not report_id or not job_id:
383+
raise ValueError("report_id and job_id must be set")
387384

388385
await self.client.async_.jobs.wait_until_complete(
389386
job=job_id,

0 commit comments

Comments
 (0)