adjust the run_hook api to no longer take Hook

This commit is contained in:
Anthony Sottile
2023-01-16 16:34:01 -05:00
parent 48ae18a2cb
commit 628c876b2d
26 changed files with 163 additions and 192 deletions

View File

@@ -2,8 +2,8 @@ from __future__ import annotations
from typing import Sequence
from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
ENVIRONMENT_DIR = None
get_default_version = helpers.basic_get_default_version
@@ -13,10 +13,14 @@ in_env = helpers.no_env
def run_hook(
hook: Hook,
prefix: Prefix,
entry: str,
args: Sequence[str],
file_args: Sequence[str],
*,
require_serial: bool,
color: bool,
) -> tuple[int, bytes]:
out = f'{hook.entry}\n\n'.encode()
out = f'{entry}\n\n'.encode()
out += b'\n'.join(f.encode() for f in file_args) + b'\n'
return 1, out