1515
1616
1717class Status (str , Enum ):
18+ """Status of a report."""
19+
1820 SUCCESS = "SUCCESS"
1921 FAILURE = "FAILURE"
2022 SKIPPED = "SKIPPED"
2123
2224 def is_success (self ) -> bool :
25+ """Check if the status is success."""
2326 return self == Status .SUCCESS
2427
2528 def is_failure (self ) -> bool :
29+ """Check if the status is failure."""
2630 return self == Status .FAILURE
2731
2832 def is_skipped (self ) -> bool :
33+ """Check if the status is skipped."""
2934 return self == Status .SKIPPED
3035
3136
@@ -34,6 +39,16 @@ def is_skipped(self) -> bool:
3439
3540@define
3641class Report :
42+ """A report for a rule.
43+
44+ Attributes:
45+ id (RuleID): The ID of the rule.
46+ name (RuleName): The name of the rule.
47+ description (str): The description of the rule.
48+ status (Status): The status of the report.
49+ reasons (list[Reason] | None): The list of reasons for the report if the report is a failure or skipped.
50+ """
51+
3752 id : RuleID
3853 name : RuleName
3954 description : str
@@ -73,12 +88,29 @@ def make_failure(id: RuleID, name: RuleName, description: str, reasons: list[Rea
7388
7489@define
7590class SanityResult :
91+ """The result of a Sanity check.
92+
93+ Attributes:
94+ dataset_id (str): The ID of the dataset.
95+ version (str | None): The version of the dataset.
96+ reports (list[Report]): The list of reports.
97+ """
98+
7699 dataset_id : str
77100 version : str | None
78101 reports : list [Report ]
79102
80103 @classmethod
81104 def from_context (cls , context : SanityContext , reports : list [Report ]) -> Self :
105+ """Create a SanityResult from a SanityContext and a list of reports.
106+
107+ Args:
108+ context (SanityContext): The SanityContext to use.
109+ reports (list[Report]): The list of reports to include in the result.
110+
111+ Returns:
112+ The created SanityResult.
113+ """
82114 return cls (
83115 dataset_id = context .dataset_id .value_or ("UNKNOWN" ),
84116 version = context .version .value_or (None ),
0 commit comments