Report

Report(results=list(), package_path='')

Collection of check results for a package.

A Report aggregates multiple CheckResult objects and provides methods for querying the overall status and summarizing results.

Attributes

results : list[CheckResult]

List of CheckResult objects from running checks.

package_path : str

Path to the package that was checked.

Examples

Create a report and add results:

>>> report = Report(package_path="/path/to/package")
>>> report.add(CheckResult("metadata", CheckStatus.OK, "Valid"))
>>> report.add(CheckResult("tests", CheckStatus.OK, "Passed"))
>>> report.passed
True

Check for specific failure conditions:

>>> report.failed_on(["error"])
False
>>> report.failed_on(["error", "warning"])
False

Methods

Name Description
add Add a check result to the report.
count_by_status Count results by status.
failed_on Check if any result matches the fail_on criteria.
to_dict Convert to dictionary for JSON serialization.

add

Report.add(result)

Add a check result to the report.

Parameters

result : CheckResult

The CheckResult to add.

Examples

>>> report = Report()
>>> report.add(CheckResult("test", CheckStatus.OK, "Passed"))
>>> len(report.results)
1

count_by_status

Report.count_by_status()

Count results by status.

Returns

: dict[CheckStatus, int]

A dictionary mapping each CheckStatus to the count of results

: dict[CheckStatus, int]

with that status.

Examples

>>> report = Report()
>>> report.add(CheckResult("a", CheckStatus.OK, "OK"))
>>> report.add(CheckResult("b", CheckStatus.OK, "OK"))
>>> report.add(CheckResult("c", CheckStatus.WARNING, "Warn"))
>>> counts = report.count_by_status()
>>> counts[CheckStatus.OK]
2
>>> counts[CheckStatus.WARNING]
1

failed_on

Report.failed_on(fail_on)

Check if any result matches the fail_on criteria.

Parameters

fail_on : list[str]

List of status values to consider as failures (e.g., [“error”, “warning”]).

Returns

: bool

True if any result has a status in the fail_on list.

Examples

>>> report = Report()
>>> report.add(CheckResult("test", CheckStatus.WARNING, "Warn"))
>>> report.failed_on(["error"])
False
>>> report.failed_on(["error", "warning"])
True

to_dict

Report.to_dict()

Convert to dictionary for JSON serialization.

Returns

: dict[str, Any]

A dictionary containing:

: dict[str, Any]
  • package_path: The path that was checked
: dict[str, Any]
  • passed: Whether all checks passed
: dict[str, Any]
  • summary: Count of each status
: dict[str, Any]
  • results: List of result dictionaries

Examples

>>> report = Report(package_path="/pkg")
>>> report.add(CheckResult("test", CheckStatus.OK, "OK"))
>>> data = report.to_dict()
>>> data["passed"]
True
>>> data["summary"]["ok"]
1