check_hook#

Contract for transformations run by check-dev-files.

class FileSet(paths: tuple[Path, ...] = (), directories: tuple[Path, ...] = (), patterns: tuple[str, ...] = ())[source]#

Bases: object

Paths whose staged modification should activate a check hook.

Directories match every file below them. Patterns are regular-expression alternatives for path families that cannot be expressed as one exact path.

paths: tuple[Path, ...][source]#
directories: tuple[Path, ...][source]#
patterns: tuple[str, ...][source]#
classmethod create(*paths: Path | str, directories: Iterable[Path | str] = (), patterns: Iterable[str] = ()) Self[source]#
classmethod union(file_sets: tuple[FileSet, ...]) Self[source]#
to_regex() str[source]#
class CheckContext(is_python_repo: bool, has_notebooks: bool, doc_apt_packages: list[str], environment_variables: dict[str, str])[source]#

Bases: object

Repository properties that are derived once and shared by every check.

is_python_repo: bool[source]#
has_notebooks: bool[source]#
doc_apt_packages: list[str][source]#
environment_variables: dict[str, str][source]#
class CheckHook(group: ~typing.Literal['python', 'github', 'env', 'nb', 'format', 'repo'], files: ~compwa_policy.utilities.check_hook.FileSet, run: ~collections.abc.Callable[[~compwa_policy.utilities.session.Session, ~compwa_policy.Arguments, ~compwa_policy.utilities.check_hook.CheckContext], None], enabled: ~collections.abc.Callable[[~compwa_policy.Arguments, ~compwa_policy.utilities.check_hook.CheckContext], bool] = <function _always_enabled>)[source]#

Bases: object

One policy transformation together with its dispatch metadata.

group: Literal['python', 'github', 'env', 'nb', 'format', 'repo'][source]#
files: FileSet[source]#
run: Callable[[Session, Arguments, CheckContext], None][source]#
enabled: Callable[[Arguments, CheckContext], bool][source]#
check_hook(*, group: ~typing.Literal['python', 'github', 'env', 'nb', 'format', 'repo'], paths: ~collections.abc.Iterable[~pathlib.Path | str] = (), directories: ~collections.abc.Iterable[~pathlib.Path | str] = (), patterns: ~collections.abc.Iterable[str] = (), enabled: ~collections.abc.Callable[[~compwa_policy.Arguments, ~compwa_policy.utilities.check_hook.CheckContext], bool] = <function _always_enabled>) Callable[[Callable[[Session, Arguments, CheckContext], None]], CheckHook][source]#

Attach dispatch and trigger metadata to a check function.