The common.py module#
Summary#
Public status of a quality rule. |
Return whether a repository file exists. |
|
Read a repository file (as UTF-8) without allowing path traversal. |
|
Return the merged text of the GitHub Actions workflow files. |
|
Return the preferred README path for a repository. |
|
|
Return the first non-empty line of a rule check docstring. |
Normalize a rule return value into a public status and detail. |
Description#
Shared helpers for quality check rules.
Module detail#
- common.file_exists(repository_root: pathlib.Path, relative_path: str) bool#
Return whether a repository file exists.
- Parameters:
- repository_root
pathlib.Path Root directory that contains the file.
- relative_path
str File path relative to
repository_root.
- repository_root
- Returns:
- bool
Truewhen the path resolves to a regular file within the repository, otherwiseFalse.
- common.file_content(repository_root: pathlib.Path, relative_path: str) str | None#
Read a repository file (as UTF-8) without allowing path traversal.
- Parameters:
- repository_root
pathlib.Path Root directory that contains the file.
- relative_path
str File path relative to
repository_root.
- repository_root
- Returns:
- common.all_workflows_content(repository_root: pathlib.Path) str | None#
Return the merged text of the GitHub Actions workflow files.
- Parameters:
- repository_root
pathlib.Path Root directory that contains
.github/workflows.
- repository_root
- Returns:
- common.readme_path(repository_root: pathlib.Path) str | None#
Return the preferred README path for a repository.
- Parameters:
- repository_root
pathlib.Path Repository root directory.
- repository_root
- Returns:
- common.normalize_check_result(raw_result: object, rule: _QualityRule) tuple[RuleStatus, str]#
Normalize a rule return value into a public status and detail.
- common.PASSED: Final[RuleStatus]#
- common.WARNING: Final[RuleStatus]#
- common.ERROR: Final[RuleStatus]#