mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add warning to additional keys in config
This commit is contained in:
parent
75651dc8b0
commit
fd9d9d276b
2 changed files with 40 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import argparse
|
||||
import functools
|
||||
import logging
|
||||
import pipes
|
||||
import sys
|
||||
|
||||
|
|
@ -15,6 +16,8 @@ from pre_commit.error_handler import FatalError
|
|||
from pre_commit.languages.all import all_languages
|
||||
from pre_commit.util import parse_version
|
||||
|
||||
logger = logging.getLogger('pre_commit')
|
||||
|
||||
|
||||
def check_type_tag(tag):
|
||||
if tag not in ALL_TAGS:
|
||||
|
|
@ -144,6 +147,16 @@ def _entry(modname):
|
|||
)
|
||||
|
||||
|
||||
def warn_on_unknown_keys_at_top_level(extra, orig_keys):
|
||||
logger.warning(
|
||||
'Your pre-commit-config contain these extra keys: {}. '
|
||||
'while the only valid keys are: {}.'.format(
|
||||
', '.join(extra),
|
||||
', '.join(sorted(orig_keys)),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
_meta = (
|
||||
(
|
||||
'check-hooks-apply', (
|
||||
|
|
@ -222,6 +235,10 @@ CONFIG_REPO_DICT = cfgv.Map(
|
|||
),
|
||||
|
||||
MigrateShaToRev(),
|
||||
cfgv.WarnAdditionalKeys(
|
||||
{'repo', 'rev', 'hooks'},
|
||||
warn_on_unknown_keys_at_top_level,
|
||||
),
|
||||
)
|
||||
DEFAULT_LANGUAGE_VERSION = cfgv.Map(
|
||||
'DefaultLanguageVersion', None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue