mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add 'types' to the schema
This commit is contained in:
parent
70bd8215b2
commit
a68c1ab0d2
5 changed files with 23 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ import argparse
|
|||
import functools
|
||||
|
||||
from aspy.yaml import ordered_load
|
||||
from identify.identify import ALL_TAGS
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import schema
|
||||
|
|
@ -19,6 +20,14 @@ def check_language(v):
|
|||
)
|
||||
|
||||
|
||||
def check_type_tag(tag):
|
||||
if tag not in ALL_TAGS:
|
||||
raise schema.ValidationError(
|
||||
'Type tag {!r} is not recognized. '
|
||||
'Try upgrading identify and pre-commit?'.format(tag),
|
||||
)
|
||||
|
||||
|
||||
def _make_argparser(filenames_help):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*', help=filenames_help)
|
||||
|
|
@ -36,10 +45,11 @@ MANIFEST_HOOK_DICT = schema.Map(
|
|||
'language', schema.check_and(schema.check_string, check_language),
|
||||
),
|
||||
|
||||
schema.Conditional(
|
||||
schema.Optional(
|
||||
'files', schema.check_and(schema.check_string, schema.check_regex),
|
||||
condition_key='always_run', condition_value=False,
|
||||
'',
|
||||
),
|
||||
schema.Optional('types', schema.check_array(check_type_tag), ['file']),
|
||||
|
||||
schema.Optional(
|
||||
'additional_dependencies', schema.check_array(schema.check_string), [],
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ NO_FILES = '(no files to check)'
|
|||
|
||||
|
||||
def _run_single_hook(hook, repo, args, skips, cols):
|
||||
filenames = get_filenames(args, hook.get('files', '^$'), hook['exclude'])
|
||||
filenames = get_filenames(args, hook['files'], hook['exclude'])
|
||||
if hook['id'] in skips:
|
||||
output.write(get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue