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

Function _hook

pre_commit/repository.py:109–144  ·  view source on GitHub ↗
(
        *hook_dicts: dict[str, Any],
        root_config: dict[str, Any],
)

Source from the content-addressed store, hash-verified

107
108
109def _hook(
110 *hook_dicts: dict[str, Any],
111 root_config: dict[str, Any],
112) -> dict[str, Any]:
113 ret, rest = dict(hook_dicts[0]), hook_dicts[1:]
114 for dct in rest:
115 ret.update(dct)
116
117 lang = ret['language']
118 if ret['language_version'] == C.DEFAULT:
119 ret['language_version'] = root_config['default_language_version'][lang]
120 if ret['language_version'] == C.DEFAULT:
121 ret['language_version'] = languages[lang].get_default_version()
122
123 if not ret['stages']:
124 ret['stages'] = root_config['default_stages']
125
126 if languages[lang].ENVIRONMENT_DIR is None:
127 if ret['language_version'] != C.DEFAULT:
128 logger.error(
129 f'The hook `{ret["id"]}` specifies `language_version` but is '
130 f'using language `{lang}` which does not install an '
131 f'environment. '
132 f'Perhaps you meant to use a specific language?',
133 )
134 exit(1)
135 if ret['additional_dependencies']:
136 logger.error(
137 f'The hook `{ret["id"]}` specifies `additional_dependencies` '
138 f'but is using language `{lang}` which does not install an '
139 f'environment. '
140 f'Perhaps you meant to use a specific language?',
141 )
142 exit(1)
143
144 return ret
145
146
147def _non_cloned_repository_hooks(

Callers 2

_cloned_repository_hooksFunction · 0.85

Calls 2

updateMethod · 0.80
get_default_versionMethod · 0.80

Tested by

no test coverage detected