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: ExplicitCollection[Path | str] = (), patterns: ExplicitCollection[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]#
Check#

A policy transformation that shares a session, arguments, and check context.

alias of Callable[[Session, Arguments, CheckContext], None]

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: Group, paths: ExplicitCollection[Path | str] = (), directories: ExplicitCollection[Path | str] = (), patterns: ExplicitCollection[str] = (), enabled: Callable[[Arguments, CheckContext], bool] = <function _always_enabled>) → Callable[[Check], CheckHook][source]#

Attach dispatch and trigger metadata to a check function.