class Hook(NamedTuple):
    src: str
    prefix: Prefix
    id: str
    name: str
    entry: str
    language: str
    alias: str
    files: str
    exclude: str
    types: Sequence[str]
    types_or: Sequence[str]
    exclude_types: Sequence[str]
    additional_dependencies: Sequence[str]
    args: Sequence[str]
    always_run: bool
    fail_fast: bool
    pass_filenames: bool
    description: str
    language_version: str
    log_file: str
    minimum_pre_commit_version: str
    require_serial: bool
    stages: Sequence[str]
    verbose: bool

    @property
    def cmd(self) -> tuple[str, ...]:
        return (*shlex.split(self.entry), *self.args)

    @property
    def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
        return (
            self.prefix,
            self.language,
            self.language_version,
            tuple(self.additional_dependencies),
        )

    @classmethod
    def create(cls, src: str, prefix: Prefix, dct: dict[str, Any]) -> Hook:
        # TODO: have cfgv do this (?)
        extra_keys = set(dct) - _KEYS
        if extra_keys:
            logger.warning(
                f'Unexpected key(s) present on {src} => {dct["id"]}: '
                f'{", ".join(sorted(extra_keys))}',
            )
        return cls(src=src, prefix=prefix, **{k: dct[k] for k in _KEYS}) ENVIRONMENT_DIR = 'conda'
def get_env_patch(env: str) -> PatchesT:
def in_env(
        prefix: Prefix,
        language_version: str,
) -> Generator[None, None, None]:
def _conda_exe() -> str:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'coursier'
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:   # pragma: win32 no cover
def get_env_patch(target_dir: str) -> PatchesT:   # pragma: win32 no cover
def in_env(
        prefix: Prefix,
) -> Generator[None, None, None]:   # pragma: win32 no cover
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]:   # pragma: win32 no cover ENVIRONMENT_DIR = 'dartenv'
def get_env_patch(venv: str) -> PatchesT:
def in_env(prefix: Prefix) -> Generator[None, None, None]:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
    def _install_dir(prefix_p: Prefix, pub_cache: str) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'docker'
PRE_COMMIT_LABEL = 'PRE_COMMIT'
def _is_in_docker() -> bool:
def _get_container_id() -> str:
def _get_docker_path(path: str) -> str:
def md5(s: str) -> str:  # pragma: win32 no cover
def docker_tag(prefix: Prefix) -> str:  # pragma: win32 no cover
def build_docker_image(
        prefix: Prefix,
        *,
        pull: bool,
) -> None:  # pragma: win32 no cover
def install_environment(
        prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None:  # pragma: win32 no cover
def get_docker_user() -> tuple[str, ...]:  # pragma: win32 no cover
def docker_cmd() -> tuple[str, ...]:  # pragma: win32 no cover
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]:  # pragma: win32 no cover ENVIRONMENT_DIR = None
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]:  # pragma: win32 no cover ENVIRONMENT_DIR = 'dotnetenv'
BIN_DIR = 'bin'
def get_env_patch(venv: str) -> PatchesT:
def in_env(prefix: Prefix) -> Generator[None, None, None]:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = None
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'golangenv'
def get_env_patch(venv: str) -> PatchesT:
def in_env(prefix: Prefix) -> Generator[None, None, None]:
def guess_go_dir(remote_url: str) -> str:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'lua_env'
def _get_lua_version() -> str:  # pragma: win32 no cover
def get_env_patch(d: str) -> PatchesT:  # pragma: win32 no cover
def _envdir(prefix: Prefix) -> str:  # pragma: win32 no cover
def in_env(prefix: Prefix) -> Generator[None, None, None]:
def install_environment(
    prefix: Prefix,
    version: str,
    additional_dependencies: Sequence[str],
) -> None:  # pragma: win32 no cover
def run_hook(
    hook: Hook,
    file_args: Sequence[str],
    color: bool,
) -> tuple[int, bytes]:  # pragma: win32 no cover ENVIRONMENT_DIR = 'node_env'
def get_default_version() -> str:
def _envdir(prefix: Prefix, version: str) -> str:
def get_env_patch(venv: str) -> PatchesT:
def in_env(
        prefix: Prefix,
        language_version: str,
) -> Generator[None, None, None]:
def healthy(prefix: Prefix, language_version: str) -> bool:
def install_environment(
        prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'perl_env'
def _envdir(prefix: Prefix, version: str) -> str:
def get_env_patch(venv: str) -> PatchesT:
def in_env(
        prefix: Prefix,
        language_version: str,
) -> Generator[None, None, None]:
def install_environment(
        prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = None
FNS = {
    Choice(multiline=True, negate=True): _process_filename_at_once_negated,
    Choice(multiline=True, negate=False): _process_filename_at_once,
    Choice(multiline=False, negate=True): _process_filename_by_line_negated,
    Choice(multiline=False, negate=False): _process_filename_by_line,
}
def _process_filename_by_line(pattern: Pattern[bytes], filename: str) -> int:
def _process_filename_at_once(pattern: Pattern[bytes], filename: str) -> int:
def _process_filename_by_line_negated(
        pattern: Pattern[bytes],
        filename: str,
) -> int:
def _process_filename_at_once_negated(
        pattern: Pattern[bytes],
        filename: str,
) -> int:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]:
def main(argv: Sequence[str] | None = None) -> int:
class Choice(NamedTuple): ENVIRONMENT_DIR = 'py_env'
def _version_info(exe: str) -> str:
def _read_pyvenv_cfg(filename: str) -> dict[str, str]:
def bin_dir(venv: str) -> str:
def get_env_patch(venv: str) -> PatchesT:
def _find_by_py_launcher(
        version: str,
) -> str | None:  # pragma: no cover (windows only)
def _find_by_sys_executable() -> str | None:
    def _norm(path: str) -> str | None:
def get_default_version() -> str:  # pragma: no cover (platform dependent)
def _sys_executable_matches(version: str) -> bool:
def norm_version(version: str) -> str | None:
def in_env(
        prefix: Prefix,
        language_version: str,
) -> Generator[None, None, None]:
def healthy(prefix: Prefix, language_version: str) -> bool:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'renv'
RSCRIPT_OPTS = ('--no-save', '--no-restore', '--no-site-file', '--no-environ')
def get_env_patch(venv: str) -> PatchesT:
def in_env(
        prefix: Prefix,
        language_version: str,
) -> Generator[None, None, None]:
def _get_env_dir(prefix: Prefix, version: str) -> str:
def _prefix_if_non_local_file_entry(
    entry: Sequence[str],
    prefix: Prefix,
    src: str,
) -> Sequence[str]:
def _rscript_exec() -> str:
def _entry_validate(entry: Sequence[str]) -> None:
def _cmd_from_hook(hook: Hook) -> tuple[str, ...]:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
def _inline_r_setup(code: str) -> str:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'rbenv'
def get_default_version() -> str:
def get_env_patch(
        venv: str,
        language_version: str,
) -> PatchesT:
def in_env(
        prefix: Prefix,
        language_version: str,
) -> Generator[None, None, None]:
def _extract_resource(filename: str, dest: str) -> None:
def _install_rbenv(
        prefix: Prefix,
        version: str,
) -> None:  # pragma: win32 no cover
def _install_ruby(
        prefix: Prefix,
        version: str,
) -> None:  # pragma: win32 no cover
def install_environment(
        prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'rustenv'
def get_env_patch(target_dir: str) -> PatchesT:
def in_env(prefix: Prefix) -> Generator[None, None, None]:
def _add_dependencies(
        cargo_toml_path: str,
        additional_dependencies: set[str],
) -> None:
def install_environment(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
) -> None:
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = None
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: ENVIRONMENT_DIR = 'swift_env'
BUILD_DIR = '.build'
BUILD_CONFIG = 'release'
def get_env_patch(venv: str) -> PatchesT:  # pragma: win32 no cover
def in_env(prefix: Prefix) -> Generator[None, None, None]:
def install_environment(
        prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None:  # pragma: win32 no cover
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]:  # pragma: win32 no cover ENVIRONMENT_DIR = None
def run_hook(
        hook: Hook,
        file_args: Sequence[str],
        color: bool,
) -> tuple[int, bytes]: class Prefix(NamedTuple):
    prefix_dir: str

    def path(self, *parts: str) -> str:
        return os.path.normpath(os.path.join(self.prefix_dir, *parts))

    def exists(self, *parts: str) -> bool:
        return os.path.exists(self.path(*parts))

    def star(self, end: str) -> tuple[str, ...]:
        paths = os.listdir(self.prefix_dir)
        return tuple(path for path in paths if path.endswith(end))
from typing import Callable
from typing import NamedTuple
from typing import Sequence
from pre_commit.hook import Hook
from pre_commit.languages import conda
from pre_commit.languages import coursier
from pre_commit.languages import dart
from pre_commit.languages import docker
from pre_commit.languages import docker_image
from pre_commit.languages import dotnet
from pre_commit.languages import fail
from pre_commit.languages import golang
from pre_commit.languages import lua
from pre_commit.languages import node
from pre_commit.languages import perl
from pre_commit.languages import pygrep
from pre_commit.languages import python
from pre_commit.languages import r
from pre_commit.languages import ruby
from pre_commit.languages import rust
from pre_commit.languages import script
from pre_commit.languages import swift
from pre_commit.languages import system
from pre_commit.prefix import Prefix
from __future__ import annotations




class Language(NamedTuple):
    name: str
    # Use `None` for no installation / environment
    ENVIRONMENT_DIR: str | None
    # return a value to replace `'default` for `language_version`
    get_default_version: Callable[[], str]
    # return whether the environment is healthy (or should be rebuilt)
    healthy: Callable[[Prefix, str], bool]
    # install a repository for the given language and language_version
    install_environment: Callable[[Prefix, str, Sequence[str]], None]
    # execute a hook and return the exit code and output
    run_hook: Callable[[Hook, Sequence[str], bool], tuple[int, bytes]]


# TODO: back to modules + Protocol: https://github.com/python/mypy/issues/5018
languages = {
    # BEGIN GENERATED (testing/gen-languages-all)
    'conda': Language(name='conda', ENVIRONMENT_DIR=conda.ENVIRONMENT_DIR, get_default_version=conda.get_default_version, healthy=conda.healthy, install_environment=conda.install_environment, run_hook=conda.run_hook),  # noqa: E501
    'coursier': Language(name='coursier', ENVIRONMENT_DIR=coursier.ENVIRONMENT_DIR, get_default_version=coursier.get_default_version, healthy=coursier.healthy, install_environment=coursier.install_environment, run_hook=coursier.run_hook),  # noqa: E501
    'dart': Language(name='dart', ENVIRONMENT_DIR=dart.ENVIRONMENT_DIR, get_default_version=dart.get_default_version, healthy=dart.healthy, install_environment=dart.install_environment, run_hook=dart.run_hook),  # noqa: E501
    'docker': Language(name='docker', ENVIRONMENT_DIR=docker.ENVIRONMENT_DIR, get_default_version=docker.get_default_version, healthy=docker.healthy, install_environment=docker.install_environment, run_hook=docker.run_hook),  # noqa: E501

    'docker_image': Language(name='docker_image', ENVIRONMENT_DIR=docker_image.ENVIRONMENT_DIR, get_default_version=docker_image.get_default_version, healthy=docker_image.healthy, install_environment=docker_image.install_environment, run_hook=docker_image.run_hook),  # noqa: E501