MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / Hook

Class Hook

pre_commit/hook.py:13–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class Hook(NamedTuple):
14 src: str
15 prefix: Prefix
16 id: str
17 name: str
18 entry: str
19 language: str
20 alias: str
21 files: str
22 exclude: str
23 types: Sequence[str]
24 types_or: Sequence[str]
25 exclude_types: Sequence[str]
26 additional_dependencies: Sequence[str]
27 args: Sequence[str]
28 always_run: bool
29 fail_fast: bool
30 pass_filenames: bool
31 description: str
32 language_version: str
33 log_file: str
34 minimum_pre_commit_version: str
35 require_serial: bool
36 stages: Sequence[str]
37 verbose: bool
38
39 @property
40 def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
41 return (
42 self.prefix,
43 self.language,
44 self.language_version,
45 tuple(self.additional_dependencies),
46 )
47
48 @classmethod
49 def create(cls, src: str, prefix: Prefix, dct: dict[str, Any]) -> Hook:
50 # TODO: have cfgv do this (?)
51 extra_keys = set(dct) - _KEYS
52 if extra_keys:
53 logger.warning(
54 f'Unexpected key(s) present on {src} => {dct["id"]}: '
55 f'{", ".join(sorted(extra_keys))}',
56 )
57 return cls(src=src, prefix=prefix, **{k: dct[k] for k in _KEYS})
58
59
60_KEYS = frozenset(set(Hook._fields) - {'src', 'prefix'})

Callers 1

test_manifest_hooksFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_manifest_hooksFunction · 0.72