RM003#

class src.ansys.pre_commit_hooks.quality_rules.readme.RM003#

Bases: README

README has a license badge matching project metadata.

Reads the license declared in [project].license of pyproject.toml and looks for a license badge for the same license. The declaration can be a license string, a license.text value, or a license.file path whose content is read. MIT, Apache-2.0, BSD-2-Clause and BSD-3-Clause are recognized. Any other license is matched by its declared text.

Notes

  • A missing badge, or a badge for a different license, produces a warning, including when there is no README file.

  • A warning is also produced when pyproject.toml is missing or invalid, or declares no license, because the badge cannot be verified.

Overview#

check

Return whether the README license badge matches project metadata.

Import detail#

from src.ansys.pre_commit_hooks.quality_rules.readme import RM003

Method detail#

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

Return whether the README license badge matches project metadata.

Parameters:
repository_rootpathlib.Path

Repository root directory.

readme_filestr or None

Name of the detected README file, or None if there is none.

Returns:
bool or str

True if a matching badge is found, otherwise a "WARNING: ..." message.