MCPcopy
hub / github.com/pre-commit/pre-commit / run_language

Function run_language

testing/language_helpers.py:10–40  ·  view source on GitHub ↗
(
        path: os.PathLike[str],
        language: Language,
        exe: str,
        args: Sequence[str] = (),
        file_args: Sequence[str] = (),
        version: str | None = None,
        deps: Sequence[str] = (),
        is_local: bool = False,
        require_serial: bool = True,
        color: bool = False,
)

Source from the content-addressed store, hash-verified

8
9
10def run_language(
11 path: os.PathLike[str],
12 language: Language,
13 exe: str,
14 args: Sequence[str] = (),
15 file_args: Sequence[str] = (),
16 version: str | None = None,
17 deps: Sequence[str] = (),
18 is_local: bool = False,
19 require_serial: bool = True,
20 color: bool = False,
21) -> tuple[int, bytes]:
22 prefix = Prefix(str(path))
23 version = version or language.get_default_version()
24
25 if language.ENVIRONMENT_DIR is not None:
26 language.install_environment(prefix, version, deps)
27 health_error = language.health_check(prefix, version)
28 assert health_error is None, health_error
29 with language.in_env(prefix, version):
30 ret, out = language.run_hook(
31 prefix,
32 exe,
33 args,
34 file_args,
35 is_local=is_local,
36 require_serial=require_serial,
37 color=color,
38 )
39 out = out.replace(b'\r\n', b'\n')
40 return ret, out

Callers 15

_hook_runFunction · 0.90
test_hazmatFunction · 0.90
test_simple_python_hookFunction · 0.90
test_r_hookFunction · 0.90
test_r_inlineFunction · 0.90
test_run_depFunction · 0.90
test_run_emptyFunction · 0.90

Calls 6

PrefixClass · 0.90
get_default_versionMethod · 0.80
install_environmentMethod · 0.80
health_checkMethod · 0.80
in_envMethod · 0.80
run_hookMethod · 0.80

Tested by 15

_hook_runFunction · 0.72
test_hazmatFunction · 0.72
test_simple_python_hookFunction · 0.72
test_r_hookFunction · 0.72
test_r_inlineFunction · 0.72
test_run_depFunction · 0.72
test_run_emptyFunction · 0.72