Skip to content

Commit f6a71f5

Browse files
committed
style: add docstrings
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent fdae2b3 commit f6a71f5

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

t4_devkit/sanity/result.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@
1515

1616

1717
class 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
3641
class 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
7590
class 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),

t4_devkit/sanity/run.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ def sanity_check(
1717
include_warning: bool = False,
1818
excludes: Sequence[str] | None = None,
1919
) -> SanityResult:
20+
"""Run sanity checks on the given data root.
21+
22+
Args:
23+
data_root (str): The root directory of the data.
24+
revision (str | None, optional): The revision to check. If None, the latest revision is used.
25+
include_warning (bool, optional): Whether to include warning checks.
26+
excludes (Sequence[str] | None, optional): A list of rule names or groups to exclude.
27+
28+
Returns:
29+
A SanityResult object.
30+
"""
2031
with warnings.catch_warnings():
2132
if include_warning:
2233
warnings.simplefilter("error")

0 commit comments

Comments
 (0)