PreCommit#

class src.ansys.pre_commit_hooks.quality_rules.pre_commit.PreCommit#

Bases: abc.ABC

Pre-commit rule family.

Base class of the pre-commit quality rules. Each rule is a subclass named PC with a static check method that evaluates the repository’s pre-commit configuration independently. Missing or unreadable configuration is reported as an error rather than skipped. Rules for optional hooks report a RECOMMENDATION instead of an error when the hook is absent.

Overview#

check

Evaluate a pre-commit rule.

Import detail#

from src.ansys.pre_commit_hooks.quality_rules.pre_commit import PreCommit

Attribute detail#

PreCommit.family: ClassVar[str] = 'pre_commit'#

Method detail#

static PreCommit.check(repository_root: pathlib.Path, readme_file: str | None) → ansys.pre_commit_hooks.quality_rules.common.RuleCheckResult#
Abstractmethod:

Evaluate a pre-commit rule.

Parameters:
repository_rootpathlib.Path

Repository root directory.

readme_filestr or None

Detected README path, unused by this rule family.

Returns:
bool or str

True when the rule passes, False for an error, or a string prefixed with "RECOMMENDATION: " or "ERROR: ".