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

Function _check_args_length

pre_commit/commands/hook_impl.py:189–211  ·  view source on GitHub ↗
(hook_type: str, args: Sequence[str])

Source from the content-addressed store, hash-verified

187
188
189def _check_args_length(hook_type: str, args: Sequence[str]) -> None:
190 if hook_type == 'prepare-commit-msg':
191 if len(args) < 1 or len(args) > 3:
192 raise SystemExit(
193 f'hook-impl for {hook_type} expected 1, 2, or 3 arguments '
194 f'but got {len(args)}: {args}',
195 )
196 elif hook_type == 'pre-rebase':
197 if len(args) < 1 or len(args) > 2:
198 raise SystemExit(
199 f'hook-impl for {hook_type} expected 1 or 2 arguments '
200 f'but got {len(args)}: {args}',
201 )
202 elif hook_type in _EXPECTED_ARG_LENGTH_BY_HOOK:
203 expected = _EXPECTED_ARG_LENGTH_BY_HOOK[hook_type]
204 if len(args) != expected:
205 arguments_s = 'argument' if expected == 1 else 'arguments'
206 raise SystemExit(
207 f'hook-impl for {hook_type} expected {expected} {arguments_s} '
208 f'but got {len(args)}: {args}',
209 )
210 else:
211 raise AssertionError(f'unexpected hook type: {hook_type}')
212
213
214def _run_ns(

Callers 1

_run_nsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected