compwa_policy.utilities.precommit package#

Submodules#

Module contents#

Helper functions for modifying .pre-commit.config.yaml.

class Precommit(document: PrecommitConfig, parser: YAML, source: IO | Path | None = None)[source]#

Bases: object

Read-only representation of a .pre-commit-config.yaml file.

property document: PrecommitConfig[source]#
property parser: YAML[source]#
property source: IO | Path | None[source]#
classmethod load(source: IO | Path | str = PosixPath('.pre-commit-config.yaml')) T[source]#

Load a pyproject.toml file from a file, I/O stream, or str.

dumps() str[source]#
find_repo(search_pattern: str) Repo | None[source]#

Find pre-commit repo definition in pre-commit config.

find_repo_with_index(search_pattern: str) tuple[int, Repo] | None[source]#

Find pre-commit repo definition and its index in pre-commit config.

class ModifiablePrecommit(document: PrecommitConfig, parser: YAML, source: IO | Path | None = None)[source]#

Bases: Precommit, AbstractContextManager

dump(target: IO | Path | str | None = None) None[source]#
property changelog: list[str][source]#
remove_hook(hook_id: str, repo_url: str | None = None) None[source]#
update_single_hook_repo(expected: Repo) None[source]#
update_hook(repo_url: str, expected_hook: Hook) None[source]#