diff --git a/docs/cli/t4sanity.md b/docs/cli/t4sanity.md index fe074c9..09dd8d8 100644 --- a/docs/cli/t4sanity.md +++ b/docs/cli/t4sanity.md @@ -13,7 +13,6 @@ $ t4sanity -h │ --output -o TEXT Path to output JSON file. [default: None] │ │ --revision -rv TEXT Specify if you want to check the specific version. [default: None] │ │ --exclude -e TEXT Exclude specific rules or rule groups. [default: None] │ -│ --include-warning -iw Indicates whether to report any warnings. │ │ --strict -s Indicates whether warnings are treated as failures. │ │ --install-completion Install completion for the current shell. │ │ --show-completion Show completion for the current shell, to copy it or customize the installation. │ diff --git a/t4_devkit/cli/sanity.py b/t4_devkit/cli/sanity.py index facdcd2..6c5ed79 100644 --- a/t4_devkit/cli/sanity.py +++ b/t4_devkit/cli/sanity.py @@ -36,19 +36,14 @@ def main( excludes: list[str] | None = typer.Option( None, "-e", "--exclude", help="Exclude specific rules or rule groups." ), - include_warning: bool = typer.Option( - False, "-iw", "--include-warning", help="Indicates whether to report any warnings." - ), strict: bool = typer.Option( - False, "-s", "--strict", help="Indicates whether warnings are treated as failures." + False, + "-s", + "--strict", + help="By default, warnings do not cause failure. If set, warnings are treated as failures.", ), ) -> None: - result = sanity_check( - data_root=data_root, - revision=revision, - excludes=excludes, - include_warning=include_warning, - ) + result = sanity_check(data_root=data_root, revision=revision, excludes=excludes) print_sanity_result(result, strict=strict) diff --git a/t4_devkit/sanity/run.py b/t4_devkit/sanity/run.py index cd62ab9..ae91431 100644 --- a/t4_devkit/sanity/run.py +++ b/t4_devkit/sanity/run.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from typing import Sequence from .context import SanityContext @@ -14,7 +13,6 @@ def sanity_check( data_root: str, revision: str | None = None, *, - include_warning: bool = False, excludes: Sequence[str] | None = None, ) -> SanityResult: """Run sanity checks on the given data root. @@ -22,21 +20,14 @@ def sanity_check( Args: data_root (str): The root directory of the data. revision (str | None, optional): The revision to check. If None, the latest revision is used. - include_warning (bool, optional): Whether to include warning checks. excludes (Sequence[str] | None, optional): A list of rule names or groups to exclude. Returns: A SanityResult object. """ - with warnings.catch_warnings(): - if include_warning: - warnings.simplefilter("error") - else: - warnings.simplefilter("ignore") + context = SanityContext.from_path(data_root, revision=revision) - context = SanityContext.from_path(data_root, revision=revision) + checkers = CHECKERS.build(excludes=excludes) + reports = [checker(context) for checker in checkers] - checkers = CHECKERS.build(excludes=excludes) - reports = [checker(context) for checker in checkers] - - return SanityResult.from_context(context, reports) + return SanityResult.from_context(context, reports)